Index: trunk/phase3/includes/CoreParserFunctions.php |
— | — | @@ -158,9 +158,8 @@ |
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
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 |
165 | 164 | * |
166 | 165 | * @param Parser $parser Parent parser |
167 | 166 | * @param string $text Desired title text |
— | — | @@ -216,6 +215,11 @@ |
217 | 216 | return self::formatRaw( SiteStats::pagesInNs( intval( $namespace ) ), $raw ); |
218 | 217 | } |
219 | 218 | |
| 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 | + */ |
220 | 224 | static function pagesincategory( $parser, $category = '', $raw = null ) { |
221 | 225 | global $wgExpensiveParserFunctionLimit; |
222 | 226 | $category = Category::newFromName($category); |
— | — | @@ -224,11 +228,7 @@ |
225 | 229 | } |
226 | 230 | $parser->mExpensiveFunctionCount++; |
227 | 231 | 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 ); |
233 | 233 | } |
234 | 234 | return 0; |
235 | 235 | } |