From a997803cd6cf97da234e6d5b363e135806a7414b Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Tue, 29 Oct 2019 12:52:47 -0400 Subject: [PATCH] Deprecate Parser::replaceLinkHolders / replaceLinkHoldersText Because this method is used in the ImageMap extension, we can't immediately hard-deprecate replaceLinkHolders. Code search: https://codesearch.wmflabs.org/deployed/?q=replaceLinkHolders&i=nope&files=&repos= Bug: T236810 Change-Id: If02130ffc86d0d9db2a455efcd29641a8206f0a0 (cherry picked from commit 023bb7677fa93b97e155969bacc4ef8be2410b3c) --- RELEASE-NOTES-1.34 | 4 +++- includes/parser/Parser.php | 31 ++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index 59e50d58e6..f3527ed52b 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -640,7 +640,9 @@ because of Phabricator reports. doHeadings, doAllQuotes, replaceExternalLinks, replaceInternalLinks, replaceInternalLinks2, getVariableValue, initialiseVariables, formatHeadings, testPst, testPreprocess, testSrvus, areSubpagesAllowed, maybeDoSubpageLink, - splitWhitespace, createAssocArgs. + splitWhitespace, createAssocArgs, armorLinks, makeKnownLinkHolder, + getImageParams, parseLinkParameter, stripAltText, replaceLinkHolders, + replaceLinkHoldersText. === 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 2147f2f350..798b2a8432 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1548,7 +1548,7 @@ class Parser { $text = $this->doBlockLevels( $text, $linestart ); - $this->replaceLinkHolders( $text ); + $this->replaceLinkHoldersPrivate( $text ); /** * The input doesn't get language converted if @@ -4602,7 +4602,7 @@ class Parser { # turns into # link text with suffix # Do this before unstrip since link text can contain strip markers - $safeHeadline = $this->replaceLinkHoldersText( $headline ); + $safeHeadline = $this->replaceLinkHoldersTextPrivate( $headline ); # Avoid insertion of weird stuff like by expanding the relevant sections $safeHeadline = $this->mStripState->unstripBoth( $safeHeadline ); @@ -5316,8 +5316,20 @@ class Parser { * * @param string &$text * @param int $options + * @deprecated since 1.34; should not be used outside parser class. */ public function replaceLinkHolders( &$text, $options = 0 ) { + $this->replaceLinkHoldersPrivate( $text, $options ); + } + + /** + * Replace "" link placeholders with actual links, in the buffer + * Placeholders created in Linker::link() + * + * @param string &$text + * @param int $options + */ + private function replaceLinkHoldersPrivate( &$text, $options = 0 ) { $this->mLinkHolders->replace( $text ); } @@ -5327,8 +5339,21 @@ class Parser { * * @param string $text * @return string + * @deprecated since 1.34; should not be used outside parser class. */ public function replaceLinkHoldersText( $text ) { + wfDeprecated( __METHOD__, '1.34' ); + return $this->replaceLinkHoldersTextPrivate( $text ); + } + + /** + * Replace "" link placeholders with plain text of links + * (not HTML-formatted). + * + * @param string $text + * @return string + */ + private function replaceLinkHoldersTextPrivate( $text ) { return $this->mLinkHolders->replaceText( $text ); } @@ -5820,7 +5845,7 @@ class Parser { if ( $holders ) { $tooltip = $holders->replaceText( $caption ); } else { - $tooltip = $this->replaceLinkHoldersText( $caption ); + $tooltip = $this->replaceLinkHoldersTextPrivate( $caption ); } # make sure there are no placeholders in thumbnail attributes -- 2.20.1