From: C. Scott Ananian Date: Tue, 29 Oct 2019 07:32:44 +0000 (-0400) Subject: Deprecate Parser::areSubpagesAllowed() / Parser::maybeDoSubpageLink() X-Git-Tag: 1.34.0-rc.1~13 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices//%27ecrire/admin_repair.php3/%27?a=commitdiff_plain;h=0974c515c10806f37d9e8e388740ad3a83bd8f5b;p=lhc%2Fweb%2Fwiklou.git Deprecate Parser::areSubpagesAllowed() / Parser::maybeDoSubpageLink() 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) --- diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index aa974817f0..5fbd44451c 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -639,7 +639,7 @@ because of Phabricator reports. 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 diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index d15288af90..c5dd811c8a 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2436,7 +2436,10 @@ class Parser { $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() ) { @@ -2509,7 +2512,9 @@ class Parser { # Make subpage if necessary if ( $useSubpages ) { - $link = $this->maybeDoSubpageLink( $origLink, $text ); + $link = Linker::normalizeSubpageLink( + $this->mTitle, $origLink, $text + ); } else { $link = $origLink; } @@ -2734,9 +2739,11 @@ class Parser { /** * 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 + wfDeprecated( __METHOD__, '1.34' ); 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 + * @deprecated since 1.34; should not be used outside parser class. */ public function maybeDoSubpageLink( $target, &$text ) { + wfDeprecated( __METHOD__, '1.34' ); return Linker::normalizeSubpageLink( $this->mTitle, $target, $text ); } @@ -3504,7 +3513,9 @@ class Parser { $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();