Anomie has uploaded a new change for review. https://gerrit.wikimedia.org/r/216311
Change subject: ApiOpenSearch: Ignore any other unexpected keys in json output ...................................................................... ApiOpenSearch: Ignore any other unexpected keys in json output Iad295d2f fixed warnings to not break the opensearch json output. But other stuff like $wgDebugToolbar can do the same thing, so let's strip all unrecognized keys to avoid that problem. Bug: T100635 Change-Id: I20b6502482af537ccb703f400508960038213a91 --- M RELEASE-NOTES-1.25 M includes/api/ApiOpenSearch.php 2 files changed, 15 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/11/216311/1 diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25 index c627ccb..db37c5d 100644 --- a/RELEASE-NOTES-1.25 +++ b/RELEASE-NOTES-1.25 @@ -9,6 +9,8 @@ * (T100767) Setting a configuration setting for skin or extension to false in LocalSettings.php was not working. +* (T100635) API action=opensearch json output no longer breaks when + $wgDebugToolbar is enabled. == Changes since 1.25.1 == diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index a93b7cc..0adb464 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -384,13 +384,25 @@ public function execute() { if ( !$this->getResult()->getResultData( 'error' ) ) { - $warnings = $this->getResult()->removeValue( 'warnings', null ); + $result = $this->getResult(); + + // Ignore warnings or treat as errors, as requested + $warnings = $result->removeValue( 'warnings', null ); if ( $this->warningsAsError && $warnings ) { $this->dieUsage( 'Warnings cannot be represented in OpenSearch JSON format', 'warnings', 0, array( 'warnings' => $warnings ) ); } + + // Ignore any other unexpected keys (e.g. from $wgDebugToolbar) + $remove = array_keys( array_diff_key( + $result->getResultData(), + array( 0 => 'search', 1 => 'terms', 2 => 'descriptions', 3 => 'urls' ) + ) ); + foreach ( $remove as $key ) { + $result->removeValue( $key, null ); + } } parent::execute(); -- To view, visit https://gerrit.wikimedia.org/r/216311 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I20b6502482af537ccb703f400508960038213a91 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: REL1_25 Gerrit-Owner: Anomie <bjor...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits