BUG?? - Empty Dates produce undefined offset in general_functions.php

taubes

Member
Hi Eugenio,

I hope you can help quickly. When I use empty dates in a query, I get the following notice for each record with an empty date format
Notice: Undefined offset: 1 in ...sqlite/include/general_functions.php on line 287
Notice: Undefined offset: 2 in ...sqlite/include/general_functions.php on line 287

in the results view it shows me two dashes "--" which I presume are the left-overs form the empty date. I have never seen this before and it may be specific to a sqlite database or the latest release. I did not have time to check.

Best

Stefan
---
You are using DaDaBIK version 9.2.2-Monterosso enterprise, installed on 03-13-2019 (installation code: 144695c88e79047861), the latest version of DaDaBIK is 9.2.2-Monterosso released on 03-05-2019
PHP Version: 5.6.37
sqlite version: 3.8.10.2
Web server: Apache/2.4.34 (Unix) PHP/5.6.37
Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.2 Safari/605.1.15
 

taubes

Member
When I choose literal_english as a date_format in the config file, it always shows Jan 1, 1970 for empty dates. Any other date_format produces just the date_separators "--".
 

eugenio

Administrator
Staff member
Hello Stefan,
I don't see anything in the new version that could be related to your issue.

Can you explain more in details? Are you referring to just browsing a table containing empty dates? When you say empty, do you mean that in the database they are NULL?

Best,
 

taubes

Member
Dear Eugenio,

The wrong date Jan 1, 1970 (literal_english) or the date_separators (any other date format) are shown in the results view. For some reason the date field is empty but not Null when a new record is created. I have tried to set the sqlite database field type to TEXT or DATE and it makes no difference. When I go into the database and set the date field to Null manually it shows everything correctly. However every new record created that has an empty date field gives this error.

I can fix this now by setting $treat_blank_as_null = 1; in the config.php. Once I modify the old entries this gets fixed too but not automatically.

$treat_blank_as_null = 0; produces this error reproducibly for empty dates in an sqlite database. I have not tried the server-based MYSQL databases with $treat_blank_as_null = 0; in the current release yet.

Hope this helps,

Stefan
 

eugenio

Administrator
Staff member
The thing is that typically (and differently from strings) an "empty" date shouldn't exist, either you have a NULL date or an actual date.

Can you confirm that with:

$treat_blank_as_null = 1;

everything is correctly working for NEW records?

If yes, I would "clean" with a SQL query the "wrong" old dates you have in your db, setting them to NULL for every empty (or Jan 1, 1970) date.

Best,
 
Top