View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
17730Bug reportsSurvey editingpublic2022-01-12 19:45
Reportermhladun Assigned Togalads  
PrioritynoneSeverityminor 
Status assignedResolutionopen 
Product Version5.2.x 
Summary17730: Survey Theme Update - Datecreated is Invalid
DescriptionI've inquired about this issue here: https://forums.limesurvey.org/forum/development/125954-theme-update-datecreated-is-invalid.

Basically, when updating from one existing theme to another, the error message "Survey could not be updated, please fix the following error: The format of Datecreated is invalid." appears. See the attached image for the error message overlaying the page. The themes I am switching between are pre-installed themes like "Fruity" and "Vanilla". The error is raised after clicking the Save button.

I've tried updating LS a few times. I started at 5.1.17+211025 then went to 5.2.1+211111 and now I am at 5.2.2+211115 and the bug is still present. I also tried resetting all the themes and received the same message.
Steps To ReproduceSteps to reproduce
------------------------------
Make a survey (it can be blank with no questions).
Go it the general survey settings and change to another pre-installed theme (e.g. Fruity to Vanilla).
Click save.

Expected result
-------------------------
The theme is updated.

Actual result
-----------------
The theme is not updated and a red banner will appear with the Datecreated is invalid error message. (See screenshot)
The error logs also receive a single message:
    "[error] [application.LimeExpressionManager] setVariableAndTokenMappingsForExpressionManager with an empty surveyOptions."

Tagsdatecreated, survey, surveyOptions, theme
Bug heat10
Complete LimeSurvey version number (& build)5.2.2+211115
I will donate to the project if issue is resolvedNo
BrowserBrave/Chrome
Database type & versionPostgresql/EnterpriseDB 10.9.17
Server OS (if known)Windows Server 2019 Datacenter
Webserver software & version (if known)nginx 1.20.1
PHP Version8.0.12

Users monitoring this issue

User List DenisChenu, mhladun

Activities

mhladun

mhladun

2021-11-17 15:31

reporter  

w.png (72,592 bytes)   
w.png (72,592 bytes)   
mhladun

mhladun

2021-12-08 17:04

reporter   ~67743

In the application logs, I receive "2021/12/08 17:01:43 [error] [application.LimeExpressionManager] setVariableAndTokenMappingsForExpressionManager with an empty surveyOptions." when trying to change the theme. I've also tried a few different date formats (including the removal of the creationDate xml element) in configs.xml, but nothing seems to work.
gabrieljenik

gabrieljenik

2021-12-23 15:25

manager   ~67860

We couldn't reproduce it in master with postgre. Can you try again please with the steps you provided?

Is the error happening with new surveys or with pre-existing surveys?

Thanks!
mhladun

mhladun

2022-01-11 17:37

reporter   ~67966

Hi Gabriel, the error happens with new and existing surveys. I've also noticed it happens when I try to save other survey properties as well, such as settings in the Publication and Access tab (Link survey on public index page), settings in the Presentation tab (Show "There are X questions in this survey"), etc.

The lime_surveys.datecreated field in our Postgresql database is a timestamp of the form YYYY-MM-DD 24H:MM:SS.fff. For example, 2021-11-11 18:11:32.000 2021-12-15 20:38:52.000 2021-11-25 23:30:14.000.

I've been able to side-step the GUI error by making manual changes to the database fields thus far.
gabrieljenik

gabrieljenik

2022-01-12 13:53

manager   ~67969

Last edited: 2022-01-12 14:15

View 4 revisions

Can I please ask you a screenshot of the definition of the startdate and datecreated fields in the database?
Also, does this happen when you update something on an active survey? or only to deactivated surveys?

Can I also ask you to add this line (temporary) on application/controllers/admin/database.php, line 922

```
Yii::log("Trying to save with this date " . $oSurvey->datecreated, \CLogger::LEVEL_ERROR, 'application.controller.database');
```
gabrieljenik

gabrieljenik

2022-01-12 14:14

manager   ~67970

Like this.
image.png (44,322 bytes)   
image.png (44,322 bytes)   
gabrieljenik

