3 function updateSearchIndex( $start, $end, $maxLockTime, $quiet ) {
5 global $wgDisableSearchUpdate;
7 $fname = "updateSearchIndex";
10 $wgDisableSearchUpdate = false;
12 output( "Updating searchindex between $start and $end\n" );
14 # Select entries from recentchanges which are on top and between the specified times
15 $start = wfStrencode( $start );
16 $end = wfStrencode( $end );
18 $sql = "SELECT rc_cur_id,rc_type,rc_moved_to_ns,rc_moved_to_title FROM recentchanges
19 WHERE rc_this_oldid=0 AND rc_timestamp BETWEEN '$start' AND '$end'";
20 $res = wfQuery( $sql, DB_READ, $fname );
24 output( " --- Waiting for lock ---" );
30 # Loop through the results and do a search update
31 while ( $row = wfFetchObject( $res ) ) {
32 # Allow reads to be processed
33 if ( $maxLockTime && time() > $lockTime + $maxLockTime ) {
34 output( " --- Relocking ---" );
39 if ( $row->rc_type == RC_LOG ) {
41 } elseif ( $row->rc_type == RC_MOVE || $row->rc_type == RC_MOVE_OVER_REDIRECT ) {
42 # Rename searchindex entry
43 $titleObj = Title::makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title );
44 $title = $titleObj->getPrefixedDBkey();
45 output( "$title..." );
46 $u = new SearchUpdate( $row->rc_cur_id, $title, false );
50 $curRow = wfGetArray( 'cur', array( 'cur_namespace', 'cur_title', 'cur_text' ), array( 'cur_id' => $row->rc_cur_id ) );
52 $titleObj = Title::makeTitle( $curRow->cur_namespace, $curRow->cur_title );
53 $title = $titleObj->getPrefixedDBkey();
56 $u = new SearchUpdate( $row->rc_cur_id, $curRow->cur_title, $curRow->cur_text );
70 function lockSearchindex() {
71 wfQuery( "LOCK TABLES searchindex LOW_PRIORITY WRITE, cur READ, interwiki READ", DB_WRITE );
74 function unlockSearchindex() {
75 wfQuery( "UNLOCK TABLES", DB_WRITE );
78 # Unlock and lock again
79 # Since the lock is low-priority, queued reads will be able to complete
80 function relockSearchindex() {
85 function output( $text ) {