Bartosz Dziewoński has uploaded a new change for review.

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

Change subject: Allow extensions to use 
ParserLimitReportPrepare/ParserLimitReportFormat again
......................................................................

Allow extensions to use ParserLimitReportPrepare/ParserLimitReportFormat again

* Display data in all "namespaces", not just 'limitreport',
  as extensions may use custom ones (e.g. Scribunto).
  See ParserOutput::setLimitReportData(). The isDisabled()
  checks ensure that "unknown" "namespaces" are still ignored.
* Correct the $key passed to ParserLimitReportFormat.

Follow-up to 1255654ed5a89ed57491bda38f544ed87e3bc601,
which for unclear reasons removed this code entirely,
and 0051f108b954b52b9981d5d85862ac1f292db80c, which was
not a complete fix.

This still does not resolve everything that was broken in
1255654ed5a89ed57491bda38f544ed87e3bc601 (limit report data
without a "namespace" will be ignored). Honestly I would
prefer to revert the whole thing entirely and rethink it.

Bug: T142210
Change-Id: I5af34c07255a8bc3977f474037b748bccf46ae99
---
M includes/EditPage.php
1 file changed, 24 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/37/320237/1

diff --git a/includes/EditPage.php b/includes/EditPage.php
index 9c5c91a..fc21495 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -3550,26 +3550,31 @@
                ] ) .
                        Html::openElement( 'tbody' );
 
-               foreach ( $output->getLimitReportData()['limitreport'] as $key 
=> $value ) {
-                       if ( Hooks::run( 'ParserLimitReportFormat',
-                               [ $key, &$value, &$limitReport, true, true ]
-                       ) ) {
-                               $keyMsg = wfMessage( "limitreport-$key" );
-                               $valueMsg = wfMessage(
-                                       [ "limitreport-$key-value-html", 
"limitreport-$key-value" ]
-                               );
-                               if ( !$valueMsg->exists() ) {
-                                       $valueMsg = new RawMessage( '$1' );
-                               }
-                               if ( !$keyMsg->isDisabled() && 
!$valueMsg->isDisabled() ) {
-                                       // If it's a value/limit array, convert 
it for $1/$2
-                                       if ( is_array( $value ) && isset( 
$value['value'] ) ) {
-                                               $value = [ $value['value'], 
$value['limit'] ];
+               foreach ( $output->getLimitReportData() as $ns => $data ) {
+                       if ( is_array( $data ) ) {
+                               foreach ( $data as $name => $value ) {
+                                       $key = "$ns-$name";
+                                       if ( Hooks::run( 
'ParserLimitReportFormat',
+                                               [ $key, &$value, &$limitReport, 
true, true ]
+                                       ) ) {
+                                               $keyMsg = wfMessage( $key );
+                                               $valueMsg = wfMessage(
+                                                       [ "$key-value-html", 
"$key-value" ]
+                                               );
+                                               if ( !$valueMsg->exists() ) {
+                                                       $valueMsg = new 
RawMessage( '$1' );
+                                               }
+                                               if ( !$keyMsg->isDisabled() && 
!$valueMsg->isDisabled() ) {
+                                                       // If it's a 
value/limit array, convert it for $1/$2
+                                                       if ( is_array( $value ) 
&& isset( $value['value'] ) ) {
+                                                               $value = [ 
$value['value'], $value['limit'] ];
+                                                       }
+                                                       $limitReport .= 
Html::openElement( 'tr' ) .
+                                                               
Html::rawElement( 'th', null, $keyMsg->parse() ) .
+                                                               
Html::rawElement( 'td', null, $valueMsg->params( $value )->parse() ) .
+                                                               
Html::closeElement( 'tr' );
+                                               }
                                        }
-                                       $limitReport .= Html::openElement( 'tr' 
) .
-                                               Html::rawElement( 'th', null, 
$keyMsg->parse() ) .
-                                               Html::rawElement( 'td', null, 
$valueMsg->params( $value )->parse() ) .
-                                               Html::closeElement( 'tr' );
                                }
                        }
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5af34c07255a8bc3977f474037b748bccf46ae99
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

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

Reply via email to