r33547 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33546‎ | r33547 | r33548 >
Date:14:19, 18 April 2008
Author:simetrical
Status:old
Tags:
Comment:
Comments, code simplification
Modified paths:
  • /trunk/phase3/includes/CoreParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/CoreParserFunctions.php
@@ -158,9 +158,8 @@
159159 }
160160
161161 /**
162 - * Override the title of the page when viewed,
163 - * provided we've been given a title which
164 - * will normalise to the canonical title
 162+ * Override the title of the page when viewed, provided we've been given a
 163+ * title which will normalise to the canonical title
165164 *
166165 * @param Parser $parser Parent parser
167166 * @param string $text Desired title text
@@ -216,6 +215,11 @@
217216 return self::formatRaw( SiteStats::pagesInNs( intval( $namespace ) ), $raw );
218217 }
219218
 219+ /**
 220+ * Return the number of pages in the given category, or 0 if it's nonexis-
 221+ * tent. This is an expensive parser function and can't be called too many
 222+ * times per page.
 223+ */
220224 static function pagesincategory( $parser, $category = '', $raw = null ) {
221225 global $wgExpensiveParserFunctionLimit;
222226 $category = Category::newFromName($category);
@@ -224,11 +228,7 @@
225229 }
226230 $parser->mExpensiveFunctionCount++;
227231 if ($parser->mExpensiveFunctionCount <= $wgExpensiveParserFunctionLimit) {
228 - $count = $category->getPageCount();
229 - if ( !$count ) {
230 - $count = 0;
231 - }
232 - return self::formatRaw( $count, $raw );
 232+ return self::formatRaw( (int)$category->getPageCount(), $raw );
233233 }
234234 return 0;
235235 }

Status & tagging log