Krinkle has uploaded a new change for review.
https://gerrit.wikimedia.org/r/56320
Change subject: OpenSearch: Error for unsupported formats and adding
format=jsonfm
......................................................................
OpenSearch: Error for unsupported formats and adding format=jsonfm
Previously it would just completely ignore the format parameter.
Making it always serve JSON no matter the value of the format
parameter.
Now it properly errors when doing (for example) format=txt or format=xml.
Also adding support for jsonfm.
Change-Id: Ia98f54f41f39006312fb49ecd718f0f161f27c37
---
M RELEASE-NOTES-1.21
M includes/api/ApiOpenSearch.php
2 files changed, 20 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/20/56320/1
diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21
index 8844f9b..765f324 100644
--- a/RELEASE-NOTES-1.21
+++ b/RELEASE-NOTES-1.21
@@ -281,6 +281,9 @@
to action=feedwatchlist
* WDDX formatted output will actually be formatted (and normal output will no
longer be), and will no longer choke on booleans.
+* action=opensearch no longer silently ignores invalid values for the format
+ parameter.
+* action=opensearch now supports format=jsonfm.
=== API internal changes in 1.21 ===
* For debugging only, a new global $wgDebugAPI removes many API restrictions
when true.
diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php
index caf361a..745f7f9 100644
--- a/includes/api/ApiOpenSearch.php
+++ b/includes/api/ApiOpenSearch.php
@@ -1,7 +1,5 @@
<?php
/**
- *
- *
* Created on Oct 13, 2006
*
* Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
@@ -29,8 +27,20 @@
*/
class ApiOpenSearch extends ApiBase {
+ /**
+ * Override built-in handling of format parameter.
+ * Only JSON is supported.
+ *
+ * @return ApiFormatBase|null
+ */
public function getCustomPrinter() {
- return $this->getMain()->createPrinterByName( 'json' );
+ $params = $this->extractRequestParams();
+ $format = $params['format'];
+ $allowed = array( 'json', 'jsonfm' );
+ if ( in_array( $format, $allowed ) ) {
+ return $this->getMain()->createPrinterByName( $format );
+ }
+ return $this->getMain()->createPrinterByName( $allowed[0] );
}
public function execute() {
@@ -94,6 +104,10 @@
ApiBase::PARAM_ISMULTI => true
),
'suggest' => false,
+ 'format' => array(
+ ApiBase::PARAM_DFLT => 'json',
+ ApiBase::PARAM_TYPE => array( 'json', 'jsonfm'
),
+ )
);
}
--
To view, visit https://gerrit.wikimedia.org/r/56320
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia98f54f41f39006312fb49ecd718f0f161f27c37
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits