From 844d724621693faefe99311e882396c78e31189f Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 29 Aug 2017 12:36:33 -0700 Subject: [PATCH] Avoid using deprecated Title::canTalk() Change-Id: Ibd224f9de595435524e683262882c9ebf2761abf --- includes/Title.php | 2 +- includes/api/ApiMove.php | 2 +- includes/parser/CoreParserFunctions.php | 12 ++++++------ includes/parser/Parser.php | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 05f85fa47d..b6a1689c71 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1324,7 +1324,7 @@ class Title implements LinkTarget { * * @since 1.30 * - * @return Title The object for the talk page, + * @return Title|null The object for the talk page, * or null if no associated talk page can exist, according to canHaveTalkPage(). */ public function getTalkPageIfDefined() { diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 1fb034f85f..e7b280803e 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -59,7 +59,7 @@ class ApiMove extends ApiBase { if ( !$toTitle || $toTitle->isExternal() ) { $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['to'] ) ] ); } - $toTalk = $toTitle->canTalk() ? $toTitle->getTalkPage() : null; + $toTalk = $toTitle->getTalkPageIfDefined(); if ( $toTitle->getNamespace() == NS_FILE && !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle ) diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index f0f1f5fa97..3d262628be 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -582,14 +582,14 @@ class CoreParserFunctions { } public static function talkspace( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) { + if ( is_null( $t ) || !$t->canHaveTalkPage() ) { return ''; } return str_replace( '_', ' ', $t->getTalkNsText() ); } public static function talkspacee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) { + if ( is_null( $t ) || !$t->canHaveTalkPage() ) { return ''; } return wfUrlencode( $t->getTalkNsText() ); @@ -632,14 +632,14 @@ class CoreParserFunctions { } public static function fullpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) { + if ( is_null( $t ) || !$t->canHaveTalkPage() ) { return ''; } return wfEscapeWikiText( $t->getPrefixedText() ); } public static function fullpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) { + if ( is_null( $t ) || !$t->canHaveTalkPage() ) { return ''; } return wfEscapeWikiText( $t->getPrefixedURL() ); @@ -688,14 +688,14 @@ class CoreParserFunctions { } public static function talkpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) { + if ( is_null( $t ) || !$t->canHaveTalkPage() ) { return ''; } return wfEscapeWikiText( $t->getTalkPage()->getPrefixedText() ); } public static function talkpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); - if ( is_null( $t ) || !$t->canTalk() ) { + if ( is_null( $t ) || !$t->canHaveTalkPage() ) { return ''; } return wfEscapeWikiText( $t->getTalkPage()->getPrefixedURL() ); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 3f0e38f584..57e627e4aa 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2586,7 +2586,7 @@ class Parser { ) ) ); break; case 'talkpagename': - if ( $this->mTitle->canTalk() ) { + if ( $this->mTitle->canHaveTalkPage() ) { $talkPage = $this->mTitle->getTalkPage(); $value = wfEscapeWikiText( $talkPage->getPrefixedText() ); } else { @@ -2594,7 +2594,7 @@ class Parser { } break; case 'talkpagenamee': - if ( $this->mTitle->canTalk() ) { + if ( $this->mTitle->canHaveTalkPage() ) { $talkPage = $this->mTitle->getTalkPage(); $value = wfEscapeWikiText( $talkPage->getPrefixedURL() ); } else { @@ -2694,12 +2694,12 @@ class Parser { $value = $this->mTitle->getNamespace(); break; case 'talkspace': - $value = $this->mTitle->canTalk() + $value = $this->mTitle->canHaveTalkPage() ? str_replace( '_', ' ', $this->mTitle->getTalkNsText() ) : ''; break; case 'talkspacee': - $value = $this->mTitle->canTalk() ? wfUrlencode( $this->mTitle->getTalkNsText() ) : ''; + $value = $this->mTitle->canHaveTalkPage() ? wfUrlencode( $this->mTitle->getTalkNsText() ) : ''; break; case 'subjectspace': $value = str_replace( '_', ' ', $this->mTitle->getSubjectNsText() ); -- 2.20.1