From ac2b9d7baec40007f4e51b631b97546e1a277be7 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 22 Aug 2013 13:47:23 -0400 Subject: [PATCH] Allow ParserLimitReportFormat to change $value It's likely that an extension might want to reformat the value (e.g. by passing it through Language::formatSize()), but otherwise use the default behavior for the key. Make $value a reference parameter so they don't have to reimplement all the logic for laying out the row. Change-Id: I7799616a602d90e1b8d3f0ece35811ca387bade7 --- docs/hooks.txt | 5 +++-- includes/EditPage.php | 2 +- includes/parser/Parser.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 96a72df677..7bd725a8a4 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1847,7 +1847,7 @@ needs formatting. If nothing handles this hook, the default is to use "$key" to get the label, and "$key-value" or "$key-value-text"/"$key-value-html" to format the value. $key: Key for the limit report item (string) -$value: Value of the limit report item +&$value: Value of the limit report item &$report: String onto which to append the data $isHTML: If true, $report is an HTML table with two columns; if false, it's text intended for display in a monospaced font. @@ -1855,7 +1855,8 @@ $localize: If false, $report should be output in English. 'ParserLimitReportPrepare': Called at the end of Parser:parse() when the parser will include comments about size of the text parsed. Hooks should use -$output->setLimitReportData() to populate data. +$output->setLimitReportData() to populate data. Functions for this hook should +not use $wgLang; do that in ParserLimitReportFormat instead. $parser: Parser object $output: ParserOutput object diff --git a/includes/EditPage.php b/includes/EditPage.php index 530e267453..68691c5cd4 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2937,7 +2937,7 @@ HTML foreach ( $output->getLimitReportData() as $key => $value ) { if ( wfRunHooks( 'ParserLimitReportFormat', - array( $key, $value, &$limitReport, true, true ) + array( $key, &$value, &$limitReport, true, true ) ) ) { $keyMsg = wfMessage( $key ); $valueMsg = wfMessage( array( "$key-value-html", "$key-value" ) ); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 848a1a0abc..2df3160dc8 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -541,7 +541,7 @@ class Parser { } foreach ( $this->mOutput->getLimitReportData() as $key => $value ) { if ( wfRunHooks( 'ParserLimitReportFormat', - array( $key, $value, &$limitReport, false, false ) + array( $key, &$value, &$limitReport, false, false ) ) ) { $keyMsg = wfMessage( $key )->inLanguage( 'en' )->useDatabase( false ); $valueMsg = wfMessage( array( "$key-value-text", "$key-value" ) ) -- 2.20.1