From: Brion Vibber Date: Thu, 1 Jan 2009 00:05:08 +0000 (+0000) Subject: Follow-up to r45174: (bug 16806) Fix regression from r44524 that caused links to... X-Git-Tag: 1.31.0-rc.0~43648 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=c5d575e091daa884761c820e3bbf700b9e69d3d5;p=lhc%2Fweb%2Fwiklou.git Follow-up to r45174: (bug 16806) Fix regression from r44524 that caused links to files to not get added to mLinks in ParserOutput, which caused them to not be included in LinksUpdate::LinksUpdate(), and not added to pagelinks. Fixes other cases broken by Parser's assumptions failing to hold after change in Title::isAlwaysKnown()'s behavior: * Links to invalid Special: pages were being recorded, but shouldn't * Links to valid MediaWiki: pages were no longer recorded Instead of the NS_FILE special-case in r45174, I'm just tossing *all* isAlwaysKnown links over to ParserOutput::addLink(), and letting the latter worry about what types of titles it won't record. Just for good measure, in case any NS_MEDIA titles make it into ParserOutput::addLink() they'll be normalized to NS_FILE. --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index a2f9b9a6de..da32c00119 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1843,13 +1843,10 @@ class Parser # FIXME: isAlwaysKnown() can be expensive for file links; we should really do # batch file existence checks for NS_FILE and NS_MEDIA if( $iw == '' && $nt->isAlwaysKnown() ) { - # Need to add file links to parser output here or else they won't end up - # in the pagelinks table later - if( $ns == NS_FILE ) { - $this->mOutput->addLink( $nt ); - } + $this->mOutput->addLink( $nt ); $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix ); } else { + # Links will be added to the output link list after checking $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix ); } } diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 35951387dd..35cb5c922f 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -87,6 +87,14 @@ class ParserOutput function addLink( $title, $id = null ) { $ns = $title->getNamespace(); $dbk = $title->getDBkey(); + if ( $ns == NS_MEDIA ) { + // Normalize this pseudo-alias if it makes it down here... + $ns = NS_FILE; + } elseif( $ns == NS_SPECIAL ) { + // We don't record Special: links currently + // It might actually be wise to, but we'd need to do some normalization. + return; + } if ( !isset( $this->mLinks[$ns] ) ) { $this->mLinks[$ns] = array(); }