From: Antoine Musso Date: Fri, 13 Jul 2012 14:53:06 +0000 (+0200) Subject: dbErrorLog can now be forced to UTC X-Git-Tag: 1.31.0-rc.0~23058 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=bc6d5fb88a55af033d759e7f6165d7ceaf4cd77e;p=lhc%2Fweb%2Fwiklou.git dbErrorLog can now be forced to UTC $wgDBerrorLog is used to log database error. It is using $wgLocalTimezone to format the date which might not always be wanted in a multi Timezone cluster of wiki. wgDBerrorLogInUTC , when true, will override the Wiki timezone to uses UTC whenever a database error is logged. Change-Id: I091d6029272b69db0aefdebfc37896d0a8e8770e --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index e56cf60953..a9bdeb7d3b 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -23,6 +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 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 eed7d58e1b..c1c73d2b50 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1381,6 +1381,11 @@ $wgMasterWaitTimeout = 10; /** File to log database errors to */ $wgDBerrorLog = false; +/** + * Override wiki timezone to UTC for wgDBerrorLog + * @since 1.20 + */ +$wgDBerrorLogInUTC = false; /** When to give an error message */ $wgDBClusterTimeout = 10; diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 1a21e205bb..432622912d 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1053,11 +1053,22 @@ function wfDebugLog( $logGroup, $text, $public = true ) { * @param $text String: database error message. */ function wfLogDBError( $text ) { - global $wgDBerrorLog; + global $wgDBerrorLog, $wgDBerrorLogInUtc; if ( $wgDBerrorLog ) { $host = wfHostname(); $wiki = wfWikiID(); - $text = date( 'D M j G:i:s T Y' ) . "\t$host\t$wiki\t$text"; + + 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 ); + } + + $text = "$date\t$host\t$wiki\t$text"; wfErrorLog( $text, $wgDBerrorLog ); } }