* (bug 22738) Allow filtering by action type on query=logevent
authorSam Reed <reedy@users.mediawiki.org>
Fri, 5 Mar 2010 23:21:38 +0000 (23:21 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Fri, 5 Mar 2010 23:21:38 +0000 (23:21 +0000)
Needs patrol fixing (but not an api problem)

RELEASE-NOTES
includes/api/ApiQueryLogEvents.php

index d33bf3a..2978fa9 100644 (file)
@@ -42,6 +42,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 22353) Categorised recent changes now works again
 
 == API changes in 1.17 ==
+* (bug 22738) Allow filtering by action type on query=logevent
 
 === Languages updated in 1.17 ===
 
index aa36b85..9df96a2 100644 (file)
@@ -48,6 +48,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                $this->fld_ids = isset( $prop['ids'] );
                $this->fld_title = isset( $prop['title'] );
                $this->fld_type = isset( $prop['type'] );
+               $this->fld_action = isset ( $prop['action'] );
                $this->fld_user = isset( $prop['user'] );
                $this->fld_timestamp = isset( $prop['timestamp'] );
                $this->fld_comment = isset( $prop['comment'] );
@@ -103,7 +104,10 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        $index['change_tag'] = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
                }
 
-               if ( !is_null( $params['type'] ) ) {
+               if ( !is_null( $params['action'] ) ) {
+                       $this->addWhereFld( 'log_action', substr( $params['action'], strrpos( $params['action'], "/" ) + 1 ) );
+               }
+               else if ( !is_null( $params['type'] ) ) {
                        $this->addWhereFld( 'log_type', $params['type'] );
                        $index['logging'] = 'type_time';
                }
@@ -232,8 +236,8 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                ApiQueryBase::addTitleInfo( $vals, $title );
                        }
                }
-
-               if ( $this->fld_type ) {
+               
+               if ( $this->fld_type || $this->fld_action ) {
                        $vals['type'] = $row->log_type;
                        $vals['action'] = $row->log_action;
                }
@@ -292,7 +296,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
        }
 
        public function getAllowedParams() {
-               global $wgLogTypes;
+               global $wgLogTypes, $wgLogActions;
                return array(
                        'prop' => array(
                                ApiBase::PARAM_ISMULTI => true,
@@ -312,6 +316,9 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        'type' => array(
                                ApiBase::PARAM_TYPE => $wgLogTypes
                        ),
+                       'action' => array(
+                               ApiBase::PARAM_TYPE => array_keys( $wgLogActions )
+                       ),
                        'start' => array(
                                ApiBase::PARAM_TYPE => 'timestamp'
                        ),
@@ -342,6 +349,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                return array(
                        'prop' => 'Which properties to get',
                        'type' => 'Filter log entries to only this type(s)',
+                       'action' => "Filter log actions to only this type. Overrides {$this->getModulePrefix()}type",
                        'start' => 'The timestamp to start enumerating from.',
                        'end' => 'The timestamp to end enumerating.',
                        'dir' => 'In which direction to enumerate.',