From 10be9f4be54178fb84b661066659dce45ddd1c12 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 1 Jun 2005 10:29:34 +0000 Subject: [PATCH] * (bug 2274) Respect stub threshold in category page list Uses page_len field, so doesn't have to do extra lookups. --- includes/CategoryPage.php | 4 ++-- includes/Linker.php | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index 2d09936f63..d7a1b40e5b 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -91,7 +91,7 @@ class CategoryPage extends Article { $limit = 200; $res = $dbr->select( array( 'page', 'categorylinks' ), - array( 'page_title', 'page_namespace', 'cl_sortkey' ), + array( 'page_title', 'page_namespace', 'page_len', 'cl_sortkey' ), array( $pageCondition, 'cl_from = page_id', 'cl_to' => $this->mTitle->getDBKey()), @@ -139,7 +139,7 @@ class CategoryPage extends Article { } } else { // Page in this category - array_push( $articles, $sk->makeKnownLinkObj( $title, $wgContLang->convert( $title->getText() ) ) ) ; + array_push( $articles, $sk->makeSizeLinkObj( $x->page_len, $title, $wgContLang->convert( $title->getText() ) ) ) ; array_push( $articles_start_char, $wgContLang->convert( $wgContLang->firstChar( $x->cl_sortkey ) ) ); } } diff --git a/includes/Linker.php b/includes/Linker.php index fdf5c88751..3bdbab9e90 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -309,6 +309,28 @@ class Linker { return $s; } + /** + * Generate either a normal exists-style link or a stub link, depending + * on the given page size. + * + * @param int $size + * @param Title $nt + * @param string $text + * @param string $query + * @param string $trail + * @param string $prefix + * @return string HTML of link + */ + function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + global $wgUser; + $threshold = IntVal( $wgUser->getOption( 'stubthreshold' ) ); + if( $size < $threshold ) { + return $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix ); + } else { + return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix ); + } + } + /** @todo document */ function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { $u = $nt->escapeLocalURL( $query ); -- 2.20.1