Merge "Update weblinks in comments from HTTP to HTTPS"
[lhc/web/wiklou.git] / includes / parser / Parser.php
index d427cf9..3f703e3 100644 (file)
@@ -22,6 +22,7 @@
  */
 use MediaWiki\Linker\LinkRenderer;
 use MediaWiki\MediaWikiServices;
+use Wikimedia\ScopedCallback;
 
 /**
  * @defgroup Parser Parser
@@ -1445,6 +1446,7 @@ class Parser {
                                $keyword = 'RFC';
                                $urlmsg = 'rfcurl';
                                $cssClass = 'mw-magiclink-rfc';
+                               $trackingCat = 'magiclink-tracking-rfc';
                                $id = $m[5];
                        } elseif ( substr( $m[0], 0, 4 ) === 'PMID' ) {
                                if ( !$this->mOptions->getMagicPMIDLinks() ) {
@@ -1453,12 +1455,14 @@ class Parser {
                                $keyword = 'PMID';
                                $urlmsg = 'pubmedurl';
                                $cssClass = 'mw-magiclink-pmid';
+                               $trackingCat = 'magiclink-tracking-pmid';
                                $id = $m[5];
                        } else {
                                throw new MWException( __METHOD__ . ': unrecognised match type "' .
                                        substr( $m[0], 0, 20 ) . '"' );
                        }
                        $url = wfMessage( $urlmsg, $id )->inContentLanguage()->text();
+                       $this->addTrackingCategory( $trackingCat );
                        return Linker::makeExternalLink( $url, "{$keyword} {$id}", true, $cssClass, [], $this->mTitle );
                } elseif ( isset( $m[6] ) && $m[6] !== ''
                        && $this->mOptions->getMagicISBNLinks()
@@ -1472,6 +1476,7 @@ class Parser {
                                ' ' => '',
                                'x' => 'X',
                        ] );
+                       $this->addTrackingCategory( 'magiclink-tracking-isbn' );
                        return $this->getLinkRenderer()->makeKnownLink(
                                SpecialPage::getTitleFor( 'Booksources', $num ),
                                "ISBN $isbn",
@@ -3800,11 +3805,10 @@ class Parser {
                        return $attrText;
                }
 
+               // We can't safely check if the expansion for $content resulted in an
+               // error, because the content could happen to be the error string
+               // (T149622).
                $content = !isset( $params['inner'] ) ? null : $frame->expand( $params['inner'] );
-               if ( substr( $content, 0, $errorLen ) === $errorStr ) {
-                       // See above
-                       return $content;
-               }
 
                $marker = self::MARKER_PREFIX . "-$name-"
                        . sprintf( '%08X', $this->mMarkerIndex++ ) . self::MARKER_SUFFIX;