gabrieljenik

2022-01-12 14:34

manager   ~67971

Our thought is that somehow, the postgre DB saves the values with a precision of more than 3 digits on the timestamp.
After loading that value from DB and trying to save, that makes the validation rule to fail.
mhladun

mhladun

2022-01-12 16:12

reporter   ~67973

Here are the database definitions for the fields originating in the lime_surveys table.

It happens on active and deactive surveys.

Also, adding that line (using setFlashMessage instead of log) to database.php, we get "Trying to save with this date 11-JAN-22 23:01:46", see photo.
image-3.png (9,834 bytes)   
image-3.png (9,834 bytes)   
image-4.png (9,727 bytes)   
image-4.png (9,727 bytes)   
image-5.png (8,815 bytes)   
image-5.png (8,815 bytes)   
image-2.png (26,601 bytes)   
image-2.png (26,601 bytes)   
gabrieljenik

gabrieljenik

2022-01-12 16:54

manager   ~67974

Thanks!

I think the issue is with some deault PHP/PDO option when picking up the date from the DB.
Will review
gabrieljenik

gabrieljenik

2022-01-12 17:07

manager   ~67975

Last edited: 2022-01-12 17:11

View 2 revisions

Does this help?
https://www.postgresql.org/docs/9.1/runtime-config-client.html#GUC-DATESTYLE
https://www.postgresql.org/docs/9.6/locale.html

I believe it is a DB / Locale setting issue.
gabrieljenik

gabrieljenik

2022-01-12 17:26

manager   ~67976

Check the DateStyle parameter on the DB. That should be it.
mhladun

mhladun

2022-01-12 17:27

reporter   ~67977

Running "show datestyle;" gives me "ISO, DMY"

From https://www.postgresql.org/docs/9.1/datatype-datetime.html#AEN5595, it seems like this date from should work ("08-Jan-99 --> January 8, except error in YMD mode")
gabrieljenik

gabrieljenik

2022-01-12 17:31

manager   ~67978

When querying, DB is returning dates on a style which is later not accepted by the validations done on LS.
DB will accept the values, but it is the app validations that are failing before getting to intent saving on the DB.

Please, try changing it. "SQL, DMY" may work
DenisChenu

DenisChenu

2022-01-12 17:35

developer   ~67979

@gabrieljenik : https://github.com/LimeSurvey/LimeSurvey/blob/74f4ee3ee6b9632adff9a0c1bdae946f4eae4b86/application/models/Survey.php#L535

Seems rules accept 2022-01-11 23:01:28.000 ?

Else : maybe need fixed when show form ?
mhladun

mhladun

2022-01-12 18:03

reporter   ~67980

Adding "set datestyle to SQL, DMY" to the configs.php initSQLs array gives "Trying to save with this date 11/01/2022 23:01:46" with the same dateCreated error.
image-6.png (8,677 bytes)   
image-6.png (8,677 bytes)   
gabrieljenik

gabrieljenik

2022-01-12 18:06

manager   ~67981

Then, ISO should be good.
Can I ask you to try changing locale settings? Maybe on windows itself?
gabrieljenik

gabrieljenik

2022-01-12 18:08

manager   ~67982

> maybe need fixed when show form ?

@DenisChenu I don't think so. This is an issue for dates when:
- model is loaded
- date is not updated
- model is saved
- rule fails.

Form is not involved I believe
DenisChenu

DenisChenu

2022-01-12 18:10

developer   ~67983

Strangely : trying to save 11/01/2022 23:01:46 must broke on SQL and MARIADB too …

Else : we don't show datecreated in form … then you're right …
mhladun

mhladun

2022-01-12 19:27

reporter   ~67984

Using 'initSQLs'=>array(..., 'set datestyle to ISO, DMY'), in config.php seems to have solved this... "ISO, DMY" is the result of "show datestyle;" but it's also what I use in initSQLs...
image-7.png (6,103 bytes)   
image-7.png (6,103 bytes)   
gabrieljenik

gabrieljenik

2022-01-12 19:30

manager   ~67985

Great! What do you mean by " I use in initSQLs"?
mhladun

