r81139 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81138‎ | r81139 | r81140 >
Date:17:25, 28 January 2011
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Follow-up r81132 removal of pre-8.3 support.
Still needs removal of $wgDBts2schema inside initial_setup()
Modified paths:
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -192,7 +192,7 @@
193193
194194 $this->doQuery( "SET client_encoding='UTF8'" );
195195
196 - global $wgDBmwschema, $wgDBts2schema;
 196+ global $wgDBmwschema;
197197 if ( isset( $wgDBmwschema )
198198 && $wgDBmwschema !== 'mediawiki'
199199 && preg_match( '/^\w+$/', $wgDBmwschema )
@@ -293,27 +293,6 @@
294294 print "OK</li>\n";
295295 }
296296
297 - if ( $this->numeric_version < 8.3 ) {
298 - // Tsearch2 checks
299 - print '<li>Checking that tsearch2 is installed in the database "' .
300 - htmlspecialchars( $wgDBname ) . '"...';
301 - if ( !$this->tableExists( 'pg_ts_cfg', $wgDBts2schema ) ) {
302 - print '<b>FAILED</b>. tsearch2 must be installed in the database "' .
303 - htmlspecialchars( $wgDBname ) . '".';
304 - print 'Please see <a href="http://www.devx.com/opensource/Article/21674/0/page/2">this article</a>';
305 - print " for instructions or ask on #postgresql on irc.freenode.net</li>\n";
306 - dieout( );
307 - }
308 - print "OK</li>\n";
309 - print '<li>Ensuring that user "' . htmlspecialchars( $wgDBuser ) .
310 - '" has select rights on the tsearch2 tables...';
311 - foreach ( array( 'cfg', 'cfgmap', 'dict', 'parser' ) as $table ) {
312 - $SQL = "GRANT SELECT ON pg_ts_$table TO $safeuser";
313 - $this->doQuery( $SQL );
314 - }
315 - print "OK</li>\n";
316 - }
317 -
318297 // Setup the schema for this user if needed
319298 $result = $this->schemaExists( $wgDBmwschema );
320299 $safeschema = $this->addIdentifierQuotes( $wgDBmwschema );
@@ -359,84 +338,6 @@
360339 } // end superuser
361340
362341 if ( !defined( 'POSTGRES_SEARCHPATH' ) ) {
363 -
364 - if ( $this->numeric_version < 8.3 ) {
365 - // Do we have the basic tsearch2 table?
366 - print '<li>Checking for tsearch2 in the schema "' . htmlspecialchars( $wgDBts2schema ) . '"...';
367 - if ( !$this->tableExists( 'pg_ts_dict', $wgDBts2schema ) ) {
368 - print '<b>FAILED</b>. Make sure tsearch2 is installed. See <a href="';
369 - print 'http://www.devx.com/opensource/Article/21674/0/page/2">this article</a>';
370 - print " for instructions.</li>\n";
371 - dieout( );
372 - }
373 - print "OK</li>\n";
374 -
375 - // Does this user have the rights to the tsearch2 tables?
376 - $ctype = pg_fetch_result( $this->doQuery( 'SHOW lc_ctype' ), 0, 0 );
377 - print '<li>Checking tsearch2 permissions...';
378 - // Let's check all four, just to be safe
379 - error_reporting( 0 );
380 - $ts2tables = array( 'cfg', 'cfgmap', 'dict', 'parser' );
381 - $safetsschema = $this->addIdentifierQuotes( $wgDBts2schema );
382 - foreach ( $ts2tables as $tname ) {
383 - $SQL = "SELECT count(*) FROM $safetsschema.pg_ts_$tname";
384 - $res = $this->doQuery( $SQL );
385 - if ( !$res ) {
386 - print "<b>FAILED</b> to access " . htmlspecialchars( "pg_ts_$tname" ) .
387 - ". Make sure that the user \"". htmlspecialchars( $wgDBuser ) .
388 - "\" has SELECT access to all four tsearch2 tables</li>\n";
389 - dieout( );
390 - }
391 - }
392 - $SQL = "SELECT ts_name FROM $safetsschema.pg_ts_cfg WHERE locale = " . $this->addQuotes( $ctype ) ;
393 - $SQL .= " ORDER BY CASE WHEN ts_name <> 'default' THEN 1 ELSE 0 END";
394 - $res = $this->doQuery( $SQL );
395 - error_reporting( E_ALL );
396 - if ( !$res ) {
397 - print "<b>FAILED</b>. Could not determine the tsearch2 locale information</li>\n";
398 - dieout("</ul>");
399 - }
400 - print 'OK</li>';
401 -
402 - // Will the current locale work? Can we force it to?
403 - print '<li>Verifying tsearch2 locale with ' . htmlspecialchars( $ctype ) . '...';
404 - $rows = $this->numRows( $res );
405 - $resetlocale = 0;
406 - if ( !$rows ) {
407 - print "<b>not found</b></li>\n";
408 - print '<li>Attempting to set default tsearch2 locale to "' . htmlspecialchars( $ctype ) . '"...';
409 - $resetlocale = 1;
410 - } else {
411 - $tsname = pg_fetch_result( $res, 0, 0 );
412 - if ( $tsname != 'default' ) {
413 - print "<b>not set to default (" . htmlspecialchars( $tsname ) . ")</b>";
414 - print "<li>Attempting to change tsearch2 default locale to \"" .
415 - htmlspecialchars( $ctype ) . "\"...";
416 - $resetlocale = 1;
417 - }
418 - }
419 - if ( $resetlocale ) {
420 - $SQL = "UPDATE $safetsschema.pg_ts_cfg SET locale = " . $this->addQuotes( $ctype ) . " WHERE ts_name = 'default'";
421 - $res = $this->doQuery( $SQL );
422 - if ( !$res ) {
423 - print '<b>FAILED</b>. ';
424 - print 'Please make sure that the locale in pg_ts_cfg for "default" is set to "' .
425 - htmlspecialchars( $ctype ) . "\"</li>\n";
426 - dieout( );
427 - }
428 - print 'OK</li>';
429 - }
430 -
431 - // Final test: try out a simple tsearch2 query
432 - $SQL = "SELECT $safetsschema.to_tsvector('default','MediaWiki tsearch2 testing')";
433 - $res = $this->doQuery( $SQL );
434 - if ( !$res ) {
435 - print '<b>FAILED</b>. Specifically, "' . htmlspecialchars( $SQL ) . '" did not work.</li>';
436 - dieout( );
437 - }
438 - print 'OK</li>';
439 - }
440 -
441342 // Install plpgsql if needed
442343 $this->setup_plpgsql();
443344

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81132Per comment on bug 26612, we should drop the pre-Postgres 8.3 support with th...demon14:12, 28 January 2011

Comments

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

initial_setup isn't called from anything, it's basically left for reference now until PostgresInstaller is done.

Status & tagging log