Check the link color (stub, redirect) on just one place.
authorPlatonides <platonides@users.mediawiki.org>
Mon, 2 Aug 2010 15:53:22 +0000 (15:53 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Mon, 2 Aug 2010 15:53:22 +0000 (15:53 +0000)
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
includes/Linker.php

index fb08ad8..2b6a4c1 100644 (file)
@@ -236,7 +236,7 @@ class CategoryViewer {
                                        array(),
                                        array( 'known', 'noclasses' )
                                ) . '</span>'
-                       : $this->getSkin()->makeSizeLinkObj( $pageLength, $title );
+                       : $this->getSkin()->link( $title );
 
                if ( $wgExperimentalCategorySort ) {
                        $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstLetterForLists( $sortkey ) );
index 1a9e9cf..2795a8b 100644 (file)
@@ -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 = '';