* (bug 2275) Update search index more or less right on page move
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 1 Jun 2005 02:31:45 +0000 (02:31 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 1 Jun 2005 02:31:45 +0000 (02:31 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/SearchUpdate.php
includes/Title.php

index ab9c2f7..30d06b2 100644 (file)
@@ -232,6 +232,7 @@ Various bugfixes, small features, and a few experimental things:
   that does both numeric and named chars: Sanitizer::decodeCharReferences
 * Removed some obsolete UTF-8 converter functions
 * Fix function comment in debug dump of SQL statements
+* (bug 2275) Update search index more or less right on page move
 
 
 === Caveats ===
index c64425b..ecf6ca1 100644 (file)
@@ -303,8 +303,8 @@ $text: text of the mail
 $old: old title
 $nt: new title
 $user: user who did the move
-$oldid: old article database ID
-$newid: new article database ID
+$pageid: database ID of the page that's been moved
+$redirid: database ID of the created redirect
 
 'UnknownAction': An unknown "action" has occured (useful for defining
                 your own actions)
index be7a4c4..dc383fe 100644 (file)
@@ -41,7 +41,7 @@ class SearchUpdate {
                $search =& SearchEngine::create();
                $lc = $search->legalSearchChars() . '&#;';
                
-               if( $this->mText == false ) {
+               if( $this->mText === false ) {
                        $search->updateTitle($this->mId,
                                Title::indexTitle( $this->mNamespace, $this->mTitle ));
                        wfProfileOut( $fname );
index e2c527e..0bc30af 100644 (file)
@@ -1532,18 +1532,20 @@ class Title {
                if( is_string( $err ) ) {
                        return $err;
                }
+               
+               $pageid = $this->getArticleID();
                if( $nt->exists() ) {
                        $this->moveOverExistingRedirect( $nt, $reason );
                } else { # Target didn't exist, do normal move.
                        $this->moveToNewTitle( $nt, $newid, $reason );
                }
+               $redirid = $this->getArticleID();
 
                # Fixing category links (those without piped 'alternate' names) to be sorted under the new title
-               
                $dbw =& wfGetDB( DB_MASTER );
                $categorylinks = $dbw->tableName( 'categorylinks' );
                $sql = "UPDATE $categorylinks SET cl_sortkey=" . $dbw->addQuotes( $nt->getPrefixedText() ) .
-                       " WHERE cl_from=" . $dbw->addQuotes( $this->getArticleID() ) .
+                       " WHERE cl_from=" . $dbw->addQuotes( $pageid ) .
                        " AND cl_sortkey=" . $dbw->addQuotes( $this->getPrefixedText() );
                $dbw->query( $sql, 'SpecialMovepage::doSubmit' );
 
@@ -1559,12 +1561,12 @@ class Title {
                }
 
                # Update search engine
-               $u = new SearchUpdate( $oldid, $nt->getPrefixedDBkey() );
+               $u = new SearchUpdate( $pageid, $nt->getPrefixedDBkey() );
                $u->doUpdate();
-               $u = new SearchUpdate( $newid, $this->getPrefixedDBkey(), '' );
+               $u = new SearchUpdate( $redirid, $this->getPrefixedDBkey(), '' );
                $u->doUpdate();
 
-               wfRunHooks( 'TitleMoveComplete', array(&$this, &$nt, &$wgUser, $oldid, $newid) );
+               wfRunHooks( 'TitleMoveComplete', array( &$this, &$nt, &$wgUser, $pageid, $redirid ) );
                return true;
        }