Don't move twice when moving subpages to a subpage
authorAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 18 Aug 2009 20:13:37 +0000 (20:13 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 18 Aug 2009 20:13:37 +0000 (20:13 +0000)
(bug 14817) When a page got moved to a subpage of itself, and "move
subpages" was checked, the page got moved, then moved again, like Foo ->
Foo/Bar -> Foo/Bar/Bar.  There was an explicit check to prevent this,
but the check was incorrect: it used $ot->getArticleID() after $ot had
already been moved, so the ID was the redirect.  The behavior of
getArticleID() here isn't obvious, so I cached the ID in advance for
clarity instead of switching to $nt->getArticleID().

Brief inspection of Title::moveSubpages() suggests that that would be
affected too.  The third place we have this code copy-pasted (bleh) is
SpecialRenameuser, but that's not affected because usernames can't have
slashes in them.

RELEASE-NOTES
includes/specials/SpecialMovepage.php

index f755547..7419fef 100644 (file)
@@ -413,6 +413,7 @@ this. Was used when mwEmbed was going to be an extension.
 * (bug 20265) Make AncientPages and UnusedFiles work on SQLite
 * Fixed XSS vulnerability for Internet Explorer clients (only pre-release 
   versions of MediaWiki were affected).
+* (bug 14817) Moving a page to a subpage of itself moves it twice
 
 == API changes in 1.16 ==
 
index 70b1594..c90d74a 100644 (file)
@@ -351,6 +351,9 @@ class MovePageForm {
                        $createRedirect = true;
                }
 
+               # Do the actual move.  First remember the old ID for later reference,
+               # so that we don't get the ID of the redirect.
+               $oldId = $ot->getArticleId();
                $error = $ot->moveTo( $nt, true, $this->reason, $createRedirect );
                if ( $error !== true ) {
                        # FIXME: show all the errors in a list, not just the first one
@@ -444,7 +447,7 @@ class MovePageForm {
                $skin = $wgUser->getSkin();
                $count = 1;
                foreach( $extraPages as $oldSubpage ) {
-                       if( $oldSubpage->getArticleId() == $ot->getArticleId() ) {
+                       if( $oldSubpage->getArticleId() == $oldId ) {
                                # Already did this one.
                                continue;
                        }