/**
 * @param $from
 * @param $to Title
 * @param $user
 * @param $pageid
 * @param $redirid
 * @return bool
 */
function mwSearchUpdateMove($from, $to, $user, $pageid, $redirid)
{
    global $wgDBname;
    $db = wfGetDB(DB_MASTER);
    $pageRevision = Revision::loadFromPageId($db, $pageid);
    if (!is_null($pageRevision)) {
        MWSearchUpdater::updatePage($wgDBname, $to, $pageRevision->getText());
    }
    $redirText = '#REDIRECT [[' . $to->getPrefixedText() . "]]\n";
    MWSearchUpdater::updatePage($wgDBname, $from, $redirText);
    return true;
}
 /**
  * Request that the daemon flush and reopen a given index, without changing
  * the global is-running state.
  * @return bool
  * @static
  */
 static function flush($dbname)
 {
     return MWSearchUpdater::sendRPC('searchupdater.flush', array($dbname));
 }
 /**
  * Trawl thorugh the recentchanges log to update pages which have been
  * modified since a given date. This gives a chance to catch up if
  * the index updater daemon was broken or disabled since last build.
  */
 function rebuildRecent($since = null)
 {
     global $wgDBname;
     if (is_null($since)) {
         $since = '20010115000000';
     }
     // Turn buffering back on; these are relatively small.
     //$this->dbstream->bufferResults( true );
     $cutoff = $this->dbstream->addQuotes($this->dbstream->timestamp($since));
     $recentchanges = $this->dbstream->tableName('recentchanges');
     $revision = $this->dbstream->tableName('revision');
     $page = $this->dbstream->tableName('page');
     $result = $this->dbstream->query("SELECT *\n\t\t\t FROM {$recentchanges},{$page},{$revision}\n\t\t\t WHERE rc_namespace=page_namespace\n\t\t\t AND rc_title=page_title\n\t\t\t AND rc_this_oldid=page_latest\n\t\t\t AND page_latest=rev_id\n\t\t\t AND rc_timestamp > {$cutoff}", __METHOD__);
     #$max = $this->dbstream->numRows( $result );
     $max = 10000;
     // wacky estimate
     if ($max == 0) {
         echo "Nothing to do.\n";
         return;
     }
     $this->init($max);
     $lastError = true;
     foreach ($result as $row) {
         $this->progress();
         $rev = new Revision($row);
         if (is_object($rev)) {
             $title = Title::makeTitle($row->page_namespace, $row->page_title);
             try {
                 MWSearchUpdater::updatePage($wgDBname, $title, $rev->getText());
             } catch (MWException $e) {
                 echo "ERROR: " . $e->getMessage() . "\n";
                 $lastError = $e;
             }
         }
     }
     $this->finalStatus();
     $this->dbstream->freeResult($result);
     return $lastError;
 }