Bug 39516 - Call to a member function format() on a non-object
authorReedy <reedy@wikimedia.org>
Mon, 20 Aug 2012 22:41:18 +0000 (23:41 +0100)
committerReedy <reedy@wikimedia.org>
Mon, 20 Aug 2012 22:41:18 +0000 (23:41 +0100)
Workaround for php bug [1], reported in 5.3.2, fixed already

Workaround can be removed when our minimum PHP version is > 5.3.2

[1] https://bugs.php.net/bug.php?id=52063

Change-Id: Ia60e64300787d0b683829765e8eeac1535e9d0a4

includes/GlobalFunctions.php

index c592c7c..391d11d 100644 (file)
@@ -979,7 +979,13 @@ function wfLogDBError( $text ) {
                        $logDBErrorTimeZoneObject = new DateTimeZone( $wgDBerrorLogTZ );
                }
 
-               $d = date_create( "now",  $logDBErrorTimeZoneObject );
+               // Workaround for https://bugs.php.net/bug.php?id=52063
+               // Can be removed when min PHP > 5.3.2
+               if ( $logDBErrorTimeZoneObject === null ) {
+                       $d = date_create( "now" );
+               } else {
+                       $d = date_create( "now", $logDBErrorTimeZoneObject );
+               }
 
                $date = $d->format( 'D M j G:i:s T Y' );