Page MenuHomePhorge

No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/resources/src/mediawiki.special.apisandbox/ApiSandbox.js b/resources/src/mediawiki.special.apisandbox/ApiSandbox.js
index 0d6acfc0d17..18c4deaed6d 100644
--- a/resources/src/mediawiki.special.apisandbox/ApiSandbox.js
+++ b/resources/src/mediawiki.special.apisandbox/ApiSandbox.js
@@ -225,7 +225,7 @@ const ApiSandbox = {
if ( checkPage.tokenWidget ) {
tokenWidgets.push( checkPage.tokenWidget );
}
- deferreds.push( checkPage.apiCheckValid() );
+ deferreds.push( ...checkPage.apiCheckValid() );
checkPage.getQueryParams( params, displayParams, ajaxOptions );
if ( checkPage.paramInfo.mustbeposted !== undefined ) {
method = 'post';
@@ -300,6 +300,19 @@ const ApiSandbox = {
return;
}
+ if ( params.format === undefined ) {
+ // While not required by the API, the sandbox UI makes the 'format' parameter required.
+ // If we reach this point without any value for it, that's a bug, so stop here
+ // (it would result in incorrect formatting on the results panel).
+ throw new Error( "'format' parameter is required" );
+ }
+ if ( params.action === undefined ) {
+ // While not required by the API, the sandbox UI makes the 'action' parameter required.
+ // If we reach this point without any value for it, that's a bug, so stop here
+ // (it would result in dumping the entire HTML help output on the results panel).
+ throw new Error( "'action' parameter is required" );
+ }
+
const query = $.param( displayParams );
const formatItems = Util.formatRequest( displayParams, params, method, ajaxOptions );
@@ -435,7 +448,7 @@ const ApiSandbox = {
.append( Util.parseMsg( 'apisandbox-results-login-suppressed' ) )
.appendTo( $result );
}
- let loadTime, match;
+ let loadTime;
if ( /^text\/mediawiki-api-prettyprint-wrapped(?:;|$)/.test( ct ) ) {
try {
data = JSON.parse( data );
@@ -454,11 +467,6 @@ const ApiSandbox = {
}
$result.append( Util.parseHTML( data.html ) );
loadTime = data.time;
- } else if ( ( match = data.match( /<pre[ >][\s\S]*<\/pre>/ ) ) ) {
- $result.append( Util.parseHTML( match[ 0 ] ) );
- if ( ( match = data.match( /"wgBackendResponseTime":\s*(\d+)/ ) ) ) {
- loadTime = parseInt( match[ 1 ], 10 );
- }
} else {
$( '<pre>' )
.addClass( 'api-pretty-content' )

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:33 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227870
Default Alt Text
(2 KB)

Event Timeline