I have a record that looks like this:
22 2007-11-04 10:15:00 2008-10-05 10:15:00 320 0 0 1 0
It has has_end_date=0, but event_end happens to be different from event_start, and the End Date is displayed. Apparently, whether to display the End Date or not is still determined by the old pre-has_end_date algorithm.
How to create an inconsistent record like this? I mistakenly entered 2008-10-05 10:15:00 as the start date (and no end date). Then I went back and edited the event, setting the start date backwards. This left the end date where it was, creating an inconsistent state.
In my experience, storing redundant (and potentially conflicting) data will always hurt you sooner or later. IOW, if has_end_date is 0, then event_end should be NULL. Even better would be not to have a has_end_date column at all, but to rely on event_end being NULL or non-NULL. This would uncover subtle bugs like this one much sooner.
If efficiency requires a non-NULL event_end in some queries, you can always use IFNULL(event_end, event_start).
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | has_end_date.patch | 1.01 KB | Jahriusz |
Comments
Comment #1
Jahriusz commentedAdd additional expression that checks if has_end_date is set to 0.
Patch for Version
// $Id: event.theme,v 1.58 2007/09/04 09:58:20 killes Exp $
Comment #2
salvisThe patch only hides the end date, but it doesn't keep the database from becoming inconsistent, and the event shows up every day between 2007-11-04 and 2008-10-05.
The only way to really fix this is to remove the has_end_date column. Killes needs to decide...
I have to admit that I was among those who pushed for the addition of the has_end_date column — it was a mistake. event_end should be allowed to be NULL instead. Since I have to take some of the blame, I'll try to come up with a patch to remove the has_end_date column, but Killes needs to give the green light first.
Comment #3
japerryEvent for Drupal 8 is unrelated to older versions. If an issue similar to this one exists, please open a new issue with the 8.x branch.