Download & Extend

Date showing on node view - not showing on node edit - PHP 5.4 issue

Project:Date
Version:6.x-2.x-dev
Component:Date Popup
Category:bug report
Priority:normal
Assigned:MEGAWATT
Status:needs review

Issue Summary

Hi there,

Here is my issue: I can create a node containing a date (popup widget) and save it, the date will appear on the node view. If I want to get back to the editing, the date is empty.

Everything was working fine under PHP 5.3, now that my server is running PHP 5.4 I have the same issue for several websites. Running the same website on a PHP 5.3 localhost will make everything work again...

Not sure if related, seems to be the same issue for other modules:
http://drupal.org/node/1159880
http://drupal.org/node/1453570

Any ideas???

Thanks

Comments

#1

This is my exact same issue.

In my logs I get "Illegal string offset 'month' in /.../includes/form.inc on line 1345"

Same error applies for second, hour, day, year...

#2

Anyone else with same the issue? Any ideas how to fix it?
Thanks

#3

use this to fix 1345 http://drupalcontrib.org/api/drupal/contributions%21date%21date_popup%21...
but it do not fix echo date time and time

#4

Assigned to:Anonymous» MEGAWATT

how to looks date and time in page node edit , drupal 6, php 5.4.6
do this:
1st of all fix you code similarity http://drupalcontrib.org/api/drupal/contributions%21date%21date_popup%21...

all changes in date/date_popup/date_popup.module

1. in function date_popup_process_date change

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

change to
<?php
date_format_date
($date, 'custom', $date_format) ,
?>

next step
<?php
<code>if (!empty($element[&#039;#force_value&#039;])) {$sub_element[&#039;#value&#039;] = $sub_element[&#039;#default_value&#039;]; }</code>
?>

change to
<?php
$sub_element
['#value'] = $sub_element['#default_value'];
?>

2. in function date_popup_process_time change

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

?>

change to
<?php
date_format_date
($date, 'custom', $time_format) ,
?>

and
<?php
if (!empty($element['#force_value'])) {$sub_element['#value'] = $sub_element['#default_value']; }
?>

change to
<?php
$sub_element
['#value'] = $sub_element['#default_value'];.
?>

#5

Thanks so much, it's working perfectly now!

#6

This fix didn't work for me. When I use date and time too after a content type import the dates and times are empty.

#7

Subscribing [#4] fixes the problem for me, actually just taking out the conditional

(!empty($element['#value']['time']) || !empty($edit['time'])) && is_object($date) ?

works like a charm :)

Interesting thing,
$element['#value'] = "2013-01-01";

In PHP 5.3:
empty($element['#value']['date']) ? => true

PHP 5.4:
empty($element['#value']['date']) ? => false

Thanks!

#8

All you need to do is remove the ['time'] from $element['#value']['time'] in date_popup_process_date and date_popup_process_time

Works for me in php 5.4.10 and 5.2.17.

Patch included -- built against 6.x-2.9+6-dev

AttachmentSizeStatusTest resultOperations
date_popup.module.patch1.18 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch date_popup.module.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#9

After upgrading to PHP 5.4.10 from PHP 5.2.x, I had the issue when editing the date fields that used the date popup were empty. Patched 2 sites Drupal 6 sites running on PHP 5.4.10 and date fields are populated again.

Others please review and test.

Thank you fellow Drupalers!

#10

#8 works perfect.

#11

#8 works perfect for me too!

#12

#8 works fo me, please send it to the dev version

#13

Status:active» reviewed & tested by the community

#8 working here

#14

Status:reviewed & tested by the community» needs work

The last submitted patch, date_popup.module.patch, failed testing.

#15

Status:needs work» needs review

#8: date_popup.module.patch queued for re-testing.

#16

Status:needs review» needs work

The last submitted patch, date_popup.module.patch, failed testing.

#17

#8 Worked for me, thanks.

#18

Patch worked for me.

I had to use the patch command without the -p1 to get it to work for me.

I've seen patches sit in "needs work" because of a failed test more than once.

It'd guess the test failed because the test uses the -p1 option

git apply --check -p1 /var/lib/drupaltestbot/sites/default/files/review/date_popup.module.patch

#19

Version:6.x-2.9» 6.x-2.x-dev
Status:needs work» needs review

Rerolled #8

Adding in text for search purposes

Warning: Illegal string offset 'year' in _form_set_value() (line 1345 of includes/form.inc).
Warning: Illegal string offset 'month' in _form_set_value() (line 1345 of includes/form.inc).
Warning: Illegal string offset 'day' in _form_set_value() (line 1345 of includes/form.inc).
Warning: Illegal string offset 'hour' in _form_set_value() (line 1345 of includes/form.inc).
Warning: Illegal string offset 'minute' in _form_set_value() (line 1345 of includes/form.inc).
Warning: Illegal string offset 'second' in _form_set_value() (line 1345 of includes/form.inc).

AttachmentSizeStatusTest resultOperations
date_popup-1808416-19-php5.4.patch1.37 KBTest request sentNoneView details

#20

#19 applied cleanly to 6.x-2.9 for me and allowed the date values to render on node edit screens.

+1 RTBC

#21

densolis assisted me to find out that the test is not running due to the 6.x-2.x branch not passing testing. In order to move forward either the patch need to be manually reviewed or a maintainer needs to fix up the branch so the patch can be automatically tested.