Deprecate Parser::replaceLinkHolders / replaceLinkHoldersText
[lhc/web/wiklou.git] / includes / parser / Parser.php
index d15288a..798b2a8 100644 (file)
@@ -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
@@ -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 );
        }
 
@@ -3227,8 +3236,10 @@ class Parser {
         * @param string $s
         *
         * @return array
+        * @deprecated since 1.34; appears to be unused.
         */
        public static function splitWhitespace( $s ) {
+               wfDeprecated( __METHOD__, '1.34' );
                $ltrimmed = ltrim( $s );
                $w1 = substr( $s, 0, strlen( $s ) - strlen( $ltrimmed ) );
                $trimmed = rtrim( $ltrimmed );
@@ -3291,8 +3302,10 @@ class Parser {
         * @param array $args
         *
         * @return array
+        * @deprecated since 1.34; appears to be unused in core.
         */
        public static function createAssocArgs( $args ) {
+               wfDeprecated( __METHOD__, '1.34' );
                $assocArgs = [];
                $index = 1;
                foreach ( $args as $arg ) {
@@ -3504,7 +3517,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();
@@ -4587,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 <math> by expanding the relevant sections
                        $safeHeadline = $this->mStripState->unstripBoth( $safeHeadline );
@@ -5301,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-->" 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 );
        }
 
@@ -5312,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-->" link placeholders with plain text of links
+        * (not HTML-formatted).
+        *
+        * @param string $text
+        * @return string
+        */
+       private function replaceLinkHoldersTextPrivate( $text ) {
                return $this->mLinkHolders->replaceText( $text );
        }
 
@@ -5805,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