Jump to:
| Project: | Date |
| Version: | 6.x-2.x-dev |
| Component: | Date CCK Field |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (works as designed) |
Issue Summary
In the file date/date_elements.inc, in function _date_field_update() empty values for $delta > 0 are reset, but not the first value. I haven't dived deep enought in this to figure out why, but it seems weird. This causes datestamp fields set to the empty string value '' to be stored in database as '0000-00-00 00:00:00', and further, when displayed, it shows the current date.
This causes trouble in the exif module. It uses hook_nodeapi() to set the date field values, and sometimes these are empty strings. A fix there is of course to set the date field to NULL if it's empty, but I think, if you don't have a good reason for this, the right place to fix this is in date module.
If not, please explain why and i'll submit a patch for the exif module.
One-liner attached.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| date-empty-value-delta-0.patch | 673 bytes | Ignored: Check issue status. | None | None |
Comments
#1
I ment datetime values are saved as '0000-00-00 00:00:00', not datestamp :-)
#2
The reason the zero delta is preserved is because this is the standard way CCK fields are handled. There should be an array with a 'value' that is NULL, not an empty array. Your patch would completely wipe the value out. This in turn would break other places in CCK that expect that first element to have a 'value' index, like in token handling.
This bit of code actually should be removed completely because this is handled by CCK now (this was put in place before CCK started doing that). But it is essentially doing the same thing that CCK is already doing with other fields.
If some other module is adding a value that should be empty, it should be setting the 'value' to NULL. I don't want the Date module to make assumptions that '0000-00-00 00:00:00' is not a desired value, because in some cases it may be.