From: Greg Sabino Mullane Date: Mon, 26 Mar 2007 01:05:06 +0000 (+0000) Subject: Allow user timezone adjustments to work when using Postgres - fixed bug 9299 X-Git-Tag: 1.31.0-rc.0~53608 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=0aef616c15f63f2a16ea8b86b303a7b9e233e681;p=lhc%2Fweb%2Fwiklou.git Allow user timezone adjustments to work when using Postgres - fixed bug 9299 --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e8d96881b0..dbd570438d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -29,6 +29,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN $wgAutoConfirmCount (defaulting to zero, naturally). * Added rate limiter for Special:Emailuser * Private logs can now be created using $wgLogRestrictions +* Databases using timestamps with time zone (Postgres) can now set $wgDBtimezone == New features since 1.9 == * (bug 6937) Introduce "statistics-footer" message, appended to @@ -281,6 +282,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN based on Jeff Merkey's mediawiki-1.9.3.WG-20070316.tar.gz.bz2 archive. * Introduce PageHistoryBeforeList and PageHistoryLineEnding hooks; see docs/hooks.txt for more information +* (bug 9299) Allow user timezones to work with Postgres == Maintenance == * New script maintenance/language/checkExtensioni18n.php used to check i18n diff --git a/config/index.php b/config/index.php index 2fc91f2f3b..0cf7d48d9f 100644 --- a/config/index.php +++ b/config/index.php @@ -902,6 +902,11 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $article->updateRevisionOn( $wgDatabase, $revision ); } + # If the database has a specific timezone, and its not the default(0), change LocalSettings.php + if ($wgDBtimezone != 0) { + $local = preg_replace('/(wgDBtimezone\s+= )0/', "$1$wgDBtimezone", $local); + } + /* Write out the config file now that all is well */ print "
  • \n"; print "

    Creating LocalSettings.php...

    \n\n"; @@ -1407,6 +1412,7 @@ if ( \$wgCommandLineMode ) { \$wgDBuser = \"{$slconf['DBuser']}\"; \$wgDBpassword = \"{$slconf['DBpassword']}\"; \$wgDBport = \"{$slconf['DBport']}\"; +\$wgDBtimezone = 0; \$wgDBprefix = \"{$slconf['DBprefix']}\"; # Schemas for Postgres diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 7b8df3f001..5ec2121d2d 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -485,6 +485,8 @@ $wgSMTP = false; $wgDBserver = 'localhost'; /** database port number */ $wgDBport = ''; +/** timezone the database is using */ +$wgDBtimezone = 0; /** name of the database */ $wgDBname = 'wikidb'; /** */ diff --git a/languages/Language.php b/languages/Language.php index db2476728d..5815f61979 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -391,7 +391,7 @@ class Language { * @return int */ function userAdjust( $ts, $tz = false ) { - global $wgUser, $wgLocalTZoffset; + global $wgUser, $wgLocalTZoffset, $wgDBtimezone; if (!$tz) { $tz = $wgUser->getOption( 'timecorrection' ); @@ -415,6 +415,11 @@ class Language { $hrDiff = intval( $tz ); } + # Account for databases that use timestamp with time zone + if ( isset($wgDBtimezone) ) { + $hrDiff -= $wgDBtimezone; + } + # No difference ? Return time unchanged if ( 0 == $hrDiff && 0 == $minDiff ) { return $ts; }