# If we don't know whether the page exists, let's find out.
wfProfileIn( __METHOD__ . '-checkPageExistence' );
if( !in_array( 'known', $options ) and !in_array( 'broken', $options ) ) {
- if( $target->getNamespace() == NS_SPECIAL ) {
- if( SpecialPage::exists( $target->getDBKey() ) ) {
- $options []= 'known';
- } else {
- $options []= 'broken';
- }
- } elseif( $target->isAlwaysKnown() or
- ($target->getPrefixedText() == '' and $target->getFragment() != '')
- or $target->exists() ) {
+ if( $target->isKnown() ) {
$options []= 'known';
} else {
$options []= 'broken';
if( $selected ) {
$classes[] = 'selected';
}
- if( $checkEdit && !$title->isAlwaysKnown() && $title->getArticleId() == 0 &&
- !($title->getNamespace() == NS_FILE && wfFindFile( $title )) ) {
+ if( $checkEdit && !$title->isKnown() ) {
$classes[] = 'new';
$query = 'action=edit';
}
'href' => $this->mTitle->getLocalUrl( 'action=edit§ion=new' )
);
}
- } elseif ( $this->mTitle->exists() || $this->mTitle->isAlwaysKnown() ) {
+ } elseif ( $this->mTitle->isKnown() ) {
$content_actions['viewsource'] = array(
'class' => ($action == 'edit') ? 'selected' : false,
'text' => wfMsg('viewsource'),
* misleadingly named. You probably just want to call isKnown(), which
* calls this function internally.
*
+ * (ISSUE: Most of these checks are cheap, but the file existence check
+ * can potentially be quite expensive. Including it here fixes a lot of
+ * existing code, but we might want to add an optional parameter to skip
+ * it and any other expensive checks.)
+ *
* @return \type{\bool} TRUE or FALSE
*/
public function isAlwaysKnown() {
}
# Self-link checking
- if( $nt->getFragment() === '' && $nt->getNamespace() != NS_SPECIAL ) {
+ if( $nt->getFragment() === '' && $ns != NS_SPECIAL ) {
if( in_array( $nt->getPrefixedText(), $selflink, true ) ) {
$s .= $prefix . $sk->makeSelfLinkObj( $nt, $text, '', $trail );
continue;
}
}
- # Special and Media are pseudo-namespaces; no pages actually exist in them
+ # NS_MEDIA is a pseudo-namespace for linking directly to a file
+ # FIXME: Should do batch file existence checks, see comment below
if( $ns == NS_MEDIA ) {
# Give extensions a chance to select the file revision for us
$skip = $time = false;
$s .= $prefix . $this->armorLinks( $link ) . $trail;
$this->mOutput->addImage( $nt->getDBkey() );
continue;
- } elseif( $ns == NS_SPECIAL ) {
- if( SpecialPage::exists( $nt->getDBkey() ) ) {
- $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
- } else {
- $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix );
- }
- continue;
- } elseif( $ns == NS_FILE ) {
- $img = wfFindFile( $nt );
- if( $img ) {
- // Force a blue link if the file exists; may be a remote
- // upload on the shared repository, and we want to see its
- // auto-generated page.
- $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
- $this->mOutput->addLink( $nt );
- continue;
- }
}
- $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix );
+
+ # Some titles, such as valid special pages or files in foreign repos, should
+ # be shown as bluelinks even though they're not included in the page table
+ #
+ # FIXME: isAlwaysKnown() can be expensive for file links; we should really do
+ # batch file existence checks for NS_FILE and NS_MEDIA
+ if( $nt->isAlwaysKnown() ) {
+ $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
+ } else {
+ $s .= $holders->makeHolder( $nt, $text, '', $trail, $prefix );
+ }
}
wfProfileOut( __METHOD__ );
return $holders;