/** * Get the list object for this request * @return RevDelList */ protected function getList() { if (is_null($this->revDelList)) { $this->revDelList = RevisionDeleter::createList($this->typeName, $this->getContext(), $this->targetObj, $this->ids); } return $this->revDelList; }
public function execute() { $this->useTransactionalTimeLimit(); $params = $this->extractRequestParams(); $user = $this->getUser(); if (!$user->isAllowed(RevisionDeleter::getRestriction($params['type']))) { $this->dieUsageMsg('badaccess-group0'); } if ($user->isBlocked()) { $block = $user->getBlock(); // Die using the appropriate message depending on block type if ($block->getType() == TYPE_AUTO) { $this->dieUsage('Your IP address has been blocked automatically, because it was used by a blocked user', 'autoblocked', 0, array('blockinfo' => ApiQueryUserInfo::getBlockInfo($block))); } else { $this->dieUsage('You have been blocked from editing', 'blocked', 0, array('blockinfo' => ApiQueryUserInfo::getBlockInfo($block))); } } if (!$params['ids']) { $this->dieUsage("At least one value is required for 'ids'", 'badparams'); } $hide = $params['hide'] ?: array(); $show = $params['show'] ?: array(); if (array_intersect($hide, $show)) { $this->dieUsage("Mutually exclusive values for 'hide' and 'show'", 'badparams'); } elseif (!$hide && !$show) { $this->dieUsage("At least one value is required for 'hide' or 'show'", 'badparams'); } $bits = array('content' => RevisionDeleter::getRevdelConstant($params['type']), 'comment' => Revision::DELETED_COMMENT, 'user' => Revision::DELETED_USER); $bitfield = array(); foreach ($bits as $key => $bit) { if (in_array($key, $hide)) { $bitfield[$bit] = 1; } elseif (in_array($key, $show)) { $bitfield[$bit] = 0; } else { $bitfield[$bit] = -1; } } if ($params['suppress'] === 'yes') { if (!$user->isAllowed('suppressrevision')) { $this->dieUsageMsg('badaccess-group0'); } $bitfield[Revision::DELETED_RESTRICTED] = 1; } elseif ($params['suppress'] === 'no') { $bitfield[Revision::DELETED_RESTRICTED] = 0; } else { $bitfield[Revision::DELETED_RESTRICTED] = -1; } $targetObj = null; if ($params['target']) { $targetObj = Title::newFromText($params['target']); } $targetObj = RevisionDeleter::suggestTarget($params['type'], $targetObj, $params['ids']); if ($targetObj === null) { $this->dieUsage('A target title is required for this RevDel type', 'needtarget'); } $list = RevisionDeleter::createList($params['type'], $this->getContext(), $targetObj, $params['ids']); $status = $list->setVisibility(array('value' => $bitfield, 'comment' => $params['reason'], 'perItemStatus' => true)); $result = $this->getResult(); $data = $this->extractStatusInfo($status); $data['target'] = $targetObj->getFullText(); $data['items'] = array(); foreach ($status->itemStatuses as $id => $s) { $data['items'][$id] = $this->extractStatusInfo($s); $data['items'][$id]['id'] = $id; } $list->reloadFromMaster(); // @codingStandardsIgnoreStart Avoid function calls in a FOR loop test part for ($item = $list->reset(); $list->current(); $item = $list->next()) { $data['items'][$item->getId()] += $item->getApiData($this->getResult()); } // @codingStandardsIgnoreEnd $data['items'] = array_values($data['items']); ApiResult::setIndexedTagName($data['items'], 'i'); $result->addValue(null, $this->getModuleName(), $data); }