Allow user timezone adjustments to work when using Postgres - fixed bug 9299
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Mon, 26 Mar 2007 01:05:06 +0000 (01:05 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Mon, 26 Mar 2007 01:05:06 +0000 (01:05 +0000)
RELEASE-NOTES
config/index.php
includes/DefaultSettings.php
languages/Language.php

index e8d9688..dbd5704 100644 (file)
@@ -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
index 2fc91f2..0cf7d48 100644 (file)
@@ -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 "<li style=\"list-style: none\">\n";
                print "<p>Creating LocalSettings.php...</p>\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
index 7b8df3f..5ec2121 100644 (file)
@@ -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';
 /** */
index db24767..5815f61 100644 (file)
@@ -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; }