X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiTag.php;h=f88c2dbc62f2dd3d7d5496f3d619be9f085e7bde;hb=f8ab05a4819525c32e2b05ae92e23f2f56efcf81;hp=4bf799ec90bc8b55451acd57bd2c62880b821ffd;hpb=a7f35b785943ecf471095e79bc907aa5bbe228ca;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiTag.php b/includes/api/ApiTag.php index 4bf799ec90..f88c2dbc62 100644 --- a/includes/api/ApiTag.php +++ b/includes/api/ApiTag.php @@ -25,10 +25,6 @@ */ class ApiTag extends ApiBase { - protected function getAvailableTags() { - return ChangeTags::listExplicitlyDefinedTags(); - } - public function execute() { $params = $this->extractRequestParams(); $user = $this->getUser(); @@ -45,7 +41,7 @@ class ApiTag extends ApiBase { // 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 ); @@ -67,14 +63,14 @@ class ApiTag extends ApiBase { } 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; @@ -92,7 +88,7 @@ class ApiTag extends ApiBase { if ( !$valid ) { $idResult['status'] = 'error'; - $idResult += $this->parseMsg( array( "nosuch$type", $id ) ); + $idResult += $this->parseMsg( [ "nosuch$type", $id ] ); return $idResult; } @@ -136,31 +132,31 @@ class ApiTag extends ApiBase { } 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() { @@ -168,12 +164,12 @@ class ApiTag extends ApiBase { } 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() {