Merge "Parser: Use 'Special:Badtitle/Parser' instead of 'NO TITLE'"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 26 Sep 2019 14:15:53 +0000 (14:15 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 26 Sep 2019 14:15:53 +0000 (14:15 +0000)
1  2 
includes/parser/Parser.php

@@@ -411,10 -411,8 +411,10 @@@ class Parser 
         */
        public function __destruct() {
                if ( isset( $this->mLinkHolders ) ) {
 +                      // @phan-suppress-next-line PhanTypeObjectUnsetDeclaredProperty
                        unset( $this->mLinkHolders );
                }
 +              // @phan-suppress-next-line PhanTypeSuspiciousNonTraversableForeach
                foreach ( $this as $name => $value ) {
                        unset( $this->$name );
                }
         */
        public function setTitle( $t ) {
                if ( !$t ) {
-                       $t = Title::newFromText( 'NO TITLE' );
+                       $t = Title::makeTitle( NS_SPECIAL, 'Badtitle/Parser' );
                }
  
                if ( $t->hasFragment() ) {
         */
        public function replaceExternalLinks( $text ) {
                $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
 +              // @phan-suppress-next-line PhanTypeComparisonFromArray See phan issue #3161
                if ( $bits === false ) {
                        throw new MWException( "PCRE needs to be compiled with "
                                . "--enable-unicode-properties in order for MediaWiki to function" );
                $line = $a->current(); # Workaround for broken ArrayIterator::next() that returns "void"
                $s = substr( $s, 1 );
  
 +              if ( is_null( $this->mTitle ) ) {
 +                      throw new MWException( __METHOD__ . ": \$this->mTitle is null\n" );
 +              }
 +              $nottalk = !$this->mTitle->isTalkPage();
 +
                $useLinkPrefixExtension = $this->getTargetLanguage()->linkPrefixExtension();
                $e2 = null;
                if ( $useLinkPrefixExtension ) {
                        # e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched
                        $charset = $this->contLang->linkPrefixCharset();
                        $e2 = "/^((?>.*[^$charset]|))(.+)$/sDu";
 -              }
 -
 -              if ( is_null( $this->mTitle ) ) {
 -                      throw new MWException( __METHOD__ . ": \$this->mTitle is null\n" );
 -              }
 -              $nottalk = !$this->mTitle->isTalkPage();
 -
 -              if ( $useLinkPrefixExtension ) {
                        $m = [];
                        if ( preg_match( $e2, $s, $m ) ) {
                                $first_prefix = $m[2];
         */
        private static function normalizeSectionName( $text ) {
                # T90902: ensure the same normalization is applied for IDs as to links
 +              /** @var MediaWikiTitleCodec $titleParser */
                $titleParser = MediaWikiServices::getInstance()->getTitleParser();
 +              '@phan-var MediaWikiTitleCodec $titleParser';
                try {
  
                        $parts = $titleParser->splitTitleString( "#$text" );