Drupal 7 beta 2, dev snapshots of CCK, Views, Date, Calendar, Context. PHP 5.2.10 on MAMP.
Without adding any content, I added the Calendar and Upcoming blocks to the sidebar, then the following errors started showing:
Warning: date_create() expects parameter 2 to be DateTimeZone, string given in date_api_filter_handler->default_value() (line 347 of /sites/all/modules/contrib/date/includes/date_api_filter_handler.inc).
Warning: date_format() expects parameter 1 to be DateTime, boolean given in date_api_filter_handler->default_value() (line 349 of /sites/all/modules/contrib/date/includes/date_api_filter_handler.inc).
Reading through the code, the first error leads to the second one:
// For PHP 5.2+, take advantage of any strings that native PHP
// date_create() can handle. For older versions use strtotime().
if (version_compare(PHP_VERSION, '5.2', '<')) {
$now = strtotime($default_option . ' UTC');
$date = date_create("@$now", timezone_open('UTC'));
}
else {
$date = date_create($default_option, date_default_timezone());
}
$default_date = date_format($date, DATE_FORMAT_DATETIME);
First off, if PHP 5.2 is now the base requirement then the IF statement could be reduced to:
$date = date_create($default_option, date_default_timezone());
The date_create() function requires the second argument to be a DateTimeZone object, but date_default_timezone() returns a string. The suggested fix is to use date_default_timezone_object() instead.
Comments
Comment #1
damienmckennaCorrected the method name that has the actual bug.
Comment #2
damienmckennaA patch that applies the suggested changes above.
Comment #3
karens commentedFixed. Thanks!