Follow-up to r45174: (bug 16806) Fix regression from r44524 that caused links to...
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 1 Jan 2009 00:05:08 +0000 (00:05 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 1 Jan 2009 00:05:08 +0000 (00:05 +0000)
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.

includes/parser/Parser.php
includes/parser/ParserOutput.php

index a2f9b9a..da32c00 100644 (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 );
                        }
                }
index 3595138..35cb5c9 100644 (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();
                }