From: Brion Vibber Date: Tue, 4 Apr 2006 06:37:17 +0000 (+0000) Subject: * Fix updateSearchIndex.php for new schema X-Git-Tag: 1.6.0~42 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=0e5e2d7db9e31e9b4db3693b5f05245062397ffd;p=lhc%2Fweb%2Fwiklou.git * Fix updateSearchIndex.php for new schema --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1c3693dee1..0c1700512c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -741,6 +741,7 @@ fully support the editing toolbar, but was found to be too confusing. when running command-line scripts in a Unix terminal. * (bug 5195) rebuildrecentchanges.php works again; Database::insertSelect now has a parameter for select options. +* Fix updateSearchIndex.php for new schema === Caveats === diff --git a/maintenance/updateSearchIndex.inc b/maintenance/updateSearchIndex.inc index 07cdf9d143..ed01575c32 100644 --- a/maintenance/updateSearchIndex.inc +++ b/maintenance/updateSearchIndex.inc @@ -23,14 +23,18 @@ function updateSearchIndex( $start, $end, $maxLockTime, $quiet ) { $start = $dbw->strencode( $start ); $end = $dbw->strencode( $end ); + $page = $dbw->tableName( 'page' ); $sql = "SELECT rc_cur_id,rc_type,rc_moved_to_ns,rc_moved_to_title FROM $recentchanges - WHERE rc_this_oldid=0 AND rc_timestamp BETWEEN '$start' AND '$end'"; + JOIN $page ON rc_cur_id=page_id AND rc_this_oldid=page_latest + WHERE rc_timestamp BETWEEN '$start' AND '$end' + "; $res = $dbw->query( $sql, $fname ); + # Lock searchindex if ( $maxLockTime ) { output( " --- Waiting for lock ---" ); - lockSearchindex(); + lockSearchindex( $dbw ); $lockTime = time(); output( "\n" ); } @@ -40,7 +44,7 @@ function updateSearchIndex( $start, $end, $maxLockTime, $quiet ) { # Allow reads to be processed if ( $maxLockTime && time() > $lockTime + $maxLockTime ) { output( " --- Relocking ---" ); - relockSearchindex(); + relockSearchindex( $dbw ); $lockTime = time(); output( "\n" ); } @@ -54,15 +58,14 @@ function updateSearchIndex( $start, $end, $maxLockTime, $quiet ) { $u = new SearchUpdate( $row->rc_cur_id, $title, false ); output( "\n" ); } else { - # Get cur row - $curRow = $dbw->selectRow( 'cur', array( 'cur_namespace', 'cur_title', 'cur_text' ), - array( 'cur_id' => $row->rc_cur_id ), $fname, 'FOR UPDATE' ); - if ( $curRow ) { - $titleObj = Title::makeTitle( $curRow->cur_namespace, $curRow->cur_title ); + // Get current revision + $rev = Revision::loadFromPageId( $dbw, $row->rc_cur_id ); + if( $rev ) { + $titleObj = $rev->getTitle(); $title = $titleObj->getPrefixedDBkey(); output( $title ); # Update searchindex - $u = new SearchUpdate( $row->rc_cur_id, $curRow->cur_title, $curRow->cur_text ); + $u = new SearchUpdate( $row->rc_cur_id, $titleObj->getText(), $rev->getText() ); $u->doUpdate(); output( "\n" ); } @@ -71,27 +74,35 @@ function updateSearchIndex( $start, $end, $maxLockTime, $quiet ) { # Unlock searchindex if ( $maxLockTime ) { - unlockSearchindex(); + unlockSearchindex( $dbw ); } output( "Done\n" ); } function lockSearchindex( &$db ) { - $dbw =& wfGetDB( DB_MASTER ); - extract( $dbw->tableNames( 'searchindex', 'cur', 'interwiki' ) ); - $dbw->query( "LOCK TABLES $searchindex LOW_PRIORITY WRITE, $cur READ, $interwiki READ" ); + $write = array( 'searchindex' ); + $read = array( 'page', 'revision', 'text', 'interwiki' ); + $items = array(); + + foreach( $write as $table ) { + $items[] = $db->tableName( $table ) . ' LOW_PRIORITY WRITE'; + } + foreach( $read as $table ) { + $items[] = $db->tableName( $table ) . ' READ'; + } + $sql = "LOCK TABLES " . implode( ',', $items ); + $db->query( $sql ); } -function unlockSearchindex() { - $dbw =& wfGetDB( DB_MASTER ); - $dbw->query( "UNLOCK TABLES" ); +function unlockSearchindex( &$db ) { + $db->query( "UNLOCK TABLES" ); } # Unlock and lock again # Since the lock is low-priority, queued reads will be able to complete -function relockSearchindex() { - unlockSearchindex(); - lockSearchindex(); +function relockSearchindex( &$db ) { + unlockSearchindex( $db ); + lockSearchindex( $db ); } function output( $text ) {