4 * @subpackage Maintenance
8 function updateSearchIndex( $start, $end, $maxLockTime, $quiet ) {
10 global $wgDisableSearchUpdate;
12 $fname = "updateSearchIndex";
15 $wgDisableSearchUpdate = false;
17 $dbw =& wfGetDB( DB_MASTER );
18 $recentchanges = $dbw->tableName( 'recentchanges' );
20 output( "Updating searchindex between $start and $end\n" );
22 # Select entries from recentchanges which are on top and between the specified times
23 $start = $dbw->strencode( $start );
24 $end = $dbw->strencode( $end );
26 $sql = "SELECT rc_cur_id,rc_type,rc_moved_to_ns,rc_moved_to_title FROM $recentchanges
27 WHERE rc_this_oldid=0 AND rc_timestamp BETWEEN '$start' AND '$end'";
28 $res = $dbw->query( $sql, $fname );
32 output( " --- Waiting for lock ---" );
38 # Loop through the results and do a search update
39 while ( $row = $dbw->fetchObject( $res ) ) {
40 # Allow reads to be processed
41 if ( $maxLockTime && time() > $lockTime + $maxLockTime ) {
42 output( " --- Relocking ---" );
47 if ( $row->rc_type == RC_LOG ) {
49 } elseif ( $row->rc_type == RC_MOVE || $row->rc_type == RC_MOVE_OVER_REDIRECT ) {
50 # Rename searchindex entry
51 $titleObj = Title::makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title );
52 $title = $titleObj->getPrefixedDBkey();
53 output( "$title..." );
54 $u = new SearchUpdate( $row->rc_cur_id, $title, false );
58 $curRow = $dbw->selectRow( 'cur', array( 'cur_namespace', 'cur_title', 'cur_text' ),
59 array( 'cur_id' => $row->rc_cur_id ), $fname, 'FOR UPDATE' );
61 $titleObj = Title::makeTitle( $curRow->cur_namespace, $curRow->cur_title );
62 $title = $titleObj->getPrefixedDBkey();
65 $u = new SearchUpdate( $row->rc_cur_id, $curRow->cur_title, $curRow->cur_text );
79 function lockSearchindex( &$db ) {
80 $dbw =& wfGetDB( DB_MASTER );
81 extract( $dbw->tableNames( 'searchindex', 'cur', 'interwiki' ) );
82 $dbw->query( "LOCK TABLES $searchindex LOW_PRIORITY WRITE, $cur READ, $interwiki READ" );
85 function unlockSearchindex() {
86 $dbw =& wfGetDB( DB_MASTER );
87 $dbw->query( "UNLOCK TABLES" );
90 # Unlock and lock again
91 # Since the lock is low-priority, queued reads will be able to complete
92 function relockSearchindex() {
97 function output( $text ) {