X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryLogEvents.php;h=b607ca543ec70b18d56da0845302bb99e4bd8b25;hb=b5993f884a3c4b0012fca120d3625452408c159d;hp=1578775a1c2b9b7bf1ec3e35d2a0be5c5978e0f5;hpb=e67407a97985fd73b63bbe1c3620ca37afae24b2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index 1578775a1c..b607ca543e 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -65,7 +65,6 @@ class ApiQueryLogEvents extends ApiQueryBase { // Order is significant here $this->addTables( array( 'logging', 'user', 'page' ) ); - $this->addOption( 'STRAIGHT_JOIN' ); $this->addJoinConds( array( 'user' => array( 'LEFT JOIN', 'user_id=log_user' ), @@ -104,7 +103,26 @@ class ApiQueryLogEvents extends ApiQueryBase { } if ( !is_null( $params['action'] ) ) { - list( $type, $action ) = explode( '/', $params['action'] ); + // Do validation of action param, list of allowed actions can contains wildcards + // Allow the param, when the actions is in the list or a wildcard version is listed. + $logAction = $params['action']; + if ( strpos( $logAction, '/' ) === false ) { + // all items in the list have a slash + $valid = false; + } else { + $logActions = array_flip( $this->getAllowedLogActions() ); + list( $type, $action ) = explode( '/', $logAction, 2 ); + $valid = isset( $logActions[$logAction] ) || isset( $logActions[$type . '/*'] ); + } + + if ( !$valid ) { + $valueName = $this->encodeParamName( 'action' ); + $this->dieUsage( + "Unrecognized value for parameter '$valueName': {$logAction}", + "unknown_$valueName" + ); + } + $this->addWhereFld( 'log_type', $type ); $this->addWhereFld( 'log_action', $action ); } elseif ( !is_null( $params['type'] ) ) { @@ -405,6 +423,12 @@ class ApiQueryLogEvents extends ApiQueryBase { return $vals; } + private function getAllowedLogActions() { + global $wgLogActions, $wgLogActionsHandlers; + + return array_keys( array_merge( $wgLogActions, $wgLogActionsHandlers ) ); + } + public function getCacheMode( $params ) { if ( $this->userCanSeeRevDel() ) { return 'private'; @@ -421,8 +445,8 @@ class ApiQueryLogEvents extends ApiQueryBase { } } - public function getAllowedParams() { - global $wgLogTypes, $wgLogActions, $wgLogActionsHandlers; + public function getAllowedParams( $flags = 0 ) { + global $wgLogTypes; return array( 'prop' => array( @@ -445,7 +469,10 @@ class ApiQueryLogEvents extends ApiQueryBase { ApiBase::PARAM_TYPE => $wgLogTypes ), 'action' => array( - ApiBase::PARAM_TYPE => array_keys( array_merge( $wgLogActions, $wgLogActionsHandlers ) ) + // validation on request is done in execute() + ApiBase::PARAM_TYPE => ( $flags & ApiBase::GET_VALUES_FOR_HELP ) + ? $this->getAllowedLogActions() + : null ), 'start' => array( ApiBase::PARAM_TYPE => 'timestamp' @@ -492,7 +519,10 @@ class ApiQueryLogEvents extends ApiQueryBase { ' tags - Lists tags for the event', ), 'type' => 'Filter log entries to only this type', - 'action' => "Filter log actions to only this type. Overrides {$p}type", + 'action' => array( + "Filter log actions to only this action. Overrides {$p}type", + "Wildcard actions like 'action/*' allows to specify any string for the asterisk" + ), 'start' => 'The timestamp to start enumerating from', 'end' => 'The timestamp to end enumerating', 'dir' => $this->getDirectionDescription( $p ), @@ -562,7 +592,7 @@ class ApiQueryLogEvents extends ApiQueryBase { } public function getDescription() { - return 'Get events from logs'; + return 'Get events from logs.'; } public function getPossibleErrors() {