r69921 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69920‎ | r69921 | r69922 >
Date:22:09, 25 July 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Kill $wgDBversion
Modified paths:
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/search/SearchPostgres.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/search/SearchPostgres.php
@@ -134,13 +134,9 @@
135135 * @param $colname
136136 */
137137 function searchQuery( $term, $fulltext, $colname ) {
138 - global $wgDBversion;
 138+ $postgresVersion = $this->db->getServerVersion();
139139
140 - if ( !isset( $wgDBversion ) ) {
141 - $this->db->getServerVersion();
142 - $wgDBversion = $this->db->numeric_version;
143 - }
144 - $prefix = $wgDBversion < 8.3 ? "'default'," : '';
 140+ $prefix = $postgresVersion < 8.3 ? "'default'," : '';
145141
146142 # Get the SQL fragment for the given term
147143 $searchstring = $this->parseQuery( $term );
@@ -167,8 +163,8 @@
168164 }
169165 }
170166
171 - $rankscore = $wgDBversion > 8.2 ? 5 : 1;
172 - $rank = $wgDBversion < 8.3 ? 'rank' : 'ts_rank';
 167+ $rankscore = $postgresVersion > 8.2 ? 5 : 1;
 168+ $rank = $postgresVersion < 8.3 ? 'rank' : 'ts_rank';
173169 $query = "SELECT page_id, page_namespace, page_title, ".
174170 "$rank($fulltext, to_tsquery($prefix $searchstring), $rankscore) AS score ".
175171 "FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .
Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -777,15 +777,13 @@
778778 * @return bool Success of insert operation. IGNORE always returns true.
779779 */
780780 function insert( $table, $args, $fname = 'DatabasePostgres::insert', $options = array() ) {
781 - global $wgDBversion;
782 -
783781 if ( !count( $args ) ) {
784782 return true;
785783 }
786784
787785 $table = $this->tableName( $table );
788 - if (! isset( $wgDBversion ) ) {
789 - $wgDBversion = $this->getServerVersion();
 786+ if (! isset( $this->numeric_version ) ) {
 787+ $this->getServerVersion();
790788 }
791789
792790 if ( !is_array( $options ) )
@@ -819,7 +817,7 @@
820818 $sql = "INSERT INTO $table (" . implode( ',', $keys ) . ') VALUES ';
821819
822820 if ( $multi ) {
823 - if ( $wgDBversion >= 8.2 && !$ignore ) {
 821+ if ( $this->numeric_version >= 8.2 && !$ignore ) {
824822 $first = true;
825823 foreach ( $args as $row ) {
826824 if ( $first ) {
@@ -1156,16 +1154,18 @@
11571155 * @return string Version information from the database
11581156 */
11591157 function getServerVersion() {
1160 - $versionInfo = pg_version( $this->mConn );
1161 - if ( version_compare( $versionInfo['client'], '7.4.0', 'lt' ) ) {
1162 - // Old client, abort install
1163 - $this->numeric_version = '7.3 or earlier';
1164 - } elseif ( isset( $versionInfo['server'] ) ) {
1165 - // Normal client
1166 - $this->numeric_version = $versionInfo['server'];
1167 - } else {
1168 - // Bug 16937: broken pgsql extension from PHP<5.3
1169 - $this->numeric_version = pg_parameter_status( $this->mConn, 'server_version' );
 1158+ if ( ! isset( this->numeric_version ) ) {
 1159+ $versionInfo = pg_version( $this->mConn );
 1160+ if ( version_compare( $versionInfo['client'], '7.4.0', 'lt' ) ) {
 1161+ // Old client, abort install
 1162+ $this->numeric_version = '7.3 or earlier';
 1163+ } elseif ( isset( $versionInfo['server'] ) ) {
 1164+ // Normal client
 1165+ $this->numeric_version = $versionInfo['server'];
 1166+ } else {
 1167+ // Bug 16937: broken pgsql extension from PHP<5.3
 1168+ $this->numeric_version = pg_parameter_status( $this->mConn, 'server_version' );
 1169+ }
11701170 }
11711171 return $this->numeric_version;
11721172 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r69930Followup r69921...reedy06:57, 26 July 2010

Comments

#Comment by OverlordQ (talk | contribs)   06:56, 26 July 2010

PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting T_PAAMAYIM_NEKUDOTAYIM in includes/db/DatabasePostgres.php on line 1157

Status & tagging log