Deprecate Parser::areSubpagesAllowed() / Parser::maybeDoSubpageLink()
authorC. Scott Ananian <cscott@cscott.net>
Tue, 29 Oct 2019 07:32:44 +0000 (03:32 -0400)
committerJames D. Forrester <jforrester@wikimedia.org>
Wed, 30 Oct 2019 21:34:47 +0000 (14:34 -0700)
These are unused outside the Parser and are so short it's not worth
renaming them to make them private; just hard-deprecate the methods
and inline the implementation in the small # of places they appear.

Code search:
https://codesearch.wmflabs.org/deployed/?q=areSubpagesAllowed%7CmaybeDoSubpageLink&i=nope&files=&repos=

Bug: T236810
Change-Id: Ia06c65409a3158b083bcc59c9f6e347945b375c0
(cherry picked from commit dcae22c8fa46822148dc5fd87018acb385bf4c91)

RELEASE-NOTES-1.34
includes/parser/Parser.php

index aa97481..5fbd444 100644 (file)
@@ -639,7 +639,7 @@ because of Phabricator reports.
   reasons and have been deprecated: doMagicLinks, doDoubleUnderscore,
   doHeadings, doAllQuotes, replaceExternalLinks, replaceInternalLinks,
   replaceInternalLinks2, getVariableValue, initialiseVariables, formatHeadings,
   reasons and have been deprecated: doMagicLinks, doDoubleUnderscore,
   doHeadings, doAllQuotes, replaceExternalLinks, replaceInternalLinks,
   replaceInternalLinks2, getVariableValue, initialiseVariables, formatHeadings,
-  testPst, testPreprocess, testSrvus.
+  testPst, testPreprocess, testSrvus, areSubpagesAllowed, maybeDoSubpageLink.
 
 === Other changes in 1.34 ===
 * Added option to specify "Various authors" as author in extension credits using
 
 === Other changes in 1.34 ===
 * Added option to specify "Various authors" as author in extension credits using
index d15288a..c5dd811 100644 (file)
@@ -2436,7 +2436,10 @@ class Parser {
                        $prefix = '';
                }
 
                        $prefix = '';
                }
 
-               $useSubpages = $this->areSubpagesAllowed();
+               # Some namespaces don't allow subpages
+               $useSubpages = $this->nsInfo->hasSubpages(
+                       $this->mTitle->getNamespace()
+               );
 
                # Loop for each link
                for ( ; $line !== false && $line !== null; $a->next(), $line = $a->current() ) {
 
                # Loop for each link
                for ( ; $line !== false && $line !== null; $a->next(), $line = $a->current() ) {
@@ -2509,7 +2512,9 @@ class Parser {
 
                        # Make subpage if necessary
                        if ( $useSubpages ) {
 
                        # Make subpage if necessary
                        if ( $useSubpages ) {
-                               $link = $this->maybeDoSubpageLink( $origLink, $text );
+                               $link = Linker::normalizeSubpageLink(
+                                       $this->mTitle, $origLink, $text
+                               );
                        } else {
                                $link = $origLink;
                        }
                        } else {
                                $link = $origLink;
                        }
@@ -2734,9 +2739,11 @@ class Parser {
        /**
         * Return true if subpage links should be expanded on this page.
         * @return bool
        /**
         * Return true if subpage links should be expanded on this page.
         * @return bool
+        * @deprecated since 1.34; should not be used outside parser class.
         */
        public function areSubpagesAllowed() {
                # Some namespaces don't allow subpages
         */
        public function areSubpagesAllowed() {
                # Some namespaces don't allow subpages
+               wfDeprecated( __METHOD__, '1.34' );
                return $this->nsInfo->hasSubpages( $this->mTitle->getNamespace() );
        }
 
                return $this->nsInfo->hasSubpages( $this->mTitle->getNamespace() );
        }
 
@@ -2747,8 +2754,10 @@ class Parser {
         * @param string &$text The link text, modified as necessary
         * @return string The full name of the link
         * @private
         * @param string &$text The link text, modified as necessary
         * @return string The full name of the link
         * @private
+        * @deprecated since 1.34; should not be used outside parser class.
         */
        public function maybeDoSubpageLink( $target, &$text ) {
         */
        public function maybeDoSubpageLink( $target, &$text ) {
+               wfDeprecated( __METHOD__, '1.34' );
                return Linker::normalizeSubpageLink( $this->mTitle, $target, $text );
        }
 
                return Linker::normalizeSubpageLink( $this->mTitle, $target, $text );
        }
 
@@ -3504,7 +3513,9 @@ class Parser {
                        $ns = NS_TEMPLATE;
                        # Split the title into page and subpage
                        $subpage = '';
                        $ns = NS_TEMPLATE;
                        # Split the title into page and subpage
                        $subpage = '';
-                       $relative = $this->maybeDoSubpageLink( $part1, $subpage );
+                       $relative = Linker::normalizeSubpageLink(
+                               $this->mTitle, $part1, $subpage
+                       );
                        if ( $part1 !== $relative ) {
                                $part1 = $relative;
                                $ns = $this->mTitle->getNamespace();
                        if ( $part1 !== $relative ) {
                                $part1 = $relative;
                                $ns = $this->mTitle->getNamespace();