r55262 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55261‎ | r55262 | r55263 >
Date:20:13, 18 August 2009
Author:simetrical
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialMovepage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialMovepage.php
@@ -351,6 +351,9 @@
352352 $createRedirect = true;
353353 }
354354
 355+ # Do the actual move. First remember the old ID for later reference,
 356+ # so that we don't get the ID of the redirect.
 357+ $oldId = $ot->getArticleId();
355358 $error = $ot->moveTo( $nt, true, $this->reason, $createRedirect );
356359 if ( $error !== true ) {
357360 # FIXME: show all the errors in a list, not just the first one
@@ -444,7 +447,7 @@
445448 $skin = $wgUser->getSkin();
446449 $count = 1;
447450 foreach( $extraPages as $oldSubpage ) {
448 - if( $oldSubpage->getArticleId() == $ot->getArticleId() ) {
 451+ if( $oldSubpage->getArticleId() == $oldId ) {
449452 # Already did this one.
450453 continue;
451454 }
Index: trunk/phase3/RELEASE-NOTES
@@ -413,6 +413,7 @@
414414 * (bug 20265) Make AncientPages and UnusedFiles work on SQLite
415415 * Fixed XSS vulnerability for Internet Explorer clients (only pre-release
416416 versions of MediaWiki were affected).
 417+* (bug 14817) Moving a page to a subpage of itself moves it twice
417418
418419 == API changes in 1.16 ==
419420

Follow-up revisions

RevisionCommit summaryAuthorDate
r55266Untested equivalent of r55262 ("When moving a page to a subpage of itself, do...catrope20:28, 18 August 2009

Status & tagging log