- # Lock searchindex
- if ( $maxLockTime ) {
- $this->output( " --- Waiting for lock ---" );
- $this->lockSearchindex( $dbw );
- $lockTime = time();
- $this->output( "\n" );
- }
-
- # Loop through the results and do a search update
- while ( $row = $dbw->fetchObject( $res ) ) {
- # Allow reads to be processed
- if ( $maxLockTime && time() > $lockTime + $maxLockTime ) {
- $this->output( " --- Relocking ---" );
- $this->relockSearchindex( $dbw );
- $lockTime = time();
- $this->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();
- $this->output( "$title..." );
- $u = new SearchUpdate( $row->rc_cur_id, $title, false );
- $this->output( "\n" );
- } else {
- // Get current revision
- $rev = Revision::loadFromPageId( $dbw, $row->rc_cur_id );
- if( $rev ) {
- $titleObj = $rev->getTitle();
- $title = $titleObj->getPrefixedDBkey();
- $this->output( $title );
- # Update searchindex
- $u = new SearchUpdate( $row->rc_cur_id, $titleObj->getText(), $rev->getText() );
- $u->doUpdate();
- $this->output( "\n" );
- }
- }
- }
-
- # Unlock searchindex
- if ( $maxLockTime ) {
- $this->output( " --- Unlocking --" );
- $this->unlockSearchindex( $dbw );
- $this->output( "\n" );
- }