Anomie has uploaded a new change for review.

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

Change subject: API: Update ApiTag, fix error handling
......................................................................

API: Update ApiTag, fix error handling

Change I7b37295e didn't get rebased to take into account the new ApiTag
module added the same day. So update it now.

Also fix some errors in error handling noticed while testing this
update.

Bug: T96251
Bug: T96252
Change-Id: If8b63af91547e117b9d7d88e2ec9739131ee09b7
---
M includes/api/ApiTag.php
1 file changed, 10 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/17/204517/1

diff --git a/includes/api/ApiTag.php b/includes/api/ApiTag.php
index fcf0ac1..527c6cb 100644
--- a/includes/api/ApiTag.php
+++ b/includes/api/ApiTag.php
@@ -40,26 +40,25 @@
 
                // validate and process each revid, rcid and logid
                $this->requireAtLeastOneParameter( $params, 'revid', 'rcid', 
'logid' );
-               $result = $this->getResult();
                $ret = array();
                if ( $params['revid'] ) {
                        foreach ( $params['revid'] as $id ) {
-                               $ret[] = $this->processIndividual( 'revid', 
$params, $id, $result );
+                               $ret[] = $this->processIndividual( 'revid', 
$params, $id );
                        }
                }
                if ( $params['rcid'] ) {
                        foreach ( $params['rcid'] as $id ) {
-                               $ret[] = $this->processIndividual( 'rcid', 
$params, $id, $result );
+                               $ret[] = $this->processIndividual( 'rcid', 
$params, $id );
                        }
                }
                if ( $params['logid'] ) {
                        foreach ( $params['logid'] as $id ) {
-                               $ret[] = $this->processIndividual( 'logid', 
$params, $id, $result );
+                               $ret[] = $this->processIndividual( 'logid', 
$params, $id );
                        }
                }
 
-               $result->setIndexedTagName( $ret, 'result' );
-               $result->addValue( null, $this->getModuleName(), $ret );
+               ApiResult::setIndexedTagName( $ret, 'result' );
+               $this->getResult()->addValue( null, $this->getModuleName(), 
$ret );
        }
 
        protected static function validateLogId( $logid ) {
@@ -69,7 +68,7 @@
                return (bool)$result;
        }
 
-       protected function processIndividual( $type, $params, $id, &$result ) {
+       protected function processIndividual( $type, $params, $id ) {
                $idResult = array( $type => $id );
 
                // validate the ID
@@ -102,11 +101,11 @@
                        $this->getUser() );
 
                if ( !$status->isOK() ) {
-                       if ( $status->hasWarning( 'actionthrottledtext' ) ) {
+                       if ( $status->hasMessage( 'actionthrottledtext' ) ) {
                                $idResult['status'] = 'skipped';
                        } else {
                                $idResult['status'] = 'failure';
-                               $ret['errors'] = $result->convertStatusToArray( 
$status, 'error' );
+                               $idResult['errors'] = 
$this->getErrorFormatter()->arrayFromStatus( $status, 'error' );
                        }
                } else {
                        $idResult['status'] = 'success';
@@ -115,9 +114,9 @@
                        } else {
                                $idResult['actionlogid'] = 
$status->value->logId;
                                $idResult['added'] = $status->value->addedTags;
-                               $result->setIndexedTagName( $idResult['added'], 
't' );
+                               ApiResult::setIndexedTagName( 
$idResult['added'], 't' );
                                $idResult['removed'] = 
$status->value->removedTags;
-                               $result->setIndexedTagName( 
$idResult['removed'], 't' );
+                               ApiResult::setIndexedTagName( 
$idResult['removed'], 't' );
                        }
                }
                return $idResult;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If8b63af91547e117b9d7d88e2ec9739131ee09b7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <bjor...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to