Index: trunk/phase3/includes/parser/LinkHolderArray.php |
— | — | @@ -166,8 +166,6 @@ |
167 | 167 | $output->addLink( $title, $id ); |
168 | 168 | } elseif ( $linkCache->isBadLink( $pdbk ) ) { |
169 | 169 | $colours[$pdbk] = 'new'; |
170 | | - } elseif ( $title->getNamespace() == NS_SPECIAL && !SpecialPage::exists( $pdbk ) ) { |
171 | | - $colours[$pdbk] = 'new'; |
172 | 170 | } else { |
173 | 171 | # Not in the link cache, add it to the query |
174 | 172 | if ( !isset( $current ) ) { |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -1813,14 +1813,15 @@ |
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | # Self-link checking |
1817 | | - if( $nt->getFragment() === '' && $nt->getNamespace() != NS_SPECIAL ) { |
| 1817 | + if( $nt->getFragment() === '' && $ns != NS_SPECIAL ) { |
1818 | 1818 | if( in_array( $nt->getPrefixedText(), $selflink, true ) ) { |
1819 | 1819 | $s .= $prefix . $sk->makeSelfLinkObj( $nt, $text, '', $trail ); |
1820 | 1820 | continue; |
1821 | 1821 | } |
1822 | 1822 | } |
1823 | 1823 | |
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 |
1825 | 1826 | if( $ns == NS_MEDIA ) { |
1826 | 1827 | # Give extensions a chance to select the file revision for us |
1827 | 1828 | $skip = $time = false; |
— | — | @@ -1834,25 +1835,18 @@ |
1835 | 1836 | $s .= $prefix . $this->armorLinks( $link ) . $trail; |
1836 | 1837 | $this->mOutput->addImage( $nt->getDBkey() ); |
1837 | 1838 | 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 | | - } |
1855 | 1839 | } |
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 | + } |
1857 | 1851 | } |
1858 | 1852 | wfProfileOut( __METHOD__ ); |
1859 | 1853 | return $holders; |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -190,15 +190,7 @@ |
191 | 191 | # If we don't know whether the page exists, let's find out. |
192 | 192 | wfProfileIn( __METHOD__ . '-checkPageExistence' ); |
193 | 193 | 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() ) { |
203 | 195 | $options []= 'known'; |
204 | 196 | } else { |
205 | 197 | $options []= 'broken'; |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -3114,6 +3114,11 @@ |
3115 | 3115 | * misleadingly named. You probably just want to call isKnown(), which |
3116 | 3116 | * calls this function internally. |
3117 | 3117 | * |
| 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 | + * |
3118 | 3123 | * @return \type{\bool} TRUE or FALSE |
3119 | 3124 | */ |
3120 | 3125 | public function isAlwaysKnown() { |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -594,8 +594,7 @@ |
595 | 595 | if( $selected ) { |
596 | 596 | $classes[] = 'selected'; |
597 | 597 | } |
598 | | - if( $checkEdit && !$title->isAlwaysKnown() && $title->getArticleId() == 0 && |
599 | | - !($title->getNamespace() == NS_FILE && wfFindFile( $title )) ) { |
| 598 | + if( $checkEdit && !$title->isKnown() ) { |
600 | 599 | $classes[] = 'new'; |
601 | 600 | $query = 'action=edit'; |
602 | 601 | } |
— | — | @@ -696,7 +695,7 @@ |
697 | 696 | 'href' => $this->mTitle->getLocalUrl( 'action=edit§ion=new' ) |
698 | 697 | ); |
699 | 698 | } |
700 | | - } elseif ( $this->mTitle->exists() || $this->mTitle->isAlwaysKnown() ) { |
| 699 | + } elseif ( $this->mTitle->isKnown() ) { |
701 | 700 | $content_actions['viewsource'] = array( |
702 | 701 | 'class' => ($action == 'edit') ? 'selected' : false, |
703 | 702 | 'text' => wfMsg('viewsource'), |
Index: trunk/phase3/includes/FakeTitle.php |
— | — | @@ -77,6 +77,7 @@ |
78 | 78 | function equals() { $this->error(); } |
79 | 79 | function exists() { $this->error(); } |
80 | 80 | function isAlwaysKnown() { $this->error(); } |
| 81 | + function isKnown() { $this->error(); } |
81 | 82 | function touchLinks() { $this->error(); } |
82 | 83 | function trackbackURL() { $this->error(); } |
83 | 84 | function trackbackRDF() { $this->error(); } |