Merge "Use User::groupHasPermission"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 12 Mar 2013 14:52:31 +0000 (14:52 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 12 Mar 2013 14:52:31 +0000 (14:52 +0000)
1  2 
includes/api/ApiMain.php

diff --combined includes/api/ApiMain.php
@@@ -145,7 -145,7 +145,7 @@@ class ApiMain extends ApiBase 
         * Constructs an instance of ApiMain that utilizes the module and format specified by $request.
         *
         * @param $context IContextSource|WebRequest - if this is an instance of FauxRequest, errors are thrown and no printing occurs
 -       * @param $enableWrite bool should be set to true if the api may modify data
 +       * @param bool $enableWrite should be set to true if the api may modify data
         */
        public function __construct( $context = null, $enableWrite = false ) {
                if ( $context === null ) {
        /**
         * Set the type of caching headers which will be sent.
         *
 -       * @param $mode String One of:
 +       * @param string $mode One of:
         *    - 'public':     Cache this object in public caches, if the maxage or smaxage
         *         parameter is set, or if setCacheMaxAge() was called. If a maximum age is
         *         not provided by any of these means, the object will be private.
                        return;
                }
  
-               if ( !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) ) {
+               if ( !User::groupHasPermission( '*', 'read' ) ) {
                        // Private wiki, only private headers
                        if ( $mode !== 'private' ) {
                                wfDebug( __METHOD__ . ": ignoring request for $mode cache mode, private wiki\n" );
  
        /**
         * Attempt to match an Origin header against a set of rules and a set of exceptions
 -       * @param $value string Origin header
 -       * @param $rules array Set of wildcard rules
 -       * @param $exceptions array Set of wildcard rules
 +       * @param string $value Origin header
 +       * @param array $rules Set of wildcard rules
 +       * @param array $exceptions Set of wildcard rules
         * @return bool True if $value matches a rule in $rules and doesn't match any rules in $exceptions, false otherwise
         */
        protected static function matchOrigin( $value, $rules, $exceptions ) {
         * '*' => '.*?'
         * '?' => '.'
         *
 -       * @param $wildcard string String with wildcards
 +       * @param string $wildcard String with wildcards
         * @return string Regular expression
         */
        protected static function wildcardToRegex( $wildcard ) {
        /**
         * Check the max lag if necessary
         * @param $module ApiBase object: Api module being used
 -       * @param $params Array an array containing the request parameters.
 +       * @param array $params an array containing the request parameters.
         * @return boolean True on success, false should exit immediately
         */
        protected function checkMaxLag( $module, $params ) {
         */
        protected function checkExecutePermissions( $module ) {
                $user = $this->getUser();
-               if ( $module->isReadMode() && !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) &&
+               if ( $module->isReadMode() && !User::groupHasPermission( '*', 'read' ) &&
                        !$user->isAllowed( 'read' ) )
                {
                        $this->dieUsageMsg( 'readrequired' );
        /**
         * Check POST for external response and setup result printer
         * @param $module ApiBase An Api module
 -       * @param $params Array an array with the request parameters
 +       * @param array $params an array with the request parameters
         */
        protected function setupExternalResponse( $module, $params ) {
                if ( !$this->getRequest()->wasPosted() && $module->mustBePosted() ) {
         * Get a request upload, and register the fact that it was used, for logging.
         *
         * @since 1.21
 -       * @param $name string Parameter name
 +       * @param string $name Parameter name
         * @return WebRequestUpload
         */
        public function getUpload( $name ) {
  
        /**
         * @param $module ApiBase
 -       * @param $paramName String What type of request is this? e.g. action, query, list, prop, meta, format
 +       * @param string $paramName What type of request is this? e.g. action, query, list, prop, meta, format
         * @return string
         */
        public static function makeHelpMsgHeader( $module, $paramName ) {
         * behavior of inherent ones.
         *
         * @deprecated since 1.21, Use getModuleManager()->addModule() instead.
 -       * @param $name string The identifier for this module.
 +       * @param string $name The identifier for this module.
         * @param $class ApiBase The class where this module is implemented.
         */
        protected function addModule( $name, $class ) {
         * classes who wish to add to or modify current formatters.
         *
         * @deprecated since 1.21, Use getModuleManager()->addModule() instead.
 -       * @param $name string The identifier for this format.
 +       * @param string $name The identifier for this format.
         * @param $class ApiFormatBase The class implementing this format.
         */
        protected function addFormat( $name, $class ) {