From: umherirrender Date: Sat, 9 Mar 2013 22:01:45 +0000 (+0100) Subject: Use User::groupHasPermission X-Git-Tag: 1.31.0-rc.0~20360^2~1 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=51ed2b35c14b5fa080e5415c25d046e7ea45cbe4;p=lhc%2Fweb%2Fwiklou.git Use User::groupHasPermission 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 --- diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 2bd01e029b..0450b37cc4 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -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' );