jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/321467 )

Change subject: Update for API error i18n
......................................................................


Update for API error i18n

See Iae0e2ce3.

Change-Id: Ia20b2610f0b5843b51feee8a17eb7f12cfc5eba3
---
M i18n/en.json
M i18n/qqq.json
M includes/ApiZeroPortal.php
3 files changed, 20 insertions(+), 7 deletions(-)

Approvals:
  Gergő Tisza: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/i18n/en.json b/i18n/en.json
index 5b1f7aa..482fc02 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -8,5 +8,6 @@
        "apihelp-zeroportal-description": "Zero portal API.",
        "apihelp-zeroportal-param-type": "What kind of Zero info is 
needed:\n;carriersnoips:Core configs for all carriers, excluding 
IPs.\n;proxies:List of all IPs of the proxies (pages begin with 
\"-\").\n;carriers:List of all IPs of all carriers.\n;analyticsconfig:Data in 
the analytics-required format.",
        "apihelp-zeroportal-param-start": "For analyticsconfig type, use this 
parameter to set starting timestamp.",
-       "apihelp-zeroportal-example-1": "List all IPs of all carriers"
+       "apihelp-zeroportal-example-1": "List all IPs of all carriers",
+       "apierror-zeroportal-login": "Must be authenticated with 
<code>zero-script</code> right to use this API."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index a4fa980..a98cf06 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -11,5 +11,6 @@
        "apihelp-zeroportal-description": 
"{{doc-apihelp-description|zeroportal}}",
        "apihelp-zeroportal-param-type": 
"{{doc-apihelp-param|zeroportal|type}}",
        "apihelp-zeroportal-param-start": 
"{{doc-apihelp-param|zeroportal|start}}",
-       "apihelp-zeroportal-example-1": "{{doc-apihelp-example|zeroportal}}"
+       "apihelp-zeroportal-example-1": "{{doc-apihelp-example|zeroportal}}",
+       "apierror-zeroportal-login": "{{doc-apierror}}"
 }
diff --git a/includes/ApiZeroPortal.php b/includes/ApiZeroPortal.php
index 98e2b6b..5d8db13 100644
--- a/includes/ApiZeroPortal.php
+++ b/includes/ApiZeroPortal.php
@@ -39,11 +39,22 @@
                $type = $params['type'];
                $moduleName = $this->getModuleName();
                if ( !$this->getUser()->isAllowed( 'zero-script' ) ) {
-                       $this->dieUsage(
-                               "Must be authenticated with zero-script right 
to use this API",
-                               'login',
-                               401
-                       );
+                       // Ugh. HTTP 401 status are supposed to require a 
WWW-Authenticate
+                       // header, according to the HTTP RFC.
+                       if ( is_callable( [ $this, 'dieWithError' ] ) ) {
+                               $this->dieWithError(
+                                       'apierror-zeroportal-login',
+                                       'login',
+                                       [],
+                                       401
+                               );
+                       } else {
+                               $this->dieUsage(
+                                       "Must be authenticated with zero-script 
right to use this API",
+                                       'login',
+                                       401
+                               );
+                       }
                }
 
                switch ( $type ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/321467
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia20b2610f0b5843b51feee8a17eb7f12cfc5eba3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroPortal
Gerrit-Branch: master
Gerrit-Owner: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to