Use ->getTitle() instead of ->mTitle to get the title from Parser
authorFomafix <fomafix@googlemail.com>
Tue, 27 Aug 2019 10:29:39 +0000 (12:29 +0200)
committerFomafix <fomafix@googlemail.com>
Tue, 27 Aug 2019 10:29:39 +0000 (12:29 +0200)
This allows to make mTitle a private property.

Change-Id: If953546cf4bb0324e4ae41d2195254c37c0ad3b4

includes/parser/CoreParserFunctions.php
includes/parser/PPFrame_DOM.php
includes/parser/PPFrame_Hash.php

index a7916c5..e1f4f38 100644 (file)
@@ -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()
                ) {
index 452bab1..e3c12eb 100644 (file)
@@ -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;
index 845ec73..f38cb06 100644 (file)
@@ -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;