r44524 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44523‎ | r44524 | r44525 >
Date:04:14, 13 December 2008
Author:vyznev
Status:resolved (Comments)
Tags:
Comment:
followup to r44520: simplify various bits by removing checks now made redundant
Modified paths:
  • /trunk/phase3/includes/FakeTitle.php (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/parser/LinkHolderArray.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/LinkHolderArray.php
@@ -166,8 +166,6 @@
167167 $output->addLink( $title, $id );
168168 } elseif ( $linkCache->isBadLink( $pdbk ) ) {
169169 $colours[$pdbk] = 'new';
170 - } elseif ( $title->getNamespace() == NS_SPECIAL && !SpecialPage::exists( $pdbk ) ) {
171 - $colours[$pdbk] = 'new';
172170 } else {
173171 # Not in the link cache, add it to the query
174172 if ( !isset( $current ) ) {
Index: trunk/phase3/includes/parser/Parser.php
@@ -1813,14 +1813,15 @@
18141814 }
18151815
18161816 # Self-link checking
1817 - if( $nt->getFragment() === '' && $nt->getNamespace() != NS_SPECIAL ) {
 1817+ if( $nt->getFragment() === '' && $ns != NS_SPECIAL ) {
18181818 if( in_array( $nt->getPrefixedText(), $selflink, true ) ) {
18191819 $s .= $prefix . $sk->makeSelfLinkObj( $nt, $text, '', $trail );
18201820 continue;
18211821 }
18221822 }
18231823
1824 - # Special and Media are pseudo-namespaces; no pages actually exist in them
 1824+ # NS_MEDIA is a pseudo-namespace for linking directly to a file
 1825+ # FIXME: Should do batch file existence checks, see comment below
18251826 if( $ns == NS_MEDIA ) {
18261827 # Give extensions a chance to select the file revision for us
18271828 $skip = $time = false;
@@ -1834,25 +1835,18 @@
18351836 $s .= $prefix . $this->armorLinks( $link ) . $trail;
18361837 $this->mOutput->addImage( $nt->getDBkey() );
18371838 continue;
1838 - } elseif( $ns == NS_SPECIAL ) {
1839 - if( SpecialPage::exists( $nt->getDBkey() ) ) {
1840 - $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
1841 - } else {
1842 - $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix );
1843 - }
1844 - continue;
1845 - } elseif( $ns == NS_FILE ) {
1846 - $img = wfFindFile( $nt );
1847 - if( $img ) {
1848 - // Force a blue link if the file exists; may be a remote
1849 - // upload on the shared repository, and we want to see its
1850 - // auto-generated page.
1851 - $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
1852 - $this->mOutput->addLink( $nt );
1853 - continue;
1854 - }
18551839 }
1856 - $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix );
 1840+
 1841+ # Some titles, such as valid special pages or files in foreign repos, should
 1842+ # be shown as bluelinks even though they're not included in the page table
 1843+ #
 1844+ # FIXME: isAlwaysKnown() can be expensive for file links; we should really do
 1845+ # batch file existence checks for NS_FILE and NS_MEDIA
 1846+ if( $nt->isAlwaysKnown() ) {
 1847+ $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
 1848+ } else {
 1849+ $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix );
 1850+ }
