require_once __DIR__ . '/Maintenance.php';
use Wikimedia\Rdbms\IMaintainableDatabase;
+use Wikimedia\Rdbms\DatabaseSqlite;
/**
* Maintenance script that rebuilds search index table from scratch.
// Shouldn't be needed for Postgres
$this->db = $this->getDB( DB_MASTER );
if ( $this->db->getType() == 'postgres' ) {
- $this->error( "This script is not needed when using Postgres.\n", true );
+ $this->fatalError( "This script is not needed when using Postgres.\n" );
}
if ( $this->db->getType() == 'sqlite' ) {
if ( !DatabaseSqlite::getFulltextSearchModule() ) {
- $this->error( "Your version of SQLite module for PHP doesn't "
- . "support full-text search (FTS3).\n", true );
+ $this->fatalError( "Your version of SQLite module for PHP doesn't "
+ . "support full-text search (FTS3).\n" );
}
if ( !$this->db->checkForEnabledSearch() ) {
- $this->error( "Your database schema is not configured for "
- . "full-text search support. Run update.php.\n", true );
+ $this->fatalError( "Your database schema is not configured for "
+ . "full-text search support. Run update.php.\n" );
}
}
$this->output( "Rebuilding index fields for {$count} pages...\n" );
$n = 0;
- $fields = array_merge(
- Revision::selectPageFields(),
- Revision::selectFields(),
- Revision::selectTextFields()
- );
+ $revQuery = Revision::getQueryInfo( [ 'page', 'text' ] );
while ( $n < $count ) {
if ( $n ) {
}
$end = $n + self::RTI_CHUNK_SIZE - 1;
- $res = $this->db->select( [ 'page', 'revision', 'text' ], $fields,
+ $res = $this->db->select( $revQuery['tables'], $revQuery['fields'],
[ "page_id BETWEEN $n AND $end", 'page_latest = rev_id', 'rev_text_id = old_id' ],
__METHOD__
);
private function createMysqlTextIndex() {
$searchindex = $this->db->tableName( 'searchindex' );
$this->output( "\nRebuild the index...\n" );
- $sql = "ALTER TABLE $searchindex ADD FULLTEXT si_title (si_title), " .
- "ADD FULLTEXT si_text (si_text)";
- $this->db->query( $sql, __METHOD__ );
+ foreach ( [ 'si_title', 'si_text' ] as $field ) {
+ $sql = "ALTER TABLE $searchindex ADD FULLTEXT $field ($field)";
+ $this->db->query( $sql, __METHOD__ );
+ }
}
/**