Find out the local db timezone
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Mon, 26 Mar 2007 01:13:39 +0000 (01:13 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Mon, 26 Mar 2007 01:13:39 +0000 (01:13 +0000)
includes/DatabasePostgres.php

index bed25d8..9e7d8c6 100644 (file)
@@ -154,7 +154,7 @@ class DatabasePostgres extends Database {
                ## If this is the initial connection, setup the schema stuff and possibly create the user
                if (defined('MEDIAWIKI_INSTALL')) {
                        global $wgDBname, $wgDBuser, $wgDBpassword, $wgDBsuperuser, $wgDBmwschema,
-                               $wgDBts2schema;
+                               $wgDBts2schema, $wgDBtimezone;
 
                        print "<li>Checking the version of Postgres...";
                        $version = $this->getServerVersion();
@@ -165,6 +165,20 @@ class DatabasePostgres extends Database {
                        }
                        print "version $this->numeric_version is OK.</li>\n";
 
+                       print "<li>Figuring out timezone the database is using...";
+                       ## Figure out what the local timezone is for this database
+                       $wgDBtimezone = 99;
+                       if ($this->doQuery("SET datestyle TO ISO")) {
+                               $res = $this->doQuery("SELECT substring(now() FROM E'-?\\\d\\\d\$')::int");
+                               if ($res) {
+                                       $wgDBtimezone = pg_fetch_result($res,0,0);
+                                       print "timezone is '$wgDBtimezone'</li>\n";
+                               }
+                       }
+                       if ($wgDBtimezone === 99) {
+                               print "<b>UNKNOWN</b>. Defaulting to '0'</li>\n";
+                       }
+
                        $safeuser = $this->quote_ident($wgDBuser);
                        ## Are we connecting as a superuser for the first time?
                        if ($wgDBsuperuser) {