[MediaWiki-commits] [Gerrit] mediawiki/core[master]: API: More i18n cleanup

2016-12-08 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/325990 )

Change subject: API: More i18n cleanup
..


API: More i18n cleanup

* Use errorformat for action=login Failed responses in non-BC mode.
* We removed 'messageHtml' from action=rollback's response on error, but
  left it for success. Remove it there too, it's even less useful.
* We changed action=watch's reporting of errors, but left the
  mostly-pointless reporting of "success" UI messages. These should be
  handled on the client side.

Change-Id: Ia6c402a4254fbacf4c2c3f125ce8bf0bcc71e509
---
M RELEASE-NOTES-1.29
M includes/api/ApiLogin.php
M includes/api/ApiRollback.php
M includes/api/ApiWatch.php
M resources/Resources.php
M resources/src/mediawiki/api/watch.js
M resources/src/mediawiki/page/watch.js
7 files changed, 30 insertions(+), 30 deletions(-)

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



diff --git a/RELEASE-NOTES-1.29 b/RELEASE-NOTES-1.29
index 986ecd8..0cce190 100644
--- a/RELEASE-NOTES-1.29
+++ b/RELEASE-NOTES-1.29
@@ -58,11 +58,12 @@
 * action=revisiondelete no longer includes a "rendered" property on warnings
   and errors for each item. Use errorformat=wikitext if you're wanting parsed
   output.
-* action=rollback no longer returns a "messageHtml" property on errors. Use
-  errorformat=html if you're wanting HTML formatting of messages.
+* action=rollback no longer returns a "messageHtml" property. Use
+  errorformat=html if you're wanting HTML formatting of error messages.
 * action=upload now reports optional stash failures as an array under key
   'stasherrors' rather than a 'stashfailed' text string.
-* action=watch reports 'errors' and 'warnings' instead of a single 'error'.
+* action=watch reports 'errors' and 'warnings' instead of a single 'error', and
+  no longer returns a 'message' on success.
 
 === Action API internal changes in 1.29 ===
 * New methods were added to ApiBase to handle errors and warnings using i18n
diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php
index 723dc33..6cf1fad 100644
--- a/includes/api/ApiLogin.php
+++ b/includes/api/ApiLogin.php
@@ -197,9 +197,14 @@
break;
 
case 'Failed':
-   $result['reason'] = 
ApiErrorFormatter::stripMarkup(
-   $message->useDatabase( false 
)->inLanguage( 'en' )->text()
-   );
+   $errorFormatter = $this->getErrorFormatter();
+   if ( $errorFormatter instanceof 
ApiErrorFormatter_BackCompat ) {
+   $result['reason'] = 
ApiErrorFormatter::stripMarkup(
+   $message->useDatabase( false 
)->inLanguage( 'en' )->text()
+   );
+   } else {
+   $result['reason'] = 
$errorFormatter->formatMessage( $message );
+   }
break;
 
case 'Aborted':
diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php
index c802087..9584f09 100644
--- a/includes/api/ApiRollback.php
+++ b/includes/api/ApiRollback.php
@@ -92,17 +92,6 @@
'last_revid' => intval( $details['target']->getID() )
];
 
-   $oldUser = $details['current']->getUserText( 
Revision::FOR_THIS_USER );
-   $lastUser = $details['target']->getUserText( 
Revision::FOR_THIS_USER );
-   $diffUrl = $titleObj->getFullURL( [
-   'diff' => $info['revid'],
-   'oldid' => $info['old_revid'],
-   'diffonly' => '1'
-   ] );
-   $info['messageHtml'] = $this->msg( 'rollback-success-notify' )
-   ->params( $oldUser, $lastUser, $diffUrl )
-   ->parseAsBlock();
-
$this->getResult()->addValue( null, $this->getModuleName(), 
$info );
}
 
diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php
index d257e90..88aff41 100644
--- a/includes/api/ApiWatch.php
+++ b/includes/api/ApiWatch.php
@@ -110,19 +110,9 @@
if ( $params['unwatch'] ) {
$status = UnwatchAction::doUnwatch( $title, $user );
$res['unwatched'] = $status->isOK();
-   if ( $status->isOK() ) {
-   $msgKey = $title->isTalkPage() ? 
'removedwatchtext-talk' : 'removedwatchtext';
-   $res['message'] = $this->msg( $msgKey, 
$title->getPrefixedText() )
-   ->title( $title )->parseAsBlock();
-   }
} else {
$status 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: API: More i18n cleanup

2016-12-08 Thread Anomie (Code Review)
Anomie has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/325990 )

Change subject: API: More i18n cleanup
..

API: More i18n cleanup

* Use errorformat for action=login Failed responses in non-BC mode.
* We removed 'messageHtml' from action=rollback's response on error, but
  left it for success. Remove it there too, it's even less useful.
* We changed action=watch's reporting of errors, but left the
  mostly-pointless reporting of "success" UI messages. These should be
  handled on the client side.

Change-Id: Ia6c402a4254fbacf4c2c3f125ce8bf0bcc71e509
---
M RELEASE-NOTES-1.29
M includes/api/ApiLogin.php
M includes/api/ApiRollback.php
M includes/api/ApiWatch.php
M resources/Resources.php
M resources/src/mediawiki/api/watch.js
M resources/src/mediawiki/page/watch.js
7 files changed, 30 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/90/325990/1

diff --git a/RELEASE-NOTES-1.29 b/RELEASE-NOTES-1.29
index 986ecd8..93d8cc0 100644
--- a/RELEASE-NOTES-1.29
+++ b/RELEASE-NOTES-1.29
@@ -58,11 +58,12 @@
 * action=revisiondelete no longer includes a "rendered" property on warnings
   and errors for each item. Use errorformat=wikitext if you're wanting parsed
   output.
-* action=rollback no longer returns a "messageHtml" property on errors. Use
-  errorformat=html if you're wanting HTML formatting of messages.
+* action=rollback no longer returns a "messageHtml" property. Use
+  errorformat=html if you're wanting HTML formatting of error message.
 * action=upload now reports optional stash failures as an array under key
   'stasherrors' rather than a 'stashfailed' text string.
-* action=watch reports 'errors' and 'warnings' instead of a single 'error'.
+* action=watch reports 'errors' and 'warnings' instead of a single 'error', and
+  no longer returns a 'message' on success.
 
 === Action API internal changes in 1.29 ===
 * New methods were added to ApiBase to handle errors and warnings using i18n
diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php
index 723dc33..6cf1fad 100644
--- a/includes/api/ApiLogin.php
+++ b/includes/api/ApiLogin.php
@@ -197,9 +197,14 @@
break;
 
case 'Failed':
-   $result['reason'] = 
ApiErrorFormatter::stripMarkup(
-   $message->useDatabase( false 
)->inLanguage( 'en' )->text()
-   );
+   $errorFormatter = $this->getErrorFormatter();
+   if ( $errorFormatter instanceof 
ApiErrorFormatter_BackCompat ) {
+   $result['reason'] = 
ApiErrorFormatter::stripMarkup(
+   $message->useDatabase( false 
)->inLanguage( 'en' )->text()
+   );
+   } else {
+   $result['reason'] = 
$errorFormatter->formatMessage( $message );
+   }
break;
 
case 'Aborted':
diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php
index c802087..9584f09 100644
--- a/includes/api/ApiRollback.php
+++ b/includes/api/ApiRollback.php
@@ -92,17 +92,6 @@
'last_revid' => intval( $details['target']->getID() )
];
 
-   $oldUser = $details['current']->getUserText( 
Revision::FOR_THIS_USER );
-   $lastUser = $details['target']->getUserText( 
Revision::FOR_THIS_USER );
-   $diffUrl = $titleObj->getFullURL( [
-   'diff' => $info['revid'],
-   'oldid' => $info['old_revid'],
-   'diffonly' => '1'
-   ] );
-   $info['messageHtml'] = $this->msg( 'rollback-success-notify' )
-   ->params( $oldUser, $lastUser, $diffUrl )
-   ->parseAsBlock();
-
$this->getResult()->addValue( null, $this->getModuleName(), 
$info );
}
 
diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php
index d257e90..88aff41 100644
--- a/includes/api/ApiWatch.php
+++ b/includes/api/ApiWatch.php
@@ -110,19 +110,9 @@
if ( $params['unwatch'] ) {
$status = UnwatchAction::doUnwatch( $title, $user );
$res['unwatched'] = $status->isOK();
-   if ( $status->isOK() ) {
-   $msgKey = $title->isTalkPage() ? 
'removedwatchtext-talk' : 'removedwatchtext';
-   $res['message'] = $this->msg( $msgKey, 
$title->getPrefixedText() )
-   ->title( $title )->parseAsBlock();
-   }
} else {
$status =