mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-12 09:09:25 +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 );
|
$resp->header( 'X-Cache: ' . $rp );
|
||||||
}
|
}
|
||||||
} elseif ( $response['error'] !== '' ) {
|
} 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
|
} 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'];
|
return $response['body'];
|
||||||
}
|
}
|
||||||
|
@ -180,7 +186,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
|
|
||||||
$title = Title::newFromText( $params['page'] );
|
$title = Title::newFromText( $params['page'] );
|
||||||
if ( !$title ) {
|
if ( !$title ) {
|
||||||
$this->dieUsageMsg( 'invalidtitle', $params['page'] );
|
$this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['page'] ) ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
$parserParams = [];
|
$parserParams = [];
|
||||||
|
@ -202,7 +208,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
if ( $title->exists() ) {
|
if ( $title->exists() ) {
|
||||||
$latestRevision = Revision::newFromTitle( $title );
|
$latestRevision = Revision::newFromTitle( $title );
|
||||||
if ( $latestRevision === null ) {
|
if ( $latestRevision === null ) {
|
||||||
$this->dieUsage( 'Could not find latest revision for title', 'latestnotfound' );
|
$this->dieWithError( 'apierror-visualeditor-latestnotfound', 'latestnotfound' );
|
||||||
}
|
}
|
||||||
$revision = null;
|
$revision = null;
|
||||||
if ( !isset( $parserParams['oldid'] ) || $parserParams['oldid'] === 0 ) {
|
if ( !isset( $parserParams['oldid'] ) || $parserParams['oldid'] === 0 ) {
|
||||||
|
@ -211,7 +217,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
} else {
|
} else {
|
||||||
$revision = Revision::newFromId( $parserParams['oldid'] );
|
$revision = Revision::newFromId( $parserParams['oldid'] );
|
||||||
if ( $revision === null ) {
|
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 ) {
|
if ( $content === false ) {
|
||||||
$this->dieUsage( 'Error contacting the document server', 'docserver' );
|
$this->dieWithError( 'apierror-visualeditor-docserver', 'docserver' );
|
||||||
}
|
}
|
||||||
} elseif ( $params['paction'] === 'wikitext' ) {
|
} elseif ( $params['paction'] === 'wikitext' ) {
|
||||||
$apiParams = [
|
$apiParams = [
|
||||||
|
@ -256,7 +262,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
$result['query']['pages'][$pid]['revisions']['0']['content'] :
|
$result['query']['pages'][$pid]['revisions']['0']['content'] :
|
||||||
false;
|
false;
|
||||||
if ( $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 );
|
$content = $this->parseWikitextFragment( $title, $wikitext );
|
||||||
if ( $content === false ) {
|
if ( $content === false ) {
|
||||||
$this->dieUsage( 'Error contacting the document server', 'docserver' );
|
$this->dieWithError( 'apierror-visualeditor-docserver', 'docserver' );
|
||||||
} else {
|
} else {
|
||||||
$result = [
|
$result = [
|
||||||
'result' => 'success',
|
'result' => 'success',
|
||||||
|
@ -481,7 +487,7 @@ class ApiVisualEditor extends ApiBase {
|
||||||
case 'getlanglinks':
|
case 'getlanglinks':
|
||||||
$langlinks = $this->getLangLinks( $title );
|
$langlinks = $this->getLangLinks( $title );
|
||||||
if ( $langlinks === false ) {
|
if ( $langlinks === false ) {
|
||||||
$this->dieUsage( 'Error querying MediaWiki API', 'api-langlinks-error' );
|
$this->dieWithError( 'apierror-visualeditor-api-langlinks-error', 'api-langlinks-error' );
|
||||||
} else {
|
} else {
|
||||||
$result = [ 'result' => 'success', 'langlinks' => $langlinks ];
|
$result = [ 'result' => 'success', 'langlinks' => $langlinks ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
||||||
$inflated = gzinflate( $deflated );
|
$inflated = gzinflate( $deflated );
|
||||||
wfRestoreWarnings();
|
wfRestoreWarnings();
|
||||||
if ( $deflated === $inflated || $inflated === false ) {
|
if ( $deflated === $inflated || $inflated === false ) {
|
||||||
$this->dieUsage( "Content provided is not properly deflated", 'invaliddeflate' );
|
$this->dieWithError( 'apierror-visualeditor-invaliddeflate', 'invaliddeflate' );
|
||||||
}
|
}
|
||||||
return $inflated;
|
return $inflated;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
||||||
if ( $params['cachekey'] !== null ) {
|
if ( $params['cachekey'] !== null ) {
|
||||||
$wikitext = $this->trySerializationCache( $params['cachekey'] );
|
$wikitext = $this->trySerializationCache( $params['cachekey'] );
|
||||||
if ( !is_string( $wikitext ) ) {
|
if ( !is_string( $wikitext ) ) {
|
||||||
$this->dieUsage( 'No cached serialization found with that key', 'badcachekey' );
|
$this->dieWithError( 'apierror-visualeditor-badcachekey', 'badcachekey' );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$wikitext = $this->getWikitextNoCache( $title, $params, $parserParams );
|
$wikitext = $this->getWikitextNoCache( $title, $params, $parserParams );
|
||||||
|
@ -145,7 +145,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
||||||
$title, $this->tryDeflate( $params['html'] ), $parserParams, $params['etag']
|
$title, $this->tryDeflate( $params['html'] ), $parserParams, $params['etag']
|
||||||
);
|
);
|
||||||
if ( $wikitext === false ) {
|
if ( $wikitext === false ) {
|
||||||
$this->dieUsage( 'Error contacting the document server', 'docserver' );
|
$this->dieWithError( 'apierror-visualeditor-docserver', 'docserver' );
|
||||||
}
|
}
|
||||||
return $wikitext;
|
return $wikitext;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
||||||
$params = $this->extractRequestParams();
|
$params = $this->extractRequestParams();
|
||||||
$title = Title::newFromText( $params['page'] );
|
$title = Title::newFromText( $params['page'] );
|
||||||
if ( !$title ) {
|
if ( !$title ) {
|
||||||
$this->dieUsageMsg( 'invalidtitle', $params['page'] );
|
$this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['page'] ) ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
$parserParams = [];
|
$parserParams = [];
|
||||||
|
@ -278,7 +278,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
||||||
$section = isset( $params['section'] ) ? $params['section'] : null;
|
$section = isset( $params['section'] ) ? $params['section'] : null;
|
||||||
$diff = $this->diffWikitext( $title, $wikitext, $section );
|
$diff = $this->diffWikitext( $title, $wikitext, $section );
|
||||||
if ( $diff['result'] === 'fail' ) {
|
if ( $diff['result'] === 'fail' ) {
|
||||||
$this->dieUsage( 'Diff failed', 'difffailed' );
|
$this->dieWithError( 'apierror-visualeditor-difffailed', 'difffailed' );
|
||||||
}
|
}
|
||||||
$result = $diff;
|
$result = $diff;
|
||||||
} elseif ( $params['paction'] === 'save' ) {
|
} elseif ( $params['paction'] === 'save' ) {
|
||||||
|
@ -319,7 +319,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
||||||
// frontend can update the page rendering without a refresh.
|
// frontend can update the page rendering without a refresh.
|
||||||
$result = $this->parseWikitext( $title, $newRevId );
|
$result = $this->parseWikitext( $title, $newRevId );
|
||||||
if ( $result === false ) {
|
if ( $result === false ) {
|
||||||
$this->dieUsage( 'Error contacting the Parsoid/RESTBase server', 'docserver' );
|
$this->dieWithError( 'apierror-visualeditor-docserver', 'docserver' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$result['isRedirect'] = (string) $title->isRedirect();
|
$result['isRedirect'] = (string) $title->isRedirect();
|
||||||
|
|
|
@ -48,6 +48,14 @@
|
||||||
"apihelp-visualeditoredit-param-summary": "Edit summary.",
|
"apihelp-visualeditoredit-param-summary": "Edit summary.",
|
||||||
"apihelp-visualeditoredit-param-watch": "",
|
"apihelp-visualeditoredit-param-watch": "",
|
||||||
"apihelp-visualeditoredit-param-wikitext": "",
|
"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-createsource": "Create the source code of this page",
|
||||||
"tooltip-ca-edit": "Edit this page using wikitext",
|
"tooltip-ca-edit": "Edit this page using wikitext",
|
||||||
"tooltip-ca-editsource": "Edit the source code of this page",
|
"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-summary": "{{doc-apihelp-param|visualeditoredit|summary}}\n{{Identical|Edit summary}}",
|
||||||
"apihelp-visualeditoredit-param-watch": "{{doc-apihelp-param|visualeditoredit|watch}}",
|
"apihelp-visualeditoredit-param-watch": "{{doc-apihelp-param|visualeditoredit|watch}}",
|
||||||
"apihelp-visualeditoredit-param-wikitext": "{{doc-apihelp-param|visualeditoredit|wikitext}}",
|
"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-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-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",
|
"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