jenkins-bot has submitted this change and it was merged. 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(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified 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: merged Gerrit-Change-Id: If8b63af91547e117b9d7d88e2ec9739131ee09b7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: TTO <at.li...@live.com.au> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits