3 function updateSearchIndex( $start, $end, $maxLockTime, $quiet ) {
5 global $wgDisableSearchUpdate;
7 $fname = "updateSearchIndex";
10 $wgDisableSearchUpdate = false;
12 $dbw =& wfGetDB( DB_MASTER );
13 $recentchanges = $dbw->tableName( 'recentchanges' );
15 output( "Updating searchindex between $start and $end\n" );
17 # Select entries from recentchanges which are on top and between the specified times
18 $start = $dbw->strencode( $start );
19 $end = $dbw->strencode( $end );
21 $sql = "SELECT rc_cur_id,rc_type,rc_moved_to_ns,rc_moved_to_title FROM $recentchanges
22 WHERE rc_this_oldid=0 AND rc_timestamp BETWEEN '$start' AND '$end'";
23 $res = $dbw->query( $sql, $fname );
27 output( " --- Waiting for lock ---" );
33 # Loop through the results and do a search update
34 while ( $row = $dbw->fetchObject( $res ) ) {
35 # Allow reads to be processed
36 if ( $maxLockTime && time() > $lockTime + $maxLockTime ) {
37 output( " --- Relocking ---" );
42 if ( $row->rc_type == RC_LOG ) {
44 } elseif ( $row->rc_type == RC_MOVE || $row->rc_type == RC_MOVE_OVER_REDIRECT ) {
45 # Rename searchindex entry
46 $titleObj = Title::makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title );
47 $title = $titleObj->getPrefixedDBkey();
48 output( "$title..." );
49 $u = new SearchUpdate( $row->rc_cur_id, $title, false );
53 $curRow = $dbw->selectRow( 'cur', array( 'cur_namespace', 'cur_title', 'cur_text' ),
54 array( 'cur_id' => $row->rc_cur_id ), $fname, 'FOR UPDATE' );
56 $titleObj = Title::makeTitle( $curRow->cur_namespace, $curRow->cur_title );
57 $title = $titleObj->getPrefixedDBkey();
60 $u = new SearchUpdate( $row->rc_cur_id, $curRow->cur_title, $curRow->cur_text );
74 function lockSearchindex( &$db ) {
75 $dbw =& wfGetDB( DB_MASTER );
76 extract( $dbw->tableNames( 'searchindex', 'cur', 'interwiki' ) );
77 $dbw->query( "LOCK TABLES $searchindex LOW_PRIORITY WRITE, $cur READ, $interwiki READ" );
80 function unlockSearchindex() {
81 $dbw =& wfGetDB( DB_MASTER );
82 $dbw->query( "UNLOCK TABLES" );
85 # Unlock and lock again
86 # Since the lock is low-priority, queued reads will be able to complete
87 function relockSearchindex() {
92 function output( $text ) {