Use User::groupHasPermission
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 9 Mar 2013 22:01:45 +0000 (23:01 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Sat, 9 Mar 2013 22:01:45 +0000 (23:01 +0100)
Instead of getting the rights of group '*' and searching for 'read',
there is a method to do a direct lookup for group '*' and right 'read',
makes the code easier to read.

Change-Id: I1d5d6e1f4a94ded2b3f87144e031d0c2aac62020

includes/api/ApiMain.php

index 2bd01e0..0450b37 100644 (file)
@@ -274,7 +274,7 @@ class ApiMain extends ApiBase {
                        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" );
@@ -769,7 +769,7 @@ class ApiMain extends ApiBase {
         */
        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' );