r45266 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45265‎ | r45266 | r45267 >
Date:00:05, 1 January 2009
Author:brion
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOutput.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -1843,13 +1843,10 @@
18441844 # FIXME: isAlwaysKnown() can be expensive for file links; we should really do
18451845 # batch file existence checks for NS_FILE and NS_MEDIA
18461846 if( $iw == '' && $nt->isAlwaysKnown() ) {
1847 - # Need to add file links to parser output here or else they won't end up
1848 - # in the pagelinks table later
1849 - if( $ns == NS_FILE ) {
1850 - $this->mOutput->addLink( $nt );
1851 - }
 1847+ $this->mOutput->addLink( $nt );
18521848 $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
18531849 } else {
 1850+ # Links will be added to the output link list after checking
18541851 $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix );
18551852 }
18561853 }
Index: trunk/phase3/includes/parser/ParserOutput.php
@@ -87,6 +87,14 @@
8888 function addLink( $title, $id = null ) {
8989 $ns = $title->getNamespace();
9090 $dbk = $title->getDBkey();
 91+ if ( $ns == NS_MEDIA ) {
 92+ // Normalize this pseudo-alias if it makes it down here...
 93+ $ns = NS_FILE;
 94+ } elseif( $ns == NS_SPECIAL ) {
 95+ // We don't record Special: links currently
 96+ // It might actually be wise to, but we'd need to do some normalization.
 97+ return;
 98+ }
9199 if ( !isset( $this->mLinks[$ns] ) ) {
92100 $this->mLinks[$ns] = array();
93101 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r45656(bug 16965) Follow-up to r45266, also don't record self-links, such as those ...mrzman03:42, 11 January 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44524followup to r44520: simplify various bits by removing checks now made redundantvyznev04:14, 13 December 2008
r45174(bug 16806) Fix regression from r44524 that caused links to files to not get ...mrzman05:34, 30 December 2008

Status & tagging log