From: Kunal Mehta Date: Wed, 29 Apr 2015 17:36:03 +0000 (-0700) Subject: MovePage: Move target existence check into isValidMove() X-Git-Tag: 1.31.0-rc.0~11552 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=75c813cc9a992e7e2766d0ff79db1021e3beba8a;p=lhc%2Fweb%2Fwiklou.git MovePage: Move target existence check into isValidMove() The target existence check is not dependent upon the user who is making the move, so move it into MovePage::isValidMove() instead of MovePage::checkPermissions() which not all callers will call. Bug: T97536 Change-Id: I3aad1455ad4c064cbeaf35221a00ca6baba97c33 --- diff --git a/includes/MovePage.php b/includes/MovePage.php index de7da3f939..9891106022 100644 --- a/includes/MovePage.php +++ b/includes/MovePage.php @@ -64,21 +64,9 @@ class MovePage { $status->fatal( 'spamprotectiontext' ); } - # The move is allowed only if (1) the target doesn't exist, or - # (2) the target is a redirect to the source, and has no history - # (so we can undo bad moves right after they're done). - - if ( $this->newTitle->getArticleID() ) { # Target exists; check for validity - if ( !$this->isValidMoveTarget() ) { - $status->fatal( 'articleexists' ); - } - } else { - $tp = $this->newTitle->getTitleProtection(); - if ( $tp !== false ) { - if ( !$user->isAllowed( $tp['permission'] ) ) { - $status->fatal( 'cantmove-titleprotected' ); - } - } + $tp = $this->newTitle->getTitleProtection(); + if ( $tp !== false && !$user->isAllowed( $tp['permission'] ) ) { + $status->fatal( 'cantmove-titleprotected' ); } Hooks::run( 'MovePageCheckPermissions', @@ -125,6 +113,13 @@ class MovePage { $status->fatal( 'badarticleerror' ); } + # The move is allowed only if (1) the target doesn't exist, or + # (2) the target is a redirect to the source, and has no history + # (so we can undo bad moves right after they're done). + if ( $this->newTitle->getArticleID() && !$this->isValidMoveTarget() ) { + $status->fatal( 'articleexists' ); + } + // Content model checks if ( !$wgContentHandlerUseDB && $this->oldTitle->getContentModel() !== $this->newTitle->getContentModel() ) {