Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/321462

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

Update for API error i18n

See Iae0e2ce3. Since VisualEditor master requires core master, this just
depends on the master patch instead of trying to maintain BC.

Depends-On: Iae0e2ce3bd42dd4776a9779664086119ac188412
Change-Id: I0e802a47302725f062334a437bff84e3b2b8b9a6
---
M ApiVisualEditor.php
M ApiVisualEditorEdit.php
M modules/ve-mw/i18n/en.json
M modules/ve-mw/i18n/qqq.json
4 files changed, 37 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/62/321462/1

diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php
index 648fa22..4ccf184 100644
--- a/ApiVisualEditor.php
+++ b/ApiVisualEditor.php
@@ -109,9 +109,15 @@
                                $resp->header( 'X-Cache: ' . $rp );
                        }
                } elseif ( $response['error'] !== '' ) {
-                       $this->dieUsage( 'docserver-http-error: ' . 
$response['error'], $response['error'] );
+                       $this->dieWithError(
+                               [ 'apierror-visualeditor-docserver-http-error', 
wfEscapeWikiText( $response['error'] ) ],
+                               $response['error']
+                       );
                } else { // error null, code not 200
-                       $this->dieUsage( 'docserver-http: HTTP ' . 
$response['code'], $response['code'] );
+                       $this->dieWithError(
+                               [ 'apierror-visualeditor-docserver-http', 
$response['code'] ],
+                               $response['code']
+                       );
                }
                return $response['body'];
        }
@@ -180,7 +186,7 @@
 
                $title = Title::newFromText( $params['page'] );
                if ( !$title ) {
-                       $this->dieUsageMsg( 'invalidtitle', $params['page'] );
+                       $this->dieWithError( [ 'apierror-invalidtitle', 
wfEscapeWikiText( $params['page'] ) ] );
                }
 
                $parserParams = [];
@@ -202,7 +208,7 @@
                                if ( $title->exists() ) {
                                        $latestRevision = 
Revision::newFromTitle( $title );
                                        if ( $latestRevision === null ) {
-                                               $this->dieUsage( 'Could not 
find latest revision for title', 'latestnotfound' );
+                                               $this->dieWithError( 
'apierror-visualeditor-latestnotfound', 'latestnotfound' );
                                        }
                                        $revision = null;
                                        if ( !isset( $parserParams['oldid'] ) 
|| $parserParams['oldid'] === 0 ) {
@@ -211,7 +217,7 @@
                                        } else {
                                                $revision = 
Revision::newFromId( $parserParams['oldid'] );
                                                if ( $revision === null ) {
-                                                       $this->dieUsage( 'Could 
not find revision ID ' . $parserParams['oldid'], 'oldidnotfound' );
+                                                       $this->dieWithError( [ 
'apierror-nosuchrevid', $parserParams['oldid'] ], 'oldidnotfound' );
                                                }
                                        }
 
@@ -227,7 +233,7 @@
                                                        []
                                                );
                                                if ( $content === false ) {
-                                                       $this->dieUsage( 'Error 
contacting the document server', 'docserver' );
+                                                       $this->dieWithError( 
'apierror-visualeditor-docserver', 'docserver' );
                                                }
                                        } elseif ( $params['paction'] === 
'wikitext' ) {
                                                $apiParams = [
@@ -256,7 +262,7 @@
                                                        
$result['query']['pages'][$pid]['revisions']['0']['content'] :
                                                        false;
                                                if ( $content === false ) {
-                                                       $this->dieUsage( 'Error 
contacting the document server', 'docserver' );
+                                                       $this->dieWithError( 
'apierror-visualeditor-docserver', 'docserver' );
                                                }
                                        }
 
@@ -469,7 +475,7 @@
                                }
                                $content = $this->parseWikitextFragment( 
$title, $wikitext );
                                if ( $content === false ) {
-                                       $this->dieUsage( 'Error contacting the 
document server', 'docserver' );
+                                       $this->dieWithError( 
'apierror-visualeditor-docserver', 'docserver' );
                                } else {
                                        $result = [
                                                'result' => 'success',
@@ -481,7 +487,7 @@
                        case 'getlanglinks':
                                $langlinks = $this->getLangLinks( $title );
                                if ( $langlinks === false ) {
-                                       $this->dieUsage( 'Error querying 
MediaWiki API', 'api-langlinks-error' );
+                                       $this->dieWithError( 
'apierror-visualeditor-api-langlinks-error', 'api-langlinks-error' );
                                } else {
                                        $result = [ 'result' => 'success', 
'langlinks' => $langlinks ];
                                }
diff --git a/ApiVisualEditorEdit.php b/ApiVisualEditorEdit.php
index 22a4766..057706a 100644
--- a/ApiVisualEditorEdit.php
+++ b/ApiVisualEditorEdit.php
@@ -120,7 +120,7 @@
                        $inflated = gzinflate( $deflated );
                        wfRestoreWarnings();
                        if ( $deflated === $inflated || $inflated === false ) {
-                               $this->dieUsage( "Content provided is not 
properly deflated", 'invaliddeflate' );
+                               $this->dieWithError( 
'apierror-visualeditor-invaliddeflate', 'invaliddeflate' );
                        }
                        return $inflated;
                }
@@ -131,7 +131,7 @@
                if ( $params['cachekey'] !== null ) {
                        $wikitext = $this->trySerializationCache( 
$params['cachekey'] );
                        if ( !is_string( $wikitext ) ) {
-                               $this->dieUsage( 'No cached serialization found 
with that key', 'badcachekey' );
+                               $this->dieWithError( 
'apierror-visualeditor-badcachekey', 'badcachekey' );
                        }
                } else {
                        $wikitext = $this->getWikitextNoCache( $title, $params, 
$parserParams );
@@ -145,7 +145,7 @@
                        $title, $this->tryDeflate( $params['html'] ), 
$parserParams, $params['etag']
                );
                if ( $wikitext === false ) {
-                       $this->dieUsage( 'Error contacting the document 
server', 'docserver' );
+                       $this->dieWithError( 'apierror-visualeditor-docserver', 
'docserver' );
                }
                return $wikitext;
        }
@@ -253,7 +253,7 @@
                $params = $this->extractRequestParams();
                $title = Title::newFromText( $params['page'] );
                if ( !$title ) {
-                       $this->dieUsageMsg( 'invalidtitle', $params['page'] );
+                       $this->dieWithError( [ 'apierror-invalidtitle', 
wfEscapeWikiText( $params['page'] ) ] );
                }
 
                $parserParams = [];
@@ -278,7 +278,7 @@
                        $section = isset( $params['section'] ) ? 
$params['section'] : null;
                        $diff = $this->diffWikitext( $title, $wikitext, 
$section );
                        if ( $diff['result'] === 'fail' ) {
-                               $this->dieUsage( 'Diff failed', 'difffailed' );
+                               $this->dieWithError( 
'apierror-visualeditor-difffailed', 'difffailed' );
                        }
                        $result = $diff;
                } elseif ( $params['paction'] === 'save' ) {
@@ -319,7 +319,7 @@
                                // frontend can update the page rendering 
without a refresh.
                                $result = $this->parseWikitext( $title, 
$newRevId );
                                if ( $result === false ) {
-                                       $this->dieUsage( 'Error contacting the 
Parsoid/RESTBase server', 'docserver' );
+                                       $this->dieWithError( 
'apierror-visualeditor-docserver', 'docserver' );
                                }
 
                                $result['isRedirect'] = (string) 
$title->isRedirect();
diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json
index 7f370f7..b2d1575 100644
--- a/modules/ve-mw/i18n/en.json
+++ b/modules/ve-mw/i18n/en.json
@@ -48,6 +48,14 @@
        "apihelp-visualeditoredit-param-summary": "Edit summary.",
        "apihelp-visualeditoredit-param-watch": "",
        "apihelp-visualeditoredit-param-wikitext": "",
+       "apierror-visualeditor-api-langlinks-error": "Error querying MediaWiki 
API",
+       "apierror-visualeditor-badcachekey": "No cached serialization found 
with that key",
+       "apierror-visualeditor-difffailed": "Diff failed",
+       "apierror-visualeditor-docserver": "Error contacting the 
Parsoid/RESTbase server",
+       "apierror-visualeditor-docserver-http": "docserver-http: HTTP $1",
+       "apierror-visualeditor-docserver-http-error": "docserver-http-error: 
$1",
+       "apierror-visualeditor-invaliddeflate": "Content provided is not 
properly deflated",
+       "apierror-visualeditor-latestnotfound": "Could not find latest revision 
for title",
        "tooltip-ca-createsource": "Create the source code of this page",
        "tooltip-ca-edit": "Edit this page using wikitext",
        "tooltip-ca-editsource": "Edit the source code of this page",
diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json
index ae49231..5c10399 100644
--- a/modules/ve-mw/i18n/qqq.json
+++ b/modules/ve-mw/i18n/qqq.json
@@ -61,6 +61,14 @@
        "apihelp-visualeditoredit-param-summary": 
"{{doc-apihelp-param|visualeditoredit|summary}}\n{{Identical|Edit summary}}",
        "apihelp-visualeditoredit-param-watch": 
"{{doc-apihelp-param|visualeditoredit|watch}}",
        "apihelp-visualeditoredit-param-wikitext": 
"{{doc-apihelp-param|visualeditoredit|wikitext}}",
+       "apierror-visualeditor-api-langlinks-error": "{{doc-apierror}}",
+       "apierror-visualeditor-badcachekey": "{{doc-apierror}}",
+       "apierror-visualeditor-difffailed": "{{doc-apierror}}",
+       "apierror-visualeditor-docserver": "{{doc-apierror}}",
+       "apierror-visualeditor-docserver-http": 
"{{doc-apierror}}\n\nParameters:\n* $1 - HTTP status code (numeric)",
+       "apierror-visualeditor-docserver-http-error": 
"{{doc-apierror}}\n\nParameters:\n* $1 - Error message, probably in English",
+       "apierror-visualeditor-invaliddeflate": "{{doc-apierror}}",
+       "apierror-visualeditor-latestnotfound": "{{doc-apierror}}",
        "tooltip-ca-createsource": "Tooltip of the 
{{msg-mw|Visualeditor-ca-createsource}} tab, used if the page does not 
exist.\n\nSee also:\n* {{msg-mw|Tooltip-ca-editsource}} - tooltip of the 
{{msg-mw|Visualeditor-ca-editsource}} tab, used if the page already exists",
        "tooltip-ca-edit": "Over-ridden tooltip of the wikitext \"Edit source\" 
tab.",
        "tooltip-ca-editsource": "Tooltip of the 
{{msg-mw|Visualeditor-ca-editsource}} tab, used if the page already 
exists.\n\nSee also:\n* {{msg-mw|Tooltip-ca-createsource}} - tooltip of the 
{{msg-mw|Visualeditor-ca-createsource}} tab, used if the page does not exist",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e802a47302725f062334a437bff84e3b2b8b9a6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to