Replace $wgDBerrorLogInUTC with a $wgDBerrorLogTZ variable which
authorPlatonides <platonides@gmail.com>
Fri, 13 Jul 2012 18:15:41 +0000 (20:15 +0200)
committerReedy <reedy@wikimedia.org>
Wed, 8 Aug 2012 14:51:39 +0000 (15:51 +0100)
can be set to any other timezone.
Also avoids the ugly default-changing that was being used by c15605.

Change-Id: I7a5086f84310f50a1929e07bd2e6527a518424b2

RELEASE-NOTES-1.20
includes/DefaultSettings.php
includes/GlobalFunctions.php

index 1658255..05dd980 100644 (file)
@@ -23,8 +23,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * The user right 'upload_by_url' is no longer given to sysops by default.
   This only affects installations which have $wgAllowCopyUploads set to true.
 * Removed f-prot support from $wgAntivirusSetup.
-* $wgDBerrorLogInUTC to log error in $wgDBerrorLog using an UTC date instead
-  of the wiki timezone set by $wgLocalTimezone.
+* New variable $wgDBerrorLogTZ to provide dates in the error log in a
+  different timezone than the wiki timezone set by $wgLocalTimezone.
 
 === New features in 1.20 ===
 * Added TitleIsAlwaysKnown hook which gets called when determining if a page exists.
index 55126e7..a6244ed 100644 (file)
@@ -1436,11 +1436,26 @@ $wgMasterWaitTimeout = 10;
 
 /** File to log database errors to */
 $wgDBerrorLog = false;
+
 /**
- * Override wiki timezone to UTC for wgDBerrorLog
+ * Timezone to use in the error log.
+ * Defaults to the wiki timezone ($wgLocalTimezone).
+ *
+ * A list of useable timezones can found at:
+ * http://php.net/manual/en/timezones.php
+ *
+ * @par Examples:
+ * @code
+ * $wgLocaltimezone = 'UTC';
+ * $wgLocaltimezone = 'GMT';
+ * $wgLocaltimezone = 'PST8PDT';
+ * $wgLocaltimezone = 'Europe/Sweden';
+ * $wgLocaltimezone = 'CET';
+ * @endcode
+ *
  * @since 1.20
  */
-$wgDBerrorLogInUTC = false;
+$wgDBerrorLogTZ = false;
 
 /** When to give an error message */
 $wgDBClusterTimeout = 10;
@@ -2333,8 +2348,12 @@ $wgForceUIMsgAsContentMsg = array();
  * Timezones can be translated by editing MediaWiki messages of type
  * timezone-nameinlowercase like timezone-utc.
  *
+ * A list of useable timezones can found at:
+ * http://php.net/manual/en/timezones.php
+ *
  * @par Examples:
  * @code
+ * $wgLocaltimezone = 'UTC';
  * $wgLocaltimezone = 'GMT';
  * $wgLocaltimezone = 'PST8PDT';
  * $wgLocaltimezone = 'Europe/Sweden';
index 237697f..308b711 100644 (file)
@@ -968,21 +968,21 @@ function wfDebugLog( $logGroup, $text, $public = true ) {
  * @param $text String: database error message.
  */
 function wfLogDBError( $text ) {
-       global $wgDBerrorLog, $wgDBerrorLogInUTC;
+       global $wgDBerrorLog, $wgDBerrorLogTZ;
+       static $logDBErrorTimeZoneObject = null;
+
        if ( $wgDBerrorLog ) {
                $host = wfHostname();
                $wiki = wfWikiID();
 
-               if( $wgDBerrorLogInUTC ) {
-                       $wikiTimezone = date_default_timezone_get();
-                       date_default_timezone_set( 'UTC' );
-               }
-               $date = date( 'D M j G:i:s T Y' );
-               if( $wgDBerrorLogInUTC ) {
-                       // Restore timezone
-                       date_default_timezone_set( $wikiTimezone );
+               if ( $wgDBerrorLogTZ && !$logDBErrorTimeZoneObject ) {
+                       $logDBErrorTimeZoneObject = new DateTimeZone( $wgDBerrorLogTZ );
                }
 
+               $d = date_create( "now",  $logDBErrorTimeZoneObject );
+
+               $date = $d->format( 'D M j G:i:s T Y' );
+
                $text = "$date\t$host\t$wiki\t$text";
                wfErrorLog( $text, $wgDBerrorLog );
        }