From d2b0f2960b654ea774326dcacf128894c75bc88c Mon Sep 17 00:00:00 2001 From: Fomafix Date: Tue, 27 Aug 2019 12:29:39 +0200 Subject: [PATCH] Use ->getTitle() instead of ->mTitle to get the title from Parser This allows to make mTitle a private property. Change-Id: If953546cf4bb0324e4ae41d2195254c37c0ad3b4 --- includes/parser/CoreParserFunctions.php | 17 ++++------------- includes/parser/PPFrame_DOM.php | 2 +- includes/parser/PPFrame_Hash.php | 2 +- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index a7916c5796..e1f4f38a59 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -434,7 +434,7 @@ class CoreParserFunctions { if ( !$wgRestrictDisplayTitle || ( $title instanceof Title && !$title->hasFragment() - && $title->equals( $parser->mTitle ) ) + && $title->equals( $parser->getTitle() ) ) ) { $old = $parser->mOutput->getProperty( 'displaytitle' ); if ( $old === false || $arg !== 'displaytitle_noreplace' ) { @@ -845,10 +845,7 @@ class CoreParserFunctions { * @return string */ public static function protectionlevel( $parser, $type = '', $title = '' ) { - $titleObject = Title::newFromText( $title ); - if ( !( $titleObject instanceof Title ) ) { - $titleObject = $parser->mTitle; - } + $titleObject = Title::newFromText( $title ) ?? $parser->getTitle(); if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) { $restrictions = $titleObject->getRestrictions( strtolower( $type ) ); # Title::getRestrictions returns an array, its possible it may have @@ -871,10 +868,7 @@ class CoreParserFunctions { * @return string */ public static function protectionexpiry( $parser, $type = '', $title = '' ) { - $titleObject = Title::newFromText( $title ); - if ( !( $titleObject instanceof Title ) ) { - $titleObject = $parser->mTitle; - } + $titleObject = Title::newFromText( $title ) ?? $parser->getTitle(); if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) { $expiry = $titleObject->getRestrictionExpiry( strtolower( $type ) ); // getRestrictionExpiry() returns false on invalid type; trying to @@ -1377,10 +1371,7 @@ class CoreParserFunctions { * @since 1.23 */ public static function cascadingsources( $parser, $title = '' ) { - $titleObject = Title::newFromText( $title ); - if ( !( $titleObject instanceof Title ) ) { - $titleObject = $parser->mTitle; - } + $titleObject = Title::newFromText( $title ) ?? $parser->getTitle(); if ( $titleObject->areCascadeProtectionSourcesLoaded() || $parser->incrementExpensiveFunctionCount() ) { diff --git a/includes/parser/PPFrame_DOM.php b/includes/parser/PPFrame_DOM.php index 452bab1259..e3c12eb597 100644 --- a/includes/parser/PPFrame_DOM.php +++ b/includes/parser/PPFrame_DOM.php @@ -70,7 +70,7 @@ class PPFrame_DOM implements PPFrame { public function __construct( $preprocessor ) { $this->preprocessor = $preprocessor; $this->parser = $preprocessor->parser; - $this->title = $this->parser->mTitle; + $this->title = $this->parser->getTitle(); $this->titleCache = [ $this->title ? $this->title->getPrefixedDBkey() : false ]; $this->loopCheckHash = []; $this->depth = 0; diff --git a/includes/parser/PPFrame_Hash.php b/includes/parser/PPFrame_Hash.php index 845ec73c7e..f38cb06968 100644 --- a/includes/parser/PPFrame_Hash.php +++ b/includes/parser/PPFrame_Hash.php @@ -69,7 +69,7 @@ class PPFrame_Hash implements PPFrame { public function __construct( $preprocessor ) { $this->preprocessor = $preprocessor; $this->parser = $preprocessor->parser; - $this->title = $this->parser->mTitle; + $this->title = $this->parser->getTitle(); $this->titleCache = [ $this->title ? $this->title->getPrefixedDBkey() : false ]; $this->loopCheckHash = []; $this->depth = 0; -- 2.20.1