Merge "Separate select() parameter summary from detail"
[lhc/web/wiklou.git] / includes / api / ApiQueryLogEvents.php
index 2d9d710..7cd8aac 100644 (file)
@@ -187,8 +187,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                $prefix = $params['prefix'];
 
                if ( !is_null( $prefix ) ) {
-                       global $wgMiserMode;
-                       if ( $wgMiserMode ) {
+                       if ( $this->getConfig()->get( 'MiserMode' ) ) {
                                $this->dieUsage( 'Prefix search disabled in Miser Mode', 'prefixsearchdisabled' );
                        }
 
@@ -205,7 +204,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        if ( !$this->getUser()->isAllowed( 'deletedhistory' ) ) {
                                $titleBits = LogPage::DELETED_ACTION;
                                $userBits = LogPage::DELETED_USER;
-                       } elseif ( !$this->getUser()->isAllowed( 'suppressrevision' ) ) {
+                       } elseif ( !$this->getUser()->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
                                $titleBits = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
                                $userBits = LogPage::DELETED_USER | LogPage::DELETED_RESTRICTED;
                        } else {
@@ -404,7 +403,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                        $vals['user'] = $row->user_name === null ? $row->log_user_text : $row->user_name;
                                }
                                if ( $this->fld_userid ) {
-                                       $vals['userid'] = $row->log_user;
+                                       $vals['userid'] = intval( $row->log_user );
                                }
 
                                if ( !$row->log_user ) {
@@ -449,10 +448,12 @@ class ApiQueryLogEvents extends ApiQueryBase {
                return $vals;
        }
 
+       /**
+        * @return array
+        */
        private function getAllowedLogActions() {
-               global $wgLogActions, $wgLogActionsHandlers;
-
-               return array_keys( array_merge( $wgLogActions, $wgLogActionsHandlers ) );
+               $config = $this->getConfig();
+               return array_keys( array_merge( $config->get( 'LogActions' ), $config->get( 'LogActionsHandlers' ) ) );
        }
 
        public function getCacheMode( $params ) {
@@ -472,8 +473,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
        }
 
        public function getAllowedParams( $flags = 0 ) {
-               global $wgLogTypes;
-
+               $config = $this->getConfig();
                return array(
                        'prop' => array(
                                ApiBase::PARAM_ISMULTI => true,
@@ -492,7 +492,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                )
                        ),
                        'type' => array(
-                               ApiBase::PARAM_TYPE => $wgLogTypes
+                               ApiBase::PARAM_TYPE => $config->get( 'LogTypes' )
                        ),
                        'action' => array(
                                // validation on request is done in execute()
@@ -567,8 +567,6 @@ class ApiQueryLogEvents extends ApiQueryBase {
        }
 
        public function getResultProperties() {
-               global $wgLogTypes;
-
                return array(
                        'ids' => array(
                                'logid' => 'integer',
@@ -580,7 +578,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                        ),
                        'type' => array(
                                'type' => array(
-                                       ApiBase::PROP_TYPE => $wgLogTypes
+                                       ApiBase::PROP_TYPE => $this->getConfig()->get( 'LogTypes' )
                                ),
                                'action' => 'string'
                        ),
@@ -628,12 +626,18 @@ class ApiQueryLogEvents extends ApiQueryBase {
        }
 
        public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(), array(
-                       array( 'code' => 'param_user', 'info' => 'User name $user not found' ),
-                       array( 'code' => 'param_title', 'info' => 'Bad title value \'title\'' ),
-                       array( 'code' => 'param_prefix', 'info' => 'Bad title value \'prefix\'' ),
-                       array( 'code' => 'prefixsearchdisabled', 'info' => 'Prefix search disabled in Miser Mode' ),
-               ) );
+               return array_merge(
+                       parent::getPossibleErrors(),
+                       $this->getRequireMaxOneParameterErrorMessages(
+                               array( 'title', 'prefix', 'namespace' ) ),
+                       array(
+                               array( 'code' => 'param_user', 'info' => 'User name $user not found' ),
+                               array( 'code' => 'param_title', 'info' => 'Bad title value \'title\'' ),
+                               array( 'code' => 'param_prefix', 'info' => 'Bad title value \'prefix\'' ),
+                               array( 'code' => 'prefixsearchdisabled',
+                                       'info' => 'Prefix search disabled in Miser Mode' ),
+                       )
+               );
        }
 
        public function getExamples() {