From: Platonides Date: Fri, 13 Jul 2012 18:15:41 +0000 (+0200) Subject: Replace $wgDBerrorLogInUTC with a $wgDBerrorLogTZ variable which X-Git-Tag: 1.31.0-rc.0~22802 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=ef498e793e53b30560ec717601b51b7cdec2bdae;p=lhc%2Fweb%2Fwiklou.git Replace $wgDBerrorLogInUTC with a $wgDBerrorLogTZ variable which can be set to any other timezone. Also avoids the ugly default-changing that was being used by c15605. Change-Id: I7a5086f84310f50a1929e07bd2e6527a518424b2 --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 16582554ea..05dd980304 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -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. diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 55126e7695..a6244ed94e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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'; diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 237697f413..308b7116dd 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 ); }