From: Aryeh Gregor Date: Tue, 18 Aug 2009 20:13:37 +0000 (+0000) Subject: Don't move twice when moving subpages to a subpage X-Git-Tag: 1.31.0-rc.0~40241 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=30837e8b98b12b82460bc8eafe4f5448513b0535;p=lhc%2Fweb%2Fwiklou.git Don't move twice when moving subpages to a subpage (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. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f755547cc4..7419fefd84 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 70b15948f1..c90d74aa5a 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -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; }