From: Platonides Date: Sun, 25 Jul 2010 22:09:34 +0000 (+0000) Subject: Kill $wgDBversion X-Git-Tag: 1.31.0-rc.0~35918 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=36d86e7ae9b9555a7ab3427499ec21f7ab20df27;p=lhc%2Fweb%2Fwiklou.git Kill $wgDBversion --- diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 960b74adc7..62391e94d8 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -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; } diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index a38efa0f9e..db58a6f195 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -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 " .