*/
class ApiTag extends ApiBase {
- protected function getAvailableTags() {
- return ChangeTags::listExplicitlyDefinedTags();
- }
-
public function execute() {
$params = $this->extractRequestParams();
$user = $this->getUser();
// 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() {