diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index a2f9b9a6de6..da32c001197 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 35951387ddf..35cb5c922f2 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(); }