Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/80412


Change subject: Allow ParserLimitReportFormat to change $value
......................................................................

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
---
M docs/hooks.txt
M includes/EditPage.php
M includes/parser/Parser.php
3 files changed, 5 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/12/80412/1

diff --git a/docs/hooks.txt b/docs/hooks.txt
index e776d4c..43bd194 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -1820,7 +1820,7 @@
 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.
@@ -1828,7 +1828,8 @@
 
 '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 7c7bfe9..d1fb49f 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -2895,7 +2895,7 @@
 
                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 a6823bf..38965f0 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -531,7 +531,7 @@
                        $limitReport = "NewPP limit report\n";
                        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" ) )

-- 
To view, visit https://gerrit.wikimedia.org/r/80412
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7799616a602d90e1b8d3f0ece35811ca387bade7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to