mhladun

2022-01-12 19:45

reporter   ~67986

I just meant to say that "ISO, DMY" is the same datestyle in

# configs.php
'set datestyle to ISO, DMY' in 'initSQLs'=>array(..., 'set datestyle to ISO, DMY')

and

# postgresql
>>> show datestyle;
ISO, DMY

So it's odd this changes anything, but I'm very happy this is working now!

Issue History

Date Modified Username Field Change
2021-11-17 15:31 mhladun New Issue
2021-11-17 15:31 mhladun File Added: Screenshot 2021-11-16 184347.png
2021-11-17 15:31 mhladun File Added: w.png
2021-11-17 15:32 mhladun Tag Attached: theme
2021-11-17 15:32 mhladun Tag Attached: datecreated
2021-11-17 15:32 mhladun Tag Attached: survey
2021-11-17 15:32 mhladun Tag Attached: surveyOptions
2021-11-17 15:40 mhladun Issue Monitored: mhladun
2021-11-17 15:40 mhladun Bug heat 0 => 2
2021-11-17 15:43 DenisChenu Issue Monitored: DenisChenu
2021-11-17 15:43 DenisChenu Bug heat 2 => 4
2021-11-17 15:58 galads Assigned To => galads
2021-11-17 15:58 galads Status new => confirmed
2021-11-17 15:59 galads Description Updated View Revisions
2021-11-17 15:59 galads Steps to Reproduce Updated View Revisions
2021-12-08 17:04 mhladun Note Added: 67743
2021-12-08 17:04 mhladun Bug heat 4 => 6
2021-12-23 15:25 gabrieljenik Note Added: 67860
2021-12-23 15:25 gabrieljenik Bug heat 6 => 8
2022-01-11 16:26 galads Status confirmed => feedback
2022-01-11 17:37 mhladun Note Added: 67966
2022-01-11 17:37 mhladun File Added: changing public index page setting 2022-01-11 112659.png
2022-01-11 17:37 mhladun File Added: dbeaver date created 2022-01-11 113646.png
2022-01-11 17:37 mhladun Status feedback => assigned
2022-01-12 13:53 gabrieljenik Note Added: 67969
2022-01-12 13:56 gabrieljenik Note Edited: 67969 View Revisions
2022-01-12 14:14 gabrieljenik Note Edited: 67969 View Revisions
2022-01-12 14:14 gabrieljenik Note Added: 67970
2022-01-12 14:14 gabrieljenik File Added: image.png
2022-01-12 14:15 gabrieljenik Note Edited: 67969 View Revisions
2022-01-12 14:34 gabrieljenik Note Added: 67971
2022-01-12 16:12 mhladun Note Added: 67973
2022-01-12 16:12 mhladun File Added: image-2.png
2022-01-12 16:12 mhladun File Added: image-3.png
2022-01-12 16:12 mhladun File Added: image-4.png
2022-01-12 16:12 mhladun File Added: image-5.png
2022-01-12 16:54 gabrieljenik Note Added: 67974
2022-01-12 17:07 gabrieljenik Note Added: 67975
2022-01-12 17:11 gabrieljenik Note Edited: 67975 View Revisions
2022-01-12 17:26 gabrieljenik Note Added: 67976
2022-01-12 17:27 mhladun Note Added: 67977
2022-01-12 17:31 gabrieljenik Note Added: 67978
2022-01-12 17:35 DenisChenu Note Added: 67979
2022-01-12 17:35 DenisChenu Bug heat 8 => 10
2022-01-12 18:03 mhladun Note Added: 67980
2022-01-12 18:03 mhladun File Added: image-6.png
2022-01-12 18:06 gabrieljenik Note Added: 67981
2022-01-12 18:08 gabrieljenik Note Added: 67982
2022-01-12 18:10 DenisChenu Note Added: 67983
2022-01-12 19:27 mhladun Note Added: 67984
2022-01-12 19:27 mhladun File Added: image-7.png
2022-01-12 19:30 gabrieljenik Note Added: 67985
2022-01-12 19:45 mhladun Note Added: 67986