18571851 }
18581852 wfProfileOut( __METHOD__ );
18591853 return $holders;
Index: trunk/phase3/includes/Linker.php
@@ -190,15 +190,7 @@
191191 # If we don't know whether the page exists, let's find out.
192192 wfProfileIn( __METHOD__ . '-checkPageExistence' );
193193 if( !in_array( 'known', $options ) and !in_array( 'broken', $options ) ) {
194 - if( $target->getNamespace() == NS_SPECIAL ) {
195 - if( SpecialPage::exists( $target->getDBKey() ) ) {
196 - $options []= 'known';
197 - } else {
198 - $options []= 'broken';
199 - }
200 - } elseif( $target->isAlwaysKnown() or
201 - ($target->getPrefixedText() == '' and $target->getFragment() != '')
202 - or $target->exists() ) {
 194+ if( $target->isKnown() ) {
203195 $options []= 'known';
204196 } else {
205197 $options []= 'broken';
Index: trunk/phase3/includes/Title.php
@@ -3114,6 +3114,11 @@
31153115 * misleadingly named. You probably just want to call isKnown(), which
31163116 * calls this function internally.
31173117 *
 3118+ * (ISSUE: Most of these checks are cheap, but the file existence check
 3119+ * can potentially be quite expensive. Including it here fixes a lot of
 3120+ * existing code, but we might want to add an optional parameter to skip
 3121+ * it and any other expensive checks.)
 3122+ *
31183123 * @return \type{\bool} TRUE or FALSE
31193124 */
31203125 public function isAlwaysKnown() {
Index: trunk/phase3/includes/SkinTemplate.php
@@ -594,8 +594,7 @@
595595 if( $selected ) {
596596 $classes[] = 'selected';
597597 }
598 - if( $checkEdit && !$title->isAlwaysKnown() && $title->getArticleId() == 0 &&
599 - !($title->getNamespace() == NS_FILE && wfFindFile( $title )) ) {
 598+ if( $checkEdit && !$title->isKnown() ) {
600599 $classes[] = 'new';
601600 $query = 'action=edit';
602601 }
@@ -696,7 +695,7 @@
697696 'href' => $this->mTitle->getLocalUrl( 'action=edit&section=new' )
698697 );
699698 }
700 - } elseif ( $this->mTitle->exists() || $this->mTitle->isAlwaysKnown() ) {
 699+ } elseif ( $this->mTitle->isKnown() ) {
701700 $content_actions['viewsource'] = array(
702701 'class' => ($action == 'edit') ? 'selected' : false,
703702 'text' => wfMsg('viewsource'),
Index: trunk/phase3/includes/FakeTitle.php
@@ -77,6 +77,7 @@
7878 function equals() { $this->error(); }
7979 function exists() { $this->error(); }
8080 function isAlwaysKnown() { $this->error(); }
 81+ function isKnown() { $this->error(); }
8182 function touchLinks() { $this->error(); }
8283 function trackbackURL() { $this->error(); }
8384 function trackbackRDF() { $this->error(); }

Follow-up revisions

RevisionCommit summaryAuthorDate
r44542Fix interwiki link regression from r44524.vyznev21:14, 13 December 2008
r45174(bug 16806) Fix regression from r44524 that caused links to files to not get ...mrzman05:34, 30 December 2008
r45266Follow-up to r45174: (bug 16806) Fix regression from r44524 that caused links...brion00:05, 1 January 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44520(bug 5506) Make Title::isAlwaysKnown() return true for known special pages an...vyznev02:40, 13 December 2008

Comments

#Comment by IAlex (talk | contribs)   21:02, 13 December 2008

This revision seems to have caused a regression in with 5 parser tests:

  • Inline interwiki link [Introduced between 10-Dec-2008 18:21:04, 1.14alpha (r44388) and 13-Dec-2008 20:52:57, 1.14alpha (r44540)]
  • Inline interwiki link with empty title (bug 2372) [Introduced between 10-Dec-2008 18:21:04, 1.14alpha (r44388) and 13-Dec-2008 20:52:57, 1.14alpha (r44540)]
  • Interwiki link encoding conversion (bug 1636) [Introduced between 10-Dec-2008 18:21:04, 1.14alpha (r44388) and 13-Dec-2008 20:52:57, 1.14alpha (r44540)]
  • Interwiki link with fragment (bug 2130) [Introduced between 10-Dec-2008 18:21:04, 1.14alpha (r44388) and 13-Dec-2008 20:52:57, 1.14alpha (r44540)]
  • Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion [Introduced between 10-Dec-2008 18:21:04, 1.14alpha (r44388) and 13-Dec-2008 20:52:57, 1.14alpha (r44540)]

reverting this revision causes this 5 tests to pass.

#Comment by Mr.Z-man (talk | contribs)   21:04, 13 December 2008

looks like its dropping the classes from the links...

Running test Inline interwiki link... FAILED!
--- Expected ---
<p><a href="[http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity]" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
</p>
--- Actual ---
<p><a href="[http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity]" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
</p>
#Comment by IAlex (talk | contribs)   21:06, 13 December 2008

Note: it seems that class="extiw" is missing in links.

#Comment by Ilmari Karonen (talk | contribs)   21:15, 13 December 2008

Fixed in r44542, the tests now pass again.

Status & tagging log