*/
class ApiTag extends ApiBase {
- protected function getAvailableTags() {
- return ChangeTags::listExplicitlyDefinedTags();
- }
-
public function execute() {
$params = $this->extractRequestParams();
$user = $this->getUser();
}
if ( $user->isBlocked() ) {
- $block = $user->getBlock();
-
- // Die using the appropriate messege 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 ) )
- );
- }
+ $this->dieBlocked( $user->getBlock() );
}
// validate and process each revid, rcid and logid
$this->requireAtLeastOneParameter( $params, 'revid', 'rcid', 'logid' );
- $ret = array();
+ $ret = [];
if ( $params['revid'] ) {
foreach ( $params['revid'] as $id ) {
$ret[] = $this->processIndividual( 'revid', $params, $id );
}
protected static function validateLogId( $logid ) {
- $dbr = wfGetDB( DB_SLAVE );
- $result = $dbr->selectField( 'logging', 'log_id', array( 'log_id' => $logid ),
+ $dbr = wfGetDB( DB_REPLICA );
+ $result = $dbr->selectField( 'logging', 'log_id', [ 'log_id' => $logid ],
__METHOD__ );
return (bool)$result;
}
protected function processIndividual( $type, $params, $id ) {
- $idResult = array( $type => $id );
+ $idResult = [ $type => $id ];
// validate the ID
$valid = false;
if ( !$valid ) {
$idResult['status'] = 'error';
- $idResult += $this->parseMsg( array( "nosuch$type", $id ) );
+ $idResult += $this->parseMsg( [ "nosuch$type", $id ] );
return $idResult;
}
}
public function getAllowedParams() {
- return array(
- 'rcid' => array(
+ return [
+ 'rcid' => [
ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_ISMULTI => true,
- ),
- 'revid' => array(
+ ],
+ 'revid' => [
ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_ISMULTI => true,
- ),
- 'logid' => array(
+ ],
+ 'logid' => [
ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_ISMULTI => true,
- ),
- 'add' => array(
- ApiBase::PARAM_TYPE => $this->getAvailableTags(),
+ ],
+ 'add' => [
+ ApiBase::PARAM_TYPE => 'tags',
ApiBase::PARAM_ISMULTI => true,
- ),
- 'remove' => array(
+ ],
+ 'remove' => [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_ISMULTI => true,
- ),
- 'reason' => array(
+ ],
+ 'reason' => [
ApiBase::PARAM_DFLT => '',
- ),
- );
+ ],
+ ];
}
public function needsToken() {
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=tag&revid=123&add=vandalism&token=123ABC'
=> 'apihelp-tag-example-rev',
'action=tag&logid=123&remove=spam&reason=Wrongly+applied&token=123ABC'
=> 'apihelp-tag-example-log',
- );
+ ];
}
public function getHelpUrls() {