Kill $wgDBversion
authorPlatonides <platonides@users.mediawiki.org>
Sun, 25 Jul 2010 22:09:34 +0000 (22:09 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Sun, 25 Jul 2010 22:09:34 +0000 (22:09 +0000)
includes/db/DatabasePostgres.php
includes/search/SearchPostgres.php

index 960b74a..62391e9 100644 (file)
@@ -777,15 +777,13 @@ class DatabasePostgres extends DatabaseBase {
         * @return bool Success of insert operation. IGNORE always returns true.
         */
        function insert( $table, $args, $fname = 'DatabasePostgres::insert', $options = array() ) {
-               global $wgDBversion;
-
                if ( !count( $args ) ) {
                        return true;
                }
 
                $table = $this->tableName( $table );
-               if (! isset( $wgDBversion ) ) {
-                       $wgDBversion = $this->getServerVersion();
+               if (! isset( $this->numeric_version ) ) {
+                       $this->getServerVersion();
                }
 
                if ( !is_array( $options ) )
@@ -819,7 +817,7 @@ class DatabasePostgres extends DatabaseBase {
                $sql = "INSERT INTO $table (" . implode( ',', $keys ) . ') VALUES ';
 
                if ( $multi ) {
-                       if ( $wgDBversion >= 8.2 && !$ignore ) {
+                       if ( $this->numeric_version >= 8.2 && !$ignore ) {
                                $first = true;
                                foreach ( $args as $row ) {
                                        if ( $first ) {
@@ -1156,16 +1154,18 @@ class DatabasePostgres extends DatabaseBase {
         * @return string Version information from the database
         */
        function getServerVersion() {
-               $versionInfo = pg_version( $this->mConn );
-               if ( version_compare( $versionInfo['client'], '7.4.0', 'lt' ) ) {
-                       // Old client, abort install
-                       $this->numeric_version = '7.3 or earlier';
-               } elseif ( isset( $versionInfo['server'] ) ) {
-                       // Normal client
-                       $this->numeric_version = $versionInfo['server'];
-               } else {
-                       // Bug 16937: broken pgsql extension from PHP<5.3
-                       $this->numeric_version = pg_parameter_status( $this->mConn, 'server_version' );
+               if ( ! isset( this->numeric_version ) ) {
+                       $versionInfo = pg_version( $this->mConn );
+                       if ( version_compare( $versionInfo['client'], '7.4.0', 'lt' ) ) {
+                               // Old client, abort install
+                               $this->numeric_version = '7.3 or earlier';
+                       } elseif ( isset( $versionInfo['server'] ) ) {
+                               // Normal client
+                               $this->numeric_version = $versionInfo['server'];
+                       } else {
+                               // Bug 16937: broken pgsql extension from PHP<5.3
+                               $this->numeric_version = pg_parameter_status( $this->mConn, 'server_version' );
+                       }
                }
                return $this->numeric_version;
        }
index a38efa0..db58a6f 100644 (file)
@@ -134,13 +134,9 @@ class SearchPostgres extends SearchEngine {
         * @param $colname
         */
        function searchQuery( $term, $fulltext, $colname ) {
-               global $wgDBversion;
+               $postgresVersion = $this->db->getServerVersion();
 
-               if ( !isset( $wgDBversion ) ) {
-                       $this->db->getServerVersion();
-                       $wgDBversion = $this->db->numeric_version;
-               }
-               $prefix = $wgDBversion < 8.3 ? "'default'," : '';
+               $prefix = $postgresVersion < 8.3 ? "'default'," : '';
 
                # Get the SQL fragment for the given term
                $searchstring = $this->parseQuery( $term );
@@ -167,8 +163,8 @@ class SearchPostgres extends SearchEngine {
                                }
                        }
 
-                       $rankscore = $wgDBversion > 8.2 ? 5 : 1;
-                       $rank = $wgDBversion < 8.3 ? 'rank' : 'ts_rank';
+                       $rankscore = $postgresVersion > 8.2 ? 5 : 1;
+                       $rank = $postgresVersion < 8.3 ? 'rank' : 'ts_rank';
                        $query = "SELECT page_id, page_namespace, page_title, ".
                        "$rank($fulltext, to_tsquery($prefix $searchstring), $rankscore) AS score ".
                        "FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .