Merge "Fix \n handling for HTMLUsersMultiselectField"
[lhc/web/wiklou.git] / includes / api / ApiOpenSearch.php
index ace776c..419fd14 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
  * Copyright © 2008 Brion Vibber <brion@wikimedia.org>
- * Copyright © 2014 Brad Jorsch <bjorsch@wikimedia.org>
+ * Copyright © 2014 Wikimedia Foundation and contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -232,7 +232,7 @@ class ApiOpenSearch extends ApiBase {
                                break;
 
                        case 'xml':
-                               // http://msdn.microsoft.com/en-us/library/cc891508%28v=vs.85%29.aspx
+                               // https://msdn.microsoft.com/en-us/library/cc891508(v=vs.85).aspx
                                $imageKeys = [
                                        'source' => true,
                                        'alt' => true,
@@ -309,7 +309,7 @@ class ApiOpenSearch extends ApiBase {
        }
 
        public function getHelpUrls() {
-               return 'https://www.mediawiki.org/wiki/API:Opensearch';
+               return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Opensearch';
        }
 
        /**
@@ -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 ]
                                );
                        }