From 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 12 Aug 2013 09:28:15 +0200 Subject: Update to MediaWiki 1.21.1 --- includes/api/ApiMove.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'includes/api/ApiMove.php') diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 9d73562b..3e846e3b 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,9 +78,16 @@ 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 ) { $r['moveoverredirect'] = ''; } @@ -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$'; - } } -- cgit v1.2.3-54-g00ecf