I just migrated servers and noticed that date was coming up empty regardless whether it was entered or not.

I had to make the following changes in date_popup/date_popup.module, to make it work:

    // '#default_value' => (!empty($element['#value']['date']) || !empty($edit['date'])) && is_object($date) ? date_format_date($date, 'custom', $date_format) : '',
    '#default_value' => ($element['#value']['date'] || $edit['date']) && is_object($date) ? date_format_date($date, 'custom', $date_format) : '',
    // '#default_value' => (!empty($element['#value']['time']) || !empty($edit['time'])) && is_object($date) ? date_format_date($date, 'custom', $time_format) : '',
    '#default_value' => ($element['#value']['time'] || $edit['time']) && is_object($date) ? date_format_date($date, 'custom', $time_format) : '',

Any ideas what's going on? It seems that empty() isn't returning true, like it was intended.

My old server's PHP is 5.2.6, new one is 5.4.13.

Thanks,
Andrey.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

victoriachan’s picture

I've been having this issue too. I think the problem is that in date_popup_process_date(), the conditional: !empty($element['#value']['date'] returns TRUE in PHP 5.2, but FALSE in PHP 5.4. When viewing the node edit form, the value of the $element['#value'] var is a string, eg. '2013-06-21 00:00:00', not an array.

A simple fix that should be compatible to both 5.2 and 5.4 would be to check for !empty($element['#value'] instead. Not sure why it was checking for the date part when the value is a string, not array.

Attaching patch.

victoriachan’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: date-empty_after_upgrade_to_php5.4-2115927-1.patch, failed testing.

ejk’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: date-empty_after_upgrade_to_php5.4-2115927-1.patch, failed testing.

mike.davis’s picture

I had the same problem after updating PHP from 5.2 to 5.6.

This patch worked for for me, but only updated the date, so here is an updated patch which applies the fix for the time as well.

Michelle’s picture

Status: Needs work » Needs review

This patch solved the problem for me. Setting it needs review since it never passed the bot but it gets an RTBC on the "solves the problem" front from me. :)

Status: Needs review » Needs work

The last submitted patch, 6: date-empty_after_upgrade_to_php5.4-2115927-6.patch, failed testing.

Michelle’s picture

Ok, I'm a bit confused. When I try to apply the patch to 6.x-2.10 it's saying the patch is already applied. When I go look at the code, sure enough, the code is already changed. But when I look at the annotate to see what issue it was changed in, it's showing totally the wrong issue and the date on the commit is from before _this_ issue was filed. So I'm really not sure what's going on. If someone else can confirm what I'm seeing, this can be marked dupe, though not sure a dupe of _what_.

DamienMcKenna’s picture

Status: Needs work » Closed (won't fix)

Unfortunately the D6 version of this module is no longer supported, but we appreciate the time you put into this. If this problem is relevant for D7 too, please reopen the issue. Thanks.