mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-27 15:50:29 +00:00
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
This commit is contained in:
parent
0c1eff31ef
commit
26e24c2d09
|
@ -109,9 +109,15 @@ class ApiVisualEditor extends ApiBase {
|
|||
$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 @@ class ApiVisualEditor extends ApiBase {
|
|||
|
||||
$title = Title::newFromText( $params['page'] );
|
||||
if ( !$title ) {
|
||||
$this->dieUsageMsg( 'invalidtitle', $params['page'] );
|
||||
$this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['page'] ) ] );
|
||||
}
|
||||
|
||||
$parserParams = [];
|
||||
|
@ -202,7 +208,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
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 @@ class ApiVisualEditor extends ApiBase {
|
|||
} 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 @@ class ApiVisualEditor extends ApiBase {
|
|||
[]
|
||||
);
|
||||
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 @@ class ApiVisualEditor extends ApiBase {
|
|||
$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 @@ class ApiVisualEditor extends ApiBase {
|
|||
}
|
||||
$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 @@ class ApiVisualEditor extends ApiBase {
|
|||
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 ];
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
|||
$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 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
|||
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 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
|||
$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 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
|||
$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 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
|||
$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 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
|||
// 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();
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue