jenkins-bot has submitted this change and it was merged.

Change subject: Catch when wgPageParseReport is missing
......................................................................


Catch when wgPageParseReport is missing

The performance inspector shouldn't get a fatal error if the report
is missing (as reported in T145717). We get that behavoir
when editing with Visual Editor.

Bug: T145717
Change-Id: I8a3223299fae353ea01cd770b96d2224de923dc9
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M modules/collectors/ext.PerformanceInspector.newpp.js
4 files changed, 14 insertions(+), 5 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index fae312e..9c4ed95 100644
--- a/extension.json
+++ b/extension.json
@@ -112,6 +112,7 @@
                                
"performanceinspector-newpp-scribunto-description",
                                
"performanceinspector-newpp-cachereport-description",
                                "performanceinspector-newpp-cachereport-now",
+                               "performanceinspector-newpp-missing-report",
                                "size-bytes",
                                "size-kilobytes",
                                "size-megabytes",
diff --git a/i18n/en.json b/i18n/en.json
index e4b1d74..8f6115d 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -70,5 +70,6 @@
        "performanceinspector-newpp-timingprofile-description": "Time spent 
parsing the templates for this page.",
        "performanceinspector-newpp-scribunto-description": "Memory and time 
usage spent in Lua scripting.",
        "performanceinspector-newpp-cachereport-description": "When was this 
page cached in the parser cache.",
-       "performanceinspector-newpp-cachereport-now": "Now"
+       "performanceinspector-newpp-cachereport-now": "Now",
+       "performanceinspector-newpp-missing-report": "Couldn't fetch parser 
report data so the parser report fields will be empty."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index b72f099..ad0cd6b 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -67,5 +67,6 @@
        "performanceinspector-newpp-timingprofile-description": "Description 
explaining the timing profile metrics",
        "performanceinspector-newpp-scribunto-description": "Description 
explaining the scribuntu metrics",
        "performanceinspector-newpp-cachereport-description": "Description 
explaining the cache report metrics",
-       "performanceinspector-newpp-cachereport-now": "Describe when a cache 
expires right now"
+       "performanceinspector-newpp-cachereport-now": "Describe when a cache 
expires right now",
+       "performanceinspector-newpp-missing-report": "Message when the original 
page is missing parser metrics (so that the parser report cannnot be displayed)"
 }
diff --git a/modules/collectors/ext.PerformanceInspector.newpp.js 
b/modules/collectors/ext.PerformanceInspector.newpp.js
index 0b09ba9..5ae06ea 100644
--- a/modules/collectors/ext.PerformanceInspector.newpp.js
+++ b/modules/collectors/ext.PerformanceInspector.newpp.js
@@ -1,7 +1,8 @@
 ( function ( mw ) {
 
        var newppCollector = function runNewPPCollector() {
-               var template = mw.template.get( 
'ext.PerformanceInspector.analyze', 'newpp.mustache' );
+               var template = mw.template.get( 
'ext.PerformanceInspector.analyze', 'newpp.mustache' ),
+               report, parserReportSummary, mustacheView;
 
                function generateMustacheView( parserReport ) {
                        var limitReport = [],
@@ -48,16 +49,21 @@
                        };
                }
 
+               // in some cases we don't have the wgPageParseReport, see 
https://phabricator.wikimedia.org/T145717
+               report = mw.config.get( 'wgPageParseReport' );
+               parserReportSummary = report.limitreport ? mw.msg( 
'performanceinspector-newpp-summary', mw.config.get( 'wgPageParseReport' 
).limitreport.expensivefunctioncount.value ) :  mw.msg( 
'performanceinspector-newpp-missing-report' );
+               mustacheView =  report.limitreport  ? generateMustacheView( 
mw.config.get( 'wgPageParseReport' ) ) : '';
+
                return {
                        summary: {
-                               parserReportSummary: mw.msg( 
'performanceinspector-newpp-summary', mw.config.get( 'wgPageParseReport' 
).limitreport.expensivefunctioncount.value )
+                               parserReportSummary: parserReportSummary
                        },
                        view: {
                                name: 'performanceinspector-newpp-name',
                                label: 'performanceinspector-newpp-label',
                                template: template,
                                data: {
-                                       report: generateMustacheView( 
mw.config.get( 'wgPageParseReport' ) )
+                                       report: mustacheView
                                }
                        }
                };

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8a3223299fae353ea01cd770b96d2224de923dc9
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/PerformanceInspector
Gerrit-Branch: master
Gerrit-Owner: Phedenskog <phedens...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Phedenskog <phedens...@wikimedia.org>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to