*
* @param mixed $s
* @param integer $threshold user defined threshold
- * @return string $colour CSS class
+ * @return string CSS class
*/
function getLinkColour( $s, $threshold ) {
if( $s == false ) {
}
$colour = '';
- if ( $s->page_is_redirect ) {
+ if ( !empty( $s->page_is_redirect ) ) {
# Page is a redirect
$colour = 'mw-redirect';
} elseif ( $threshold > 0 && $s->page_len < $threshold && Namespace::isContent( $s->page_namespace ) ) {
} else {
wfProfileIn( __METHOD__.'-immediate' );
- # Handles links to special pages wich do not exist in the database:
+ # Handles links to special pages which do not exist in the database:
if( $nt->getNamespace() == NS_SPECIAL ) {
if( SpecialPage::exists( $nt->getDBkey() ) ) {
$retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
} else {
$colour = '';
if ( $nt->isContentPage() ) {
+ # FIXME: This is stupid, we should combine this query with
+ # the Title::getArticleID() query above.
$threshold = $wgUser->getOption('stubthreshold');
- if ( $threshold > 0 ) {
- $dbr = wfGetDB( DB_SLAVE );
- $s = $dbr->selectRow(
- array( 'page' ),
- array( 'page_len', 'page_is_redirect', 'page_namespace' ),
- array( 'page_id' => $aid ), __METHOD__ ) ;
- $colour = $this->getLinkColour( $s, $threshold );
- }
+ $dbr = wfGetDB( DB_SLAVE );
+ $s = $dbr->selectRow(
+ array( 'page' ),
+ array( 'page_len', 'page_is_redirect', 'page_namespace' ),
+ array( 'page_id' => $aid ), __METHOD__ ) ;
+ $colour = $this->getLinkColour( $s, $threshold );
}
$retVal = $this->makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix );
}
# Not in the link cache, add it to the query
if ( !isset( $current ) ) {
$current = $ns;
- $query = "SELECT page_id, page_namespace, page_title";
+ $query = "SELECT page_id, page_namespace, page_title, page_is_redirect";
if ( $threshold > 0 ) {
- $query .= ', page_len, page_is_redirect';
+ $query .= ', page_len';
}
$query .= " FROM $page WHERE (page_namespace=$ns AND page_title IN(";
} elseif ( $current != $ns ) {
// construct query
$titleClause = $linkBatch->constructSet('page', $dbr);
- $variantQuery = "SELECT page_id, page_namespace, page_title";
+ $variantQuery = "SELECT page_id, page_namespace, page_title, page_is_redirect";
if ( $threshold > 0 ) {
- $variantQuery .= ', page_len, page_is_redirect';
+ $variantQuery .= ', page_len';
}
$variantQuery .= " FROM $page WHERE $titleClause";