View Issue Details

This bug affects 2 person(s).
 16
IDProjectCategoryView StatusLast Update
18381Feature requestsPluginspublic2022-11-23 14:41
Reporterbismark Assigned ToDenisChenu  
PrioritynormalSeverityfeature 
Status assignedResolutionopen 
Summary18381: PluginSetting type date must be saved as a common datetime string
Description

my personal dateformat is tt.mm.jjjj
now a PluginSetting type date will be saved as 02.09.2022 15:30
but I would expect a common date format like 2022-09-02 15:30

Steps To Reproduce

Steps to reproduce

(Replace this text with detailed step-by-step instructions on how to reproduce the issue)

Expected result

(Write here what you expected to happen)

Actual result

(Write here what happened instead)

TagsNo tags attached.
Bug heat16

Relationships

child of 18330 closedDenisChenu Bug reports SurveySetting type date doesnt show datepicker 

Users monitoring this issue

User List There are no users monitoring this issue.

Activities

ollehar

ollehar

2022-09-28 13:19

administrator   ~71995

Can you fix this without breaking old plugins?

c_schmitz

c_schmitz

2022-09-28 15:35

administrator   ~72005

I don't think this is a bug, but a feature.
Currently there is no typing at all used for saving plugin settings. The existing typing only determines how the setting is displayed using the SettingsWidget.

c_schmitz

c_schmitz

2022-09-28 15:39

administrator   ~72006

To keep backward_compatibilty I would just introduce a new field type and name it 'datetime' instead of 'date'. Mark 'date' as obsolete for future major versions.

Mazi

Mazi

2022-09-30 10:07

updater   ~72025

The fix for https://bugs.limesurvey.org/view.php?id=18330 leads to a far better usage of date type fields at plugin settings. But it can also cause serious issues. A user with date format setting yyyy-mm-dd may be entering a plugin setting like 2022-12-31. The date may be used for certain calculations or triggering email sending.
Then another user e.g. from Germany with date format dd.mm.yyyy edits the same setting and changes the day to "24" but then it gets saved as 24.12.2022 at the DB. All calculations or the like will be broken.

So whatever solution we aim for, we should make sure that we always have a valid date format stored for this field type, similar to how we deal with a token's expiry date for example.

DenisChenu

DenisChenu

2022-09-30 12:24

developer   ~72028

Can you fix this without breaking old plugins?

We have same issue with password : how to fix it …

To keep backward_compatibilty I would just introduce a new field type and name it 'datetime' instead of 'date'. Mark 'date' as obsolete for future major versions.

We don' have different way to save settings according to type currently … we can fix it for surveySetting before send it to the event. But for global one : there are only one function maybe extended by plugin.

Survey : https://github.com/LimeSurvey/LimeSurvey/blob/32aa344f92cee033805f3f788aac2f48a8cfded0/application/controllers/admin/Database.php#L661 We can update some before send it to plugin
Global : https://github.com/LimeSurvey/LimeSurvey/blob/32aa344f92cee033805f3f788aac2f48a8cfded0/application/libraries/PluginManager/PluginBase.php#L257 (i extend it a lot …)

The fix for https://bugs.limesurvey.org/view.php?id=18330 leads to a far better usage of date type fields at plugin settings.

Maybe best solution is to force datetime to be in ISO/SQL format here ?

Mazi

Mazi

2022-10-04 12:10

updater   ~72068

Forcing ISO/SQL format is fine with me. We just need to make sure that users are not able to enter something invalid.

Mazi

Mazi

2022-10-28 14:25

updater   ~72463

@c_schmitz, can we assign this to a developer so it gets included at the next sprint? We need it in 2-4 weeks for a new project.

@DenisChenu, do you want to pick this one since you also worked on https://bugs.limesurvey.org/view.php?id=18330 ?

c_schmitz

c_schmitz

2022-10-28 15:07

administrator   ~72464

I am sorry but it is not a priority for us and it is more like a new feature. Maybe you can hire Denis directly, if this can be implemented in a backward-comptible manner?

DenisChenu

DenisChenu

2022-10-28 15:23

developer   ~72465

@bismark have competency to do it i think :)

Else : the way i do it for password ? https://github.com/LimeSurvey/LimeSurvey/pull/2651

Adding a option : 'saveasiso'=>true

Mazi

Mazi

2022-10-28 15:40

updater   ~72466

My preference is adding a new setting type "isodate" which has a date picker but always stores details as YYYY-MM-DD format.

We just need the time for implementing this. @gabrieljenik, would you be able to provide a helping hand (paid support)?

DenisChenu

DenisChenu

2022-10-28 15:41

developer   ~72467

isodate is better than saveasiso :+1:

Currently not a lot of time :)

gabrieljenik

gabrieljenik

2022-10-31 14:35

manager   ~72486

I think the term "attribute on the setting type" and "setting type" are begin used inter-changabely.

With an attribute on the setting type, the impact is minor I think, right?

DenisChenu

DenisChenu

2022-10-31 15:31

developer   ~72490

With an attribute on the setting type, the impact is minor I think, right?

Extra options 'isodate' => false by default don't change anything for old plugins.

gabrieljenik

gabrieljenik

2022-11-23 14:29

manager   ~72860

HI @DenisChenu,

From what I spoken with Marcel, you will take this, right?

DenisChenu

DenisChenu

2022-11-23 14:41

developer   ~72861

?

I don't remind , but OK :)

Issue History

Date Modified Username Field Change
2022-09-28 11:55 bismark New Issue
2022-09-28 13:19 ollehar Note Added: 71995
2022-09-28 13:19 ollehar Bug heat 0 => 2
2022-09-28 15:28 gabrieljenik Status new => acknowledged
2022-09-28 15:35 c_schmitz Note Added: 72005
2022-09-28 15:35 c_schmitz Bug heat 2 => 4
2022-09-28 15:39 c_schmitz Note Added: 72006
2022-09-30 10:07 Mazi Note Added: 72025
2022-09-30 10:07 Mazi Bug heat 4 => 6
2022-09-30 10:07 Mazi Relationship added child of 18330
2022-09-30 12:24 DenisChenu Note Added: 72028
2022-09-30 12:24 DenisChenu Bug heat 6 => 8
2022-10-04 12:10 Mazi Note Added: 72068
2022-10-28 14:25 Mazi Note Added: 72463
2022-10-28 15:07 c_schmitz Note Added: 72464
2022-10-28 15:23 DenisChenu Note Added: 72465
2022-10-28 15:40 Mazi Note Added: 72466
2022-10-28 15:41 DenisChenu Note Added: 72467
2022-10-31 13:50 gabrieljenik Project Bug reports => Feature requests
2022-10-31 14:35 gabrieljenik Note Added: 72486
2022-10-31 14:35 gabrieljenik Bug heat 8 => 10
2022-10-31 14:36 gabrieljenik Assigned To => gabrieljenik
2022-10-31 14:36 gabrieljenik Status acknowledged => assigned
2022-10-31 15:31 DenisChenu Note Added: 72490
2022-11-01 18:34 guest Bug heat 10 => 16
2022-11-23 14:28 gabrieljenik Assigned To gabrieljenik => DenisChenu
2022-11-23 14:29 gabrieljenik Note Added: 72860
2022-11-23 14:41 DenisChenu Note Added: 72861
2022-11-23 14:41 DenisChenu Priority none => normal
2022-11-23 14:41 DenisChenu Severity @50@ => feature