[MediaWiki-commits] [Gerrit] Provide useful error details when publishing fails - change (mediawiki...ContentTranslation)

2015-07-28 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Provide useful error details when publishing fails
..


Provide useful error details when publishing fails

From our logs, we see 4 main reasons for publishing failures.
1. Timeout. Related to network.
2. spamblacklist catching URLs in translation.
3. User blocked from editing.
   Now we don't allow these users to see Special:CX at all, see
   Ib6cdcc2e5f6e7fc631e5ff7d1d3a4f812f5fa6a6
4. Parsoid failed to convert the HTML to wikitext.

For all of these, provide a brief hint in the publishing error message.

Testplan:
Here is a way to trick CX and create a publishing error:
Translate any article.
Add a section without any reference to translation.
Clear the paragraph completely. The publish button will get disabled.
Now type a space in the empty paragraph.
The publish button will get enabled again.
Publish the page and get the error:
"An error occurred while publishing the translation.
Please try to publish the page again. Error: html cannot be empty".

Bug: T100498
Change-Id: Ia96ec15a4d44c7c1403542bdd1e25660984fad8b
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M modules/publish/ext.cx.publish.js
4 files changed, 21 insertions(+), 5 deletions(-)

Approvals:
  Amire80: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index c20fdb5..ea27279 100644
--- a/extension.json
+++ b/extension.json
@@ -631,7 +631,8 @@
"cx-publish-page-success",
"cx-publish-page-error",
"cx-publish-button-publishing",
-   "cx-publish-captcha-title"
+   "cx-publish-captcha-title",
+   "unknown-error"
]
},
"ext.cx.wikibase.link": {
diff --git a/i18n/en.json b/i18n/en.json
index 2d3355b..5a571d8 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -28,7 +28,7 @@
"cx-header-all-translations": "All translations",
"cx-source-view-page": "view page",
"cx-publish-page-success": "Page published at $1",
-   "cx-publish-page-error": "An error occurred while saving the page. 
Please try to publish the page again.",
+   "cx-publish-page-error": "An error occurred while publishing the 
translation. Please try to publish the page again. Error: $1",
"cx-publish-button": "Publish translation",
"cx-publish-button-publishing": "Publishing...",
"cx-publish-summary": "Created by translating the page \"$1\"",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 39098d5..520a025 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -33,7 +33,7 @@
"cx-header-all-translations": "A link at the top of the translation 
interface to the main Special:ContentTranslation page that lists all 
translations by the user.\n{{Identical|All translations}}",
"cx-source-view-page": "A link that points to the source page under the 
heading of the source column.\n{{Identical|View page}}",
"cx-publish-page-success": "Message shown when page is published 
successfully. Parameters:\n* $1 - Link to the published page",
-   "cx-publish-page-error": "Error message to display when page saving 
fails.",
+   "cx-publish-page-error": "Error message to display when page saving 
fails.\n* $1 - Error details",
"cx-publish-button": "Publish button text in 
[[Special:ContentTranslation]].\n\nAlso used in 
{{msg-mw|Cx-tools-instructions-text6}}.",
"cx-publish-button-publishing": "Publish button text in 
[[Special:ContentTranslation]], shown while publishing is in progress. Replaces 
{{msg-mw|cx-publish-button}}.\n{{Identical|Publishing}}",
"cx-publish-summary": "This is an automatic edit summary for pages that 
were created by [[Special:ContentTranslation]].\n\nParameters:\n* $1 - the 
source page name",
diff --git a/modules/publish/ext.cx.publish.js 
b/modules/publish/ext.cx.publish.js
index 2ff31eb..03a17e4 100644
--- a/modules/publish/ext.cx.publish.js
+++ b/modules/publish/ext.cx.publish.js
@@ -292,7 +292,9 @@
 * @param {object} details
 */
CXPublish.prototype.onFail = function ( code, details ) {
-   var trace = {
+   var trace, error;
+
+   trace = {
sourceLanguage: mw.cx.sourceLanguage,
targetLanguage: mw.cx.targetLanguage,
sourceTitle: mw.cx.sourceTitle,
@@ -309,7 +311,20 @@
JSON.stringify( details )
);
 
-   mw.hook( 'mw.cx.error' ).fire( mw.msg( 'cx-publish-page-error' 
) );
+   // Try providing useful error information. "Unknown" by default.
+   error = mw.msg( 'unknown-error' );
+   if ( details.error && details.error.info ) {
+  

[MediaWiki-commits] [Gerrit] Provide useful error details when publishing fails - change (mediawiki...ContentTranslation)

2015-07-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

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

Change subject: Provide useful error details when publishing fails
..

Provide useful error details when publishing fails

From our logs, we see 4 main reasons for publishing failures.
1. Timeout. Related to network.
2. spamblacklist catching URLs in translation
3. User blocked from editing. Now we are not providing Special:CX at all for 
this
   category of users
4. Parsoid failed to convert the HTML to wikitext.

For all of these provide a brief hint in publishing error message.

Bug: T100498
Change-Id: Ia96ec15a4d44c7c1403542bdd1e25660984fad8b
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M modules/publish/ext.cx.publish.js
4 files changed, 20 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/09/227409/1

diff --git a/extension.json b/extension.json
index c20fdb5..ea27279 100644
--- a/extension.json
+++ b/extension.json
@@ -631,7 +631,8 @@
"cx-publish-page-success",
"cx-publish-page-error",
"cx-publish-button-publishing",
-   "cx-publish-captcha-title"
+   "cx-publish-captcha-title",
+   "unknown-error"
]
},
"ext.cx.wikibase.link": {
diff --git a/i18n/en.json b/i18n/en.json
index a965998..304ce59 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -28,7 +28,7 @@
"cx-header-all-translations": "All translations",
"cx-source-view-page": "view page",
"cx-publish-page-success": "Page published at $1",
-   "cx-publish-page-error": "An error occurred while saving the page. 
Please try to publish the page again.",
+   "cx-publish-page-error": "An error occurred while publishing the 
translation. Please try to publish the page again. Error: $1",
"cx-publish-button": "Publish translation",
"cx-publish-button-publishing": "Publishing...",
"cx-publish-summary": "Created by translating the page \"$1\"",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 2a2ded0..049b7b1 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -33,7 +33,7 @@
"cx-header-all-translations": "A link at the top of the translation 
interface to the main Special:ContentTranslation page that lists all 
translations by the user.\n{{Identical|All translations}}",
"cx-source-view-page": "A link that points to the source page under the 
heading of the source column.\n{{Identical|View page}}",
"cx-publish-page-success": "Message shown when page is published 
successfully. Parameters:\n* $1 - Link to the published page",
-   "cx-publish-page-error": "Error message to display when page saving 
fails.",
+   "cx-publish-page-error": "Error message to display when page saving 
fails.\n* $1 - Error details",
"cx-publish-button": "Publish button text in 
[[Special:ContentTranslation]].\n\nAlso used in 
{{msg-mw|Cx-tools-instructions-text6}}.",
"cx-publish-button-publishing": "Publish button text in 
[[Special:ContentTranslation]], shown while publishing is in progress. Replaces 
{{msg-mw|cx-publish-button}}.\n{{Identical|Publishing}}",
"cx-publish-summary": "This is an automatic edit summary for pages that 
were created by [[Special:ContentTranslation]].\n\nParameters:\n* $1 - the 
source page name",
diff --git a/modules/publish/ext.cx.publish.js 
b/modules/publish/ext.cx.publish.js
index b658e28..de38895 100644
--- a/modules/publish/ext.cx.publish.js
+++ b/modules/publish/ext.cx.publish.js
@@ -289,7 +289,8 @@
 * @param {object} details
 */
CXPublish.prototype.onFail = function ( code, details ) {
-   var trace = {
+   var trace, error;
+   trace = {
sourceLanguage: mw.cx.sourceLanguage,
targetLanguage: mw.cx.targetLanguage,
sourceTitle: mw.cx.sourceTitle,
@@ -305,8 +306,20 @@
this.targetTitle,
JSON.stringify( details )
);
-
-   mw.hook( 'mw.cx.error' ).fire( mw.msg( 'cx-publish-page-error' 
) );
+   // Try providing useful error information.
+   error = mw.msg( 'unknown-error' );
+   if ( details.error && details.error.info ) {
+   // 
{"servedby":"mw","error":{"code":"blocked","info":"You have been blocked 
from editing",
+   // "*":"See ..
+   error = details.error.info;
+   } else if ( details.edit ) {
+   // 
{"result":"error","edit":{"spamblacklist":"facebook.com","result":"Failure"}}
+   error = JSON.stringify( details.edit )