r81132 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81131‎ | r81132 | r81133 >
Date:14:12, 28 January 2011
Author:demon
Status:deferred (Comments)
Tags:
Comment:
Per comment on bug 26612, we should drop the pre-Postgres 8.3 support with the TSearch2 schema.
This removes a bunch of back-compat code in the installer and search code.
Minimum postgres version is now 8.3
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)
  • /trunk/phase3/includes/search/SearchPostgres.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/search/SearchPostgres.php
@@ -141,13 +141,11 @@
142142 function searchQuery( $term, $fulltext, $colname ) {
143143 $postgresVersion = $this->db->getServerVersion();
144144
145 - $prefix = $postgresVersion < 8.3 ? "'default'," : '';
146 -
147145 # Get the SQL fragment for the given term
148146 $searchstring = $this->parseQuery( $term );
149147
150148 ## We need a separate query here so gin does not complain about empty searches
151 - $SQL = "SELECT to_tsquery($prefix $searchstring)";
 149+ $SQL = "SELECT to_tsquery($searchstring)";
152150 $res = $this->db->doQuery($SQL);
153151 if (!$res) {
154152 ## TODO: Better output (example to catch: one 'two)
@@ -168,12 +166,10 @@
169167 }
170168 }
171169
172 - $rankscore = $postgresVersion > 8.2 ? 5 : 1;
173 - $rank = $postgresVersion < 8.3 ? 'rank' : 'ts_rank';
174170 $query = "SELECT page_id, page_namespace, page_title, ".
175 - "$rank($fulltext, to_tsquery($prefix $searchstring), $rankscore) AS score ".
 171+ "ts_rank($fulltext, to_tsquery($searchstring), 5) AS score ".
176172 "FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .
177 - "AND r.rev_text_id = c.old_id AND $fulltext @@ to_tsquery($prefix $searchstring)";
 173+ "AND r.rev_text_id = c.old_id AND $fulltext @@ to_tsquery($searchstring)";
178174 }
179175
180176 ## Redirects
Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -193,13 +193,12 @@
194194 $this->doQuery( "SET client_encoding='UTF8'" );
195195
196196 global $wgDBmwschema, $wgDBts2schema;
197 - if ( isset( $wgDBmwschema ) && isset( $wgDBts2schema )
 197+ if ( isset( $wgDBmwschema )
198198 && $wgDBmwschema !== 'mediawiki'
199199 && preg_match( '/^\w+$/', $wgDBmwschema )
200 - && preg_match( '/^\w+$/', $wgDBts2schema )
201200 ) {
202201 $safeschema = $this->addIdentifierQuotes( $wgDBmwschema );
203 - $this->doQuery( "SET search_path = $safeschema, $wgDBts2schema, public" );
 202+ $this->doQuery( "SET search_path = $safeschema, public" );
204203 }
205204
206205 return $this->mConn;
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -195,7 +195,6 @@
196196 'config-mysql-old' => 'MySQL $1 or later is required, you have $2.',
197197 'config-db-port' => 'Database port:',
198198 'config-db-schema' => 'Schema for MediaWiki',
199 - 'config-db-ts2-schema' => 'Schema for tsearch2',
200199 'config-db-schema-help' => 'The above schemas are usually correct.
201200 Only change them if you know you need to.',
202201 'config-sqlite-dir' => 'SQLite data directory:',
@@ -243,8 +242,6 @@
244243 Check the host, username and password below and try again.',
245244 'config-invalid-schema' => 'Invalid schema for MediaWiki "$1".
246245 Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).',
247 - 'config-invalid-ts2schema' => 'Invalid schema for TSearch2 "$1".
248 -Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).',
249246 'config-postgres-old' => 'PostgreSQL $1 or later is required, you have $2.',
250247 'config-sqlite-name-help' => 'Choose a name that identifies your wiki.
251248 Do not use spaces or hyphens.
@@ -450,9 +447,6 @@
451448 'config-install-pg-commit' => 'Committing changes',
452449 'config-install-pg-plpgsql' => 'Checking for language PL/pgSQL',
453450 'config-pg-no-plpgsql' => 'You need to install the language PL/pgSQL in the database $1',
454 - 'config-install-pg-ts2' => 'Checking for tsearch2',
455 - 'config-install-pg-ts2-failed' => "'''FAILED''' tsearch2 must be installed in the database $1.
456 -Please read [$2 these instructions] or ask on #postgresql on irc.freenode.net",
457451 'config-install-user' => 'Creating database user',
458452 'config-install-user-failed' => 'Granting permission to user "$1" failed: $2',
459453 'config-install-tables' => 'Creating tables',
Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -24,8 +24,7 @@
2525 'wgDBts2schema',
2626 );
2727
28 - var $minimumVersion = '8.1';
29 - private $ts2MaxVersion = '8.3'; // Doing ts2 is not necessary in PG > 8.3
 28+ var $minimumVersion = '8.3';
3029
3130 function getName() {
3231 return 'postgres';
@@ -43,7 +42,6 @@
4443 Html::element( 'legend', array(), wfMsg( 'config-db-wiki-settings' ) ) .
4544 $this->getTextBox( 'wgDBname', 'config-db-name', array(), $this->parent->getHelpBox( 'config-db-name-help' ) ) .
4645 $this->getTextBox( 'wgDBmwschema', 'config-db-schema', array(), $this->parent->getHelpBox( 'config-db-schema-help' ) ) .
47 - $this->getTextBox( 'wgDBts2schema', 'config-db-ts2-schema' ) .
4846 Html::closeElement( 'fieldset' ) .
4947 $this->getInstallUserBox();
5048 }
@@ -51,7 +49,7 @@
5250 function submitConnectForm() {
5351 // Get variables from the request
5452 $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBport',
55 - 'wgDBname', 'wgDBmwschema', 'wgDBts2schema' ) );
 53+ 'wgDBname', 'wgDBmwschema' ) );
5654
5755 // Validate them
5856 $status = Status::newGood();
@@ -63,9 +61,6 @@
6462 if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBmwschema'] ) ) {
6563 $status->fatal( 'config-invalid-schema', $newValues['wgDBmwschema'] );
6664 }
67 - if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBts2schema'] ) ) {
68 - $status->fatal( 'config-invalid-ts2schema', $newValues['wgDBts2schema'] );
69 - }
7065
7166 // Submit user box
7267 if ( $status->isOK() ) {
@@ -196,17 +191,12 @@
197192 'name' => 'user',
198193 'callback' => array( $this, 'setupUser' ),
199194 );
200 - $ts2CB = array(
201 - 'name' => 'pg-ts2',
202 - 'callback' => array( $this, 'setupTs2' ),
203 - );
204195 $plpgCB = array(
205196 'name' => 'pg-plpgsql',
206197 'callback' => array( $this, 'setupPLpgSQL' ),
207198 );
208199 $this->parent->addInstallStep( $commitCB, 'interwiki' );
209200 $this->parent->addInstallStep( $userCB );
210 - $this->parent->addInstallStep( $ts2CB, 'database' );
211201 $this->parent->addInstallStep( $plpgCB, 'database' );
212202 }
213203
@@ -266,36 +256,6 @@
267257 return $status;
268258 }
269259
270 - /**
271 - * Ts2 isn't needed in newer versions of Postgres, so wrap it in a nice big
272 - * version check and skip it if we're new. Maybe we can bump $minimumVersion
273 - * one day and render this obsolete :)
274 - *
275 - * @return Status
276 - */
277 - function setupTs2() {
278 - $status = $this->getConnection();
279 - if ( !$status->isOK() ) {
280 - return $status;
281 - }
282 -
283 - if( version_compare( $this->db->getServerVersion(), $this->ts2MaxVersion, '<' ) ) {
284 - if ( !$this->db->tableExists( 'pg_ts_cfg', $this->getVar( 'wgDBts2schema' ) ) ) {
285 - return Status::newFatal(
286 - 'config-install-pg-ts2-failed',
287 - $this->getVar( 'wgDBname' ),
288 - 'http://www.devx.com/opensource/Article/21674/0/page/2'
289 - );
290 - }
291 - $safeuser = $this->db->addQuotes( $this->getVar( 'wgDBuser' ) );
292 - foreach ( array( 'cfg', 'cfgmap', 'dict', 'parser' ) as $table ) {
293 - $sql = "GRANT SELECT ON pg_ts_$table TO $safeuser";
294 - $this->db->query( $sql, __METHOD__ );
295 - }
296 - }
297 - return Status::newGood();
298 - }
299 -
300260 function commitChanges() {
301261 $this->db->query( 'COMMIT' );
302262 return Status::newGood();
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1180,8 +1180,6 @@
11811181
11821182 /** Mediawiki schema */
11831183 $wgDBmwschema = 'mediawiki';
1184 -/** Tsearch2 schema */
1185 -$wgDBts2schema = 'public';
11861184
11871185 /** To override default SQLite data directory ($docroot/../data) */
11881186 $wgSQLiteDataDir = '';

Follow-up revisions

RevisionCommit summaryAuthorDate
r81134Followup r81132, missed some more ts2 removaldemon15:25, 28 January 2011
r81139Follow-up r81132 removal of pre-8.3 support....platonides17:25, 28 January 2011
r81913Remove unused initial_setup(), last $wgDBts2schema user. Follow up to r81132platonides19:12, 10 February 2011
r81924$wgDBts2schema was removed in r81132platonides23:57, 10 February 2011
r82668Per bug 26612, set datestyle and timezone in open() rather than relying on $w...demon13:51, 23 February 2011
r82674Various Postgres fixes (bug 26612 stuff)...demon16:01, 23 February 2011

Comments

#Comment by Platonides (talk | contribs)   16:50, 28 January 2011

Needs release notes.

#Comment by 😂 (talk | contribs)   17:00, 28 January 2011

Yes, this will need to go into the REL1_17 release notes. I plan to merge it.

Status & tagging log