diff options
Diffstat (limited to 'includes/api/ApiMove.php')
-rw-r--r-- | includes/api/ApiMove.php | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 9d73562b..c18036cf 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -30,10 +30,6 @@ */ class ApiMove extends ApiBase { - public function __construct( $main, $action ) { - parent::__construct( $main, $action ); - } - public function execute() { $user = $this->getUser(); $params = $this->extractRequestParams(); @@ -42,7 +38,7 @@ class ApiMove extends ApiBase { if ( isset( $params['from'] ) ) { $fromTitle = Title::newFromText( $params['from'] ); - if ( !$fromTitle ) { + if ( !$fromTitle || $fromTitle->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['from'] ) ); } } elseif ( isset( $params['fromid'] ) ) { @@ -58,7 +54,7 @@ class ApiMove extends ApiBase { $fromTalk = $fromTitle->getTalkPage(); $toTitle = Title::newFromText( $params['to'] ); - if ( !$toTitle ) { + if ( !$toTitle || $toTitle->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['to'] ) ); } $toTalk = $toTitle->getTalkPage(); @@ -82,10 +78,17 @@ class ApiMove extends ApiBase { } $r = array( 'from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason'] ); - if ( !$params['noredirect'] || !$user->isAllowed( 'suppressredirect' ) ) { + + if ( $fromTitle->exists() ) { + //NOTE: we assume that if the old title exists, it's because it was re-created as + // a redirect to the new title. This is not safe, but what we did before was + // even worse: we just determined whether a redirect should have been created, + // and reported that it was created if it should have, without any checks. + // Also note that isRedirect() is unreliable because of bug 37209. $r['redirectcreated'] = ''; } - if( $toTitleExists ) { + + if ( $toTitleExists ) { $r['moveoverredirect'] = ''; } @@ -96,7 +99,7 @@ class ApiMove extends ApiBase { if ( $retval === true ) { $r['talkfrom'] = $fromTalk->getPrefixedText(); $r['talkto'] = $toTalk->getPrefixedText(); - if( $toTalkExists ) { + if ( $toTalkExists ) { $r['talkmoveoverredirect'] = ''; } } else { @@ -122,7 +125,7 @@ class ApiMove extends ApiBase { } } - $watch = "preferences"; + $watch = 'preferences'; if ( isset( $params['watchlist'] ) ) { $watch = $params['watchlist']; } elseif ( $params['watch'] ) { @@ -288,15 +291,11 @@ class ApiMove extends ApiBase { public function getExamples() { return array( - 'api.php?action=move&from=Exampel&to=Example&token=123ABC&reason=Misspelled%20title&movetalk=&noredirect=' + 'api.php?action=move&from=Badtitle&to=Goodtitle&token=123ABC&reason=Misspelled%20title&movetalk=&noredirect=' ); } public function getHelpUrls() { return 'https://www.mediawiki.org/wiki/API:Move'; } - - public function getVersion() { - return __CLASS__ . ': $Id$'; - } } |