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.
This commit is contained in:
Brion Vibber 2009-01-01 00:05:08 +00:00
parent 49105885dc
commit c5d575e091
2 changed files with 10 additions and 5 deletions

View file

@ -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 );
}
}

View file

@ -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();
}