Merge "Add .pipeline/ with dev image variant"
[lhc/web/wiklou.git] / includes / parser / LinkHolderArray.php
index 66fd723..5eb799e 100644 (file)
@@ -48,6 +48,7 @@ class LinkHolderArray {
         * Reduce memory usage to reduce the impact of circular references
         */
        public function __destruct() {
+               // @phan-suppress-next-line PhanTypeSuspiciousNonTraversableForeach
                foreach ( $this as $name => $value ) {
                        unset( $this->$name );
                }
@@ -275,6 +276,7 @@ class LinkHolderArray {
 
        /**
         * Replace internal links
+        * @suppress SecurityCheck-XSS Gets confused with $entry['pdbk']
         * @param string &$text
         */
        protected function replaceInternal( &$text ) {
@@ -282,8 +284,6 @@ class LinkHolderArray {
                        return;
                }
 
-               global $wgContLang;
-
                $colours = [];
                $linkCache = MediaWikiServices::getInstance()->getLinkCache();
                $output = $this->parent->getOutput();
@@ -364,7 +364,7 @@ class LinkHolderArray {
                }
 
                # Do a second query for different language variants of links and categories
-               if ( $wgContLang->hasVariants() ) {
+               if ( $this->parent->getContentLanguage()->hasVariants() ) {
                        $this->doVariants( $colours );
                }
 
@@ -420,6 +420,7 @@ class LinkHolderArray {
        /**
         * Replace interwiki links
         * @param string &$text
+        * @suppress SecurityCheck-XSS Gets confused with $this->interwikis['pdbk']
         */
        protected function replaceInterwiki( &$text ) {
                if ( empty( $this->interwikis ) ) {
@@ -452,7 +453,6 @@ class LinkHolderArray {
         * @param array &$colours
         */
        protected function doVariants( &$colours ) {
-               global $wgContLang;
                $linkBatch = new LinkBatch();
                $variantMap = []; // maps $pdbkey_Variant => $keys (of link holders)
                $output = $this->parent->getOutput();
@@ -480,7 +480,8 @@ class LinkHolderArray {
                }
 
                // Now do the conversion and explode string to text of titles
-               $titlesAllVariants = $wgContLang->autoConvertToAllVariants( rtrim( $titlesToBeConverted, "\0" ) );
+               $titlesAllVariants = $this->parent->getContentLanguage()->
+                       autoConvertToAllVariants( rtrim( $titlesToBeConverted, "\0" ) );
                $allVariantsName = array_keys( $titlesAllVariants );
                foreach ( $titlesAllVariants as &$titlesVariant ) {
                        $titlesVariant = explode( "\0", $titlesVariant );
@@ -521,7 +522,7 @@ class LinkHolderArray {
                foreach ( $output->getCategoryLinks() as $category ) {
                        $categoryTitle = Title::makeTitleSafe( NS_CATEGORY, $category );
                        $linkBatch->addObj( $categoryTitle );
-                       $variants = $wgContLang->autoConvertToAllVariants( $category );
+                       $variants = $this->parent->getContentLanguage()->autoConvertToAllVariants( $category );
                        foreach ( $variants as $variant ) {
                                if ( $variant !== $category ) {
                                        $variantTitle = Title::makeTitleSafe( NS_CATEGORY, $variant );
@@ -632,8 +633,7 @@ class LinkHolderArray {
         * @private
         */
        public function replaceTextCallback( $matches ) {
-               $type = $matches[1];
-               $key = $matches[2];
+               list( , $type, $key ) = $matches;
                if ( $type == 'LINK' ) {
                        list( $ns, $index ) = explode( ':', $key, 2 );
                        if ( isset( $this->internals[$ns][$index]['text'] ) ) {