/** * Add/remove change tags from all the revisions in the list. * * @param array $tagsToAdd * @param array $tagsToRemove * @param array $params * @param string $reason * @param User $user * @return Status */ public function updateChangeTagsOnAll($tagsToAdd, $tagsToRemove, $params, $reason, $user) { // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed for ($this->reset(); $this->current(); $this->next()) { // @codingStandardsIgnoreEnd $item = $this->current(); $status = ChangeTags::updateTagsWithChecks($tagsToAdd, $tagsToRemove, null, $item->getId(), null, $params, $reason, $user); // Should only fail on second and subsequent times if the user trips // the rate limiter if (!$status->isOK()) { break; } } return $status; }
protected function processIndividual($type, $params, $id) { $idResult = array($type => $id); // validate the ID $valid = false; switch ($type) { case 'rcid': $valid = RecentChange::newFromId($id); break; case 'revid': $valid = Revision::newFromId($id); break; case 'logid': $valid = self::validateLogId($id); break; } if (!$valid) { $idResult['status'] = 'error'; $idResult += $this->parseMsg(array("nosuch{$type}", $id)); return $idResult; } $status = ChangeTags::updateTagsWithChecks($params['add'], $params['remove'], $type === 'rcid' ? $id : null, $type === 'revid' ? $id : null, $type === 'logid' ? $id : null, null, $params['reason'], $this->getUser()); if (!$status->isOK()) { if ($status->hasMessage('actionthrottledtext')) { $idResult['status'] = 'skipped'; } else { $idResult['status'] = 'failure'; $idResult['errors'] = $this->getErrorFormatter()->arrayFromStatus($status, 'error'); } } else { $idResult['status'] = 'success'; if (is_null($status->value->logId)) { $idResult['noop'] = ''; } else { $idResult['actionlogid'] = $status->value->logId; $idResult['added'] = $status->value->addedTags; ApiResult::setIndexedTagName($idResult['added'], 't'); $idResult['removed'] = $status->value->removedTags; ApiResult::setIndexedTagName($idResult['removed'], 't'); } } return $idResult; }