From 24619e4c665751ebac59ea959bd99e92bb10018c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 8 Sep 2004 20:36:41 +0000 Subject: [PATCH] Add Database::getSoftwareLink() and Database::getServerVersion(), and use those in Special:Version. Fixes bug 388: Special:Version shows MySQL version when using PostgreSQL http://bugzilla.wikipedia.org/show_bug.cgi?id=388 --- includes/Database.php | 14 ++++++++++++ includes/DatabasePostgreSQL.php | 38 ++++++++++++++++++++++++--------- includes/SpecialVersion.php | 7 ++++-- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index 21256c0fd4..c2d87301cc 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1196,6 +1196,20 @@ class Database { return new ResultWrapper( $this, $result ); } } + + /** + * @return string wikitext of a link to the server software's web site + */ + function getSoftwareLink() { + return "[http://www.mysql.com/ MySQL]"; + } + + /** + * @return string Version information from the database + */ + function getServerVersion() { + return mysql_get_server_info(); + } } /** diff --git a/includes/DatabasePostgreSQL.php b/includes/DatabasePostgreSQL.php index b3e74ec2f6..db4c7d8454 100644 --- a/includes/DatabasePostgreSQL.php +++ b/includes/DatabasePostgreSQL.php @@ -357,18 +357,36 @@ class DatabasePgsql extends Database { return false; } - # Return DB-style timestamp used for MySQL schema - function timestamp( $ts=0 ) { - return wfTimestamp(TS_DB,$ts); - } - - function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) { - $message = "A database error has occurred\n" . - "Query: $sql\n" . - "Function: $fname\n" . - "Error: $errno $error\n"; + # Return DB-style timestamp used for MySQL schema + function timestamp( $ts=0 ) { + return wfTimestamp(TS_DB,$ts); + } + + function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) { + $message = "A database error has occurred\n" . + "Query: $sql\n" . + "Function: $fname\n" . + "Error: $errno $error\n"; wfDebugDieBacktrace($message); } + + /** + * @return string wikitext of a link to the server software's web site + */ + function getSoftwareLink() { + return "[http://www.postgresql.org/ PostgreSQL]"; + } + + /** + * @return string Version information from the database + */ + function getServerVersion() { + $res = $this->query( "SELECT version()" ); + $row = $this->fetchRow( $res ); + $version = $row[0]; + $this->freeResult( $res ); + return $version; + } } /** diff --git a/includes/SpecialVersion.php b/includes/SpecialVersion.php index 47fe88647f..30f2fe1aa5 100644 --- a/includes/SpecialVersion.php +++ b/includes/SpecialVersion.php @@ -42,9 +42,12 @@ function wfSpecialVersion() { } $versions = array( "[http://wikipedia.sf.net/ MediaWiki]" => $wgVersion, - "[http://www.php.net/ PHP]" => phpversion() . " (" . php_sapi_name() . ")", - "[http://www.mysql.com/ MySQL]" => mysql_get_server_info() + "[http://www.php.net/ PHP]" => phpversion() . " (" . php_sapi_name() . ")" ); + + $dbr =& wfGetDB( DB_SLAVE ); + $dblink = $dbr->getSoftwareLink(); + $versions[$dblink] = $dbr->getServerVersion(); $out = ''; foreach( $versions as $module => $ver ) { -- 2.20.1