r51253 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51252‎ | r51253 | r51254 >
Date:18:55, 31 May 2009
Author:mrzman
Status:reverted (Comments)
Tags:
Comment:
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()
Modified paths:
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -596,16 +596,19 @@
597597 }
598598
599599 /**
600 - * Returns the number of contributions by a certain user
 600+ * Returns the number of contributions by a certain user. This is an
 601+ * expensive parser function and can't be called too many times per page
601602 */
602 - static function numberofcontribs( $parser, $user = null ) {
603 - if ( is_null($user) || !User::isValidUserName( $user ) )
 603+ static function numberofcontribs( $parser, $user = null, $raw = null ) {
 604+ if ( is_null($user) || !User::isValidUserName( $user ) ) {
604605 return '';
605 -
 606+ }
 607+ if ( !$parser->incrementExpensiveFunctionCount() ) {
 608+ return '';
 609+ }
606610 $u = User::newFromName( $user );
607611 $u->load();
608 -
609 - return wfEscapeWikiText( $u->edits( $u->mId ) );
 612+ return self::formatRaw( $u->mEditCount, $raw );
610613 }
611614
612615 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r51529Revert r51200, r51253, r51254, addition of {{NUMBEROFCONTRIBS:...}} parser fu...tstarling02:49, 6 June 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r51200(bug 19012) Added {{NUMBEROFCONTRIBS}} variablesoxred9317:27, 30 May 2009

Comments

#Comment by Mr.Z-man (talk | contribs)   20:24, 1 June 2009

Note, tweaked some more in r51254.

Status & tagging log