$lockTime + $maxLockTime ) { output( " --- Relocking ---" ); relockSearchindex(); $lockTime = time(); output( "\n" ); } if ( $row->rc_type == RC_LOG ) { continue; } elseif ( $row->rc_type == RC_MOVE || $row->rc_type == RC_MOVE_OVER_REDIRECT ) { # Rename searchindex entry $titleObj = Title::makeTitle( $row->rc_moved_to_ns, $row->rc_moved_to_title ); $title = $titleObj->getPrefixedDBkey(); output( "$title..." ); $u = new SearchUpdate( $row->rc_cur_id, $title, false ); output( "\n" ); } else { # Get cur row $curRow = wfGetArray( 'cur', array( 'cur_namespace', 'cur_title', 'cur_text' ), array( 'cur_id' => $row->rc_cur_id ) ); if ( $curRow ) { $titleObj = Title::makeTitle( $curRow->cur_namespace, $curRow->cur_title ); $title = $titleObj->getPrefixedDBkey(); output( $title ); # Update searchindex $u = new SearchUpdate( $row->rc_cur_id, $curRow->cur_title, $curRow->cur_text ); $u->doUpdate(); output( "\n" ); } } } # Unlock searchindex if ( $maxLockTime ) { unlockSearchindex(); } output( "Done\n" ); } function lockSearchindex() { wfQuery( "LOCK TABLES searchindex LOW_PRIORITY WRITE, cur READ", DB_WRITE ); } function unlockSearchindex() { wfQuery( "UNLOCK TABLES", DB_WRITE ); } # Unlock and lock again # Since the lock is low-priority, queued reads will be able to complete function relockSearchindex() { unlockSearchindex(); lockSearchindex(); } function output( $text ) { global $wgQuiet; if ( !$wgQuiet ) { print $text; } } ?>