Merge "Improve Html/Xml element generation docs"
[lhc/web/wiklou.git] / includes / api / ApiOpenSearch.php
index ace776c..e6fe27c 100644 (file)
@@ -391,14 +391,14 @@ class ApiOpenSearchFormatJson extends ApiFormatJson {
        }
 
        public function execute() {
-               if ( !$this->getResult()->getResultData( 'error' ) ) {
-                       $result = $this->getResult();
-
+               $result = $this->getResult();
+               if ( !$result->getResultData( 'error' ) && !$result->getResultData( 'errors' ) ) {
                        // 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,
+                               $this->dieWithError(
+                                       'apierror-opensearch-json-warnings',
+                                       'warnings',
                                        [ 'warnings' => $warnings ]
                                );
                        }