From 72cb54091145c7a77a7d55aba7bface962e4c9ef Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Mon, 26 Mar 2007 01:13:39 +0000 Subject: [PATCH] Find out the local db timezone --- includes/DatabasePostgres.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index bed25d8547..9e7d8c63b5 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -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 "
  • Checking the version of Postgres..."; $version = $this->getServerVersion(); @@ -165,6 +165,20 @@ class DatabasePostgres extends Database { } print "version $this->numeric_version is OK.
  • \n"; + print "
  • 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'
  • \n"; + } + } + if ($wgDBtimezone === 99) { + print "UNKNOWN. Defaulting to '0'\n"; + } + $safeuser = $this->quote_ident($wgDBuser); ## Are we connecting as a superuser for the first time? if ($wgDBsuperuser) { -- 2.20.1