From: Aryeh Gregor Date: Fri, 18 Apr 2008 14:19:00 +0000 (+0000) Subject: Comments, code simplification X-Git-Tag: 1.31.0-rc.0~48205 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=6b89e9e50b7d35b903fdbee171b8f820c4ad7f57;p=lhc%2Fweb%2Fwiklou.git Comments, code simplification --- diff --git a/includes/CoreParserFunctions.php b/includes/CoreParserFunctions.php index 779685e778..61fad6cfac 100644 --- a/includes/CoreParserFunctions.php +++ b/includes/CoreParserFunctions.php @@ -158,9 +158,8 @@ class CoreParserFunctions { } /** - * Override the title of the page when viewed, - * provided we've been given a title which - * will normalise to the canonical title + * Override the title of the page when viewed, provided we've been given a + * title which will normalise to the canonical title * * @param Parser $parser Parent parser * @param string $text Desired title text @@ -216,6 +215,11 @@ class CoreParserFunctions { return self::formatRaw( SiteStats::pagesInNs( intval( $namespace ) ), $raw ); } + /** + * Return the number of pages in the given category, or 0 if it's nonexis- + * tent. This is an expensive parser function and can't be called too many + * times per page. + */ static function pagesincategory( $parser, $category = '', $raw = null ) { global $wgExpensiveParserFunctionLimit; $category = Category::newFromName($category); @@ -224,11 +228,7 @@ class CoreParserFunctions { } $parser->mExpensiveFunctionCount++; if ($parser->mExpensiveFunctionCount <= $wgExpensiveParserFunctionLimit) { - $count = $category->getPageCount(); - if ( !$count ) { - $count = 0; - } - return self::formatRaw( $count, $raw ); + return self::formatRaw( (int)$category->getPageCount(), $raw ); } return 0; }