Follow-up I7d4bb90: Message tweak + add code comment
[lhc/web/wiklou.git] / includes / parser / Parser.php
index c27c51f..1548a9b 100644 (file)
@@ -710,7 +710,7 @@ class Parser {
                        $t = Title::newFromText( 'NO TITLE' );
                }
 
-               if ( strval( $t->getFragment() ) !== '' ) {
+               if ( $t->hasFragment() ) {
                        # Strip the fragment to avoid various odd effects
                        $this->mTitle = clone $t;
                        $this->mTitle->setFragment( '' );
@@ -1293,19 +1293,19 @@ class Parser {
                        if ( substr( $m[0], 0, 3 ) === 'RFC' ) {
                                $keyword = 'RFC';
                                $urlmsg = 'rfcurl';
-                               $CssClass = 'mw-magiclink-rfc';
+                               $cssClass = 'mw-magiclink-rfc';
                                $id = $m[4];
                        } elseif ( substr( $m[0], 0, 4 ) === 'PMID' ) {
                                $keyword = 'PMID';
                                $urlmsg = 'pubmedurl';
-                               $CssClass = 'mw-magiclink-pmid';
+                               $cssClass = 'mw-magiclink-pmid';
                                $id = $m[4];
                        } else {
                                throw new MWException( __METHOD__ . ': unrecognised match type "' .
                                        substr( $m[0], 0, 20 ) . '"' );
                        }
                        $url = wfMessage( $urlmsg, $id )->inContentLanguage()->text();
-                       return Linker::makeExternalLink( $url, "{$keyword} {$id}", true, $CssClass );
+                       return Linker::makeExternalLink( $url, "{$keyword} {$id}", true, $cssClass );
                } elseif ( isset( $m[5] ) && $m[5] !== '' ) {
                        # ISBN
                        $isbn = $m[5];
@@ -1684,6 +1684,7 @@ class Parser {
                wfProfileOut( __METHOD__ );
                return $s;
        }
+
        /**
         * Get the rel attribute for a particular external link.
         *
@@ -1703,6 +1704,7 @@ class Parser {
                }
                return null;
        }
+
        /**
         * Get an associative array of additional HTML attributes appropriate for a
         * particular external link.  This currently may include rel => nofollow
@@ -2120,7 +2122,7 @@ class Parser {
                        # Self-link checking. For some languages, variants of the title are checked in
                        # LinkHolderArray::doVariants() to allow batching the existence checks necessary
                        # for linking to a different variant.
-                       if ( $ns != NS_SPECIAL && $nt->equals( $this->mTitle ) && $nt->getFragment() === '' ) {
+                       if ( $ns != NS_SPECIAL && $nt->equals( $this->mTitle ) && !$nt->hasFragment() ) {
                                $s .= $prefix . Linker::makeSelfLinkObj( $nt, $text, '', $trail );
                                continue;
                        }
@@ -4148,6 +4150,10 @@ class Parser {
         * Add a tracking category, getting the title from a system message,
         * or print a debug message if the title is invalid.
         *
+        * Please add any message that you use with this function to
+        * $wgTrackingCategories. That way they will be listed on
+        * Special:TrackingCategories.
+        *
         * @param string $msg message key
         * @return Boolean: whether the addition was successful
         */
@@ -4594,14 +4600,13 @@ class Parser {
 
        /**
         * Pre-save transform helper function
-        * @private
         *
         * @param $text string
         * @param $user User
         *
         * @return string
         */
-       function pstPass2( $text, $user ) {
+       private function pstPass2( $text, $user ) {
                global $wgContLang;
 
                # Note: This is the timestamp saved as hardcoded wikitext to
@@ -5923,7 +5928,7 @@ class Parser {
 
                # Strip external link markup
                # @todo FIXME: Not tolerant to blank link text
-               # I.E. [http://www.mediawiki.org] will render as [1] or something depending
+               # I.E. [https://www.mediawiki.org] will render as [1] or something depending
                # on how many empty links there are on the page - need to figure that out.
                $text = preg_replace( '/\[(?i:' . $this->mUrlProtocols . ')([^ ]+?) ([^[]+)\]/', '$2', $text );