r85177 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85176‎ | r85177 | r85178 >
Date:04:49, 2 April 2011
Author:mah
Status:reverted (Comments)
Tags:
Comment:
Fix Bug#24308 where, on some platforms the date_create() function fails when the timezone isn't specified.
Modified paths:
  • /trunk/phase3/includes/Preferences.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Preferences.php
@@ -1202,7 +1202,8 @@
12031203 $prefill = array_fill_keys( array_values( $tzRegions ), array() );
12041204 $opt = array_merge( $opt, $prefill );
12051205
1206 - $now = date_create( 'now' );
 1206+ global $wgLocaltimezone;
 1207+ $now = date_create( 'now', $wgLocaltimezone );
12071208
12081209 foreach ( $tzs as $tz ) {
12091210 $z = explode( '/', $tz, 2 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r85358revert r85177 since a lot of people don't set their $wgLocaltimezonemah18:47, 4 April 2011

Comments

#Comment by MaxSem (talk | contribs)   11:51, 3 April 2011

Causes

Warning: date_create() expects parameter 2 to be DateTimeZone, null given in C:\Projects\MediaWiki\includes\Preferences.php on line 1206

and a load of

Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in C:\Projects\MediaWiki\includes\Preferences.php on line 1221

#Comment by 😂 (talk | contribs)   20:04, 3 April 2011

$wgLocaltimezone is null by default, most wikis don't bother setting this so wiki defaults remain in UTC.

If this is an issue with date_create(), we should push the bug back upstream.

(On a similar note, Tim cleaned up a lot of timezone stuff back in r60825)

#Comment by Brion VIBBER (talk | contribs)   21:26, 4 April 2011

Passing a string doesn't work either -- the timezone parameter needs to be a DateTimeZone object.

Status & tagging log