Merge "ApiMove: Fix fatal when attempting to move to a namespace with no talkpages"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 21 Dec 2016 00:58:03 +0000 (00:58 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 21 Dec 2016 00:58:03 +0000 (00:58 +0000)
includes/api/ApiMove.php

index 7c8aa90..18e582d 100644 (file)
@@ -59,7 +59,7 @@ class ApiMove extends ApiBase {
                if ( !$toTitle || $toTitle->isExternal() ) {
                        $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['to'] ) ] );
                }
-               $toTalk = $toTitle->getTalkPage();
+               $toTalk = $toTitle->canTalk() ? $toTitle->getTalkPage() : null;
 
                if ( $toTitle->getNamespace() == NS_FILE
                        && !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle )
@@ -100,7 +100,7 @@ class ApiMove extends ApiBase {
                $r['moveoverredirect'] = $toTitleExists;
 
                // Move the talk page
-               if ( $params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
+               if ( $params['movetalk'] && $toTalk && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
                        $toTalkExists = $toTalk->exists();
                        $status = $this->movePage( $fromTalk, $toTalk, $params['reason'], !$params['noredirect'] );
                        if ( $status->isOK() ) {