From 12fb35058ecd420288ea49bb77f16d458e1b753b Mon Sep 17 00:00:00 2001 From: Alex Z Date: Sun, 31 May 2009 18:55:38 +0000 Subject: [PATCH] Some followup to r51200: * Save a query by not using User::edits() * Mark as an expensive function (it needs at least 1 query for each use) * Use number formatting/raw option rather than pointless wfEscapeWikiText() --- includes/parser/CoreParserFunctions.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index a07d67f735..9ba8554fe7 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -596,16 +596,19 @@ class CoreParserFunctions { } /** - * Returns the number of contributions by a certain user + * Returns the number of contributions by a certain user. This is an + * expensive parser function and can't be called too many times per page */ - static function numberofcontribs( $parser, $user = null ) { - if ( is_null($user) || !User::isValidUserName( $user ) ) + static function numberofcontribs( $parser, $user = null, $raw = null ) { + if ( is_null($user) || !User::isValidUserName( $user ) ) { return ''; - + } + if ( !$parser->incrementExpensiveFunctionCount() ) { + return ''; + } $u = User::newFromName( $user ); $u->load(); - - return wfEscapeWikiText( $u->edits( $u->mId ) ); + return self::formatRaw( $u->mEditCount, $raw ); } /** -- 2.20.1