From eee4d13325626f966be8b3e14a4468177e84b918 Mon Sep 17 00:00:00 2001 From: Platonides Date: Mon, 2 Aug 2010 15:53:22 +0000 Subject: [PATCH] Check the link color (stub, redirect) on just one place. Deprecate makeSizeLinkObj. The only usage is in CategoryPage, which we can change to link() without penalty, since the created Title is already loaded with its length. --- includes/CategoryPage.php | 2 +- includes/Linker.php | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index fb08ad8c41..2b6a4c1be1 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -236,7 +236,7 @@ class CategoryViewer { array(), array( 'known', 'noclasses' ) ) . '' - : $this->getSkin()->makeSizeLinkObj( $pageLength, $title ); + : $this->getSkin()->link( $title ); if ( $wgExperimentalCategorySort ) { $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstLetterForLists( $sortkey ) ); diff --git a/includes/Linker.php b/includes/Linker.php index 1a9e9cf876..2795a8b45b 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -112,7 +112,7 @@ class Linker { $colour = 'mw-redirect'; } elseif ( $threshold > 0 && $t->exists() && $t->getLength() < $threshold && - MWNamespace::isContent( $t->getNamespace() ) ) { + $t->isContentPage() ) { # Page is a stub $colour = 'stub'; } @@ -266,14 +266,10 @@ class Linker { $classes[] = 'extiw'; } - # Note that redirects never count as stubs here. - if ( !in_array( 'broken', $options ) && $target->isRedirect() ) { - $classes[] = 'mw-redirect'; - } elseif( $target->isContentPage() ) { - # Check for stub. - $threshold = $wgUser->getOption( 'stubthreshold' ); - if( $threshold > 0 and $target->exists() and $target->getLength() < $threshold ) { - $classes[] = 'stub'; + if ( !in_array( 'broken', $options ) ) { # Avoid useless calls to LinkCache (see r50387) + $colour = $this->getLinkColour( $target, $wgUser->getOption( 'stubthreshold' ) ); + if ( $colour !== '' ) { + $classes[] = $colour; # mw-redirect or stub } } if( $classes != array() ) { @@ -335,9 +331,12 @@ class Linker { * @param $trail String * @param $prefix String * @return string HTML of link + * @deprecated */ function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { global $wgUser; + wfDeprecated( __METHOD__ ); + $threshold = intval( $wgUser->getOption( 'stubthreshold' ) ); $colour = ( $size < $threshold ) ? 'stub' : ''; // FIXME: replace deprecated makeColouredLinkObj by link() @@ -1950,6 +1949,7 @@ class Linker { * @param $prefix String: Optional prefix */ function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) { + wfDeprecated( __METHOD__ ); if($colour != ''){ $style = $this->getInternalLinkAttributesObj( $nt, $text, $colour ); } else $style = ''; -- 2.20.1