Closed (fixed)
Project:
Date
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Aug 2020 at 07:38 UTC
Updated:
23 Mar 2021 at 23:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
damienmckennaDoes the field have a value2, i.e. a "to" date? Looking at the code in question it's expecting there to be one defined.
Comment #3
preethy211 commentedNo there is no 'to' date to it. And the errors are thrown on the lines of the default switch case where 'value' and 'value2' is retrieved and stored in date1 and date2 respectively. The same error is being thrown in 5 places wherever 'value' and 'value2' is being used as mentioned below,
Comment #4
preethy211 commentedComment #5
derekw commentedHad the same error. In my case I had a bunch of NULL values in the field_data_[date field] table. Maybe from an old import as the newer nodes with the same field didn't have that problem (if the value wasn't entered there wasn't a table row for it).
Comment #6
damienmckenna@derekw: I suspect NULL issues on data that was imported would indicate a problem with the imported data, that you could fix with an update script.
@preethy211: Was your data imported, or was it created via the admin
Comment #7
preethy211 commented@damienmckenna:
date_field/content type was imported by admin but with "Collect End date" disabled
DATA to this field/content type are manually added by site users
Comment #8
lavamind commented@damienmckenna:
I'm also hitting this bug. The content was not imported. The date field value is being set to NULL by a core Rules "Set a data value" action. Under the hood, this is done using a
$field->set(NULL);call where$fieldis an instance ofEntityMetadataWrapper. See https://git.drupalcode.org/project/rules/-/blob/7.x-2.x/modules/data.eva...Comment #9
franckylfs commentedI had the exact same errors and after some testing I made this solution. In fact, normally, the function returns HTML. So a little bit of validation added to each case returns NULL in case of empty values. What do you think of my solution?
Comment #10
damienmckennaComment #11
hughworm commentedI came across more instances of the same error. I've tried a different approach testing every value for null before using. Patch attached.
Comment #12
joelpittetThanks @hughworm I've been seeing these in the logs today too after a recent upgrade to PHP 7.4.
@DamienMcKenna does this really need tests? And if so, would passing an empty array to
theme_date_display_combination()suffice?Comment #13
damienmckennaThis is fine, thank you.
Comment #14
joelpittetBumping, because I ran into it again on a different app. I'll apply the patch now to all our apps.
Comment #15
leendertdb commentedWe also had an issue with these notices appearing after upgrading to PHP 7.4. I was first looking into applying a patch, but thanks to the comment of @derekw I found out we also had quite a few records in field_data_[date field] tables with NULL values. These records with NULL values shouldn't be there and caused these errors. Probably caused by a previous import.
After deleting all the records with NULL values and clearing the cache the problem goes away.
This has nothing to do with the patch, but just dropping it in here for other people: check your "field_data_[date field]" tables in your database to see if there are any records with a "NULL" value. If so, delete them, clear the cache and check if the errors go away. You might not need any patch.
Comment #16
damienmckennaTesting to see if this alternative solution works, as it leads to slightly cleaner code imho.
Comment #18
damienmckennaCommitted. Thanks everyone.
Comment #19
ennorehling commented@damienmckenna : You accidentally wrote 'value1' there, instead of 'value', for $dates['value1']['formatted_timezone'].
Comment #20
solideogloria commentedPlease review this typo fix that applies on dev. Thanks.
Comment #22
damienmckenna.... dangit.
Thanks.