X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FPermissions%2FPermissionManager.php;h=0a8e515a32fb6a192e8b806452d48235deb9e1ed;hb=0032290d18954ae669a9e63a41ff0bc245f4b21b;hp=f9ad3ebb93639e46ef98c8e753dde60d4ecd53e6;hpb=b4675c6125736c11b5a4c14c25a2bfaf41102264;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Permissions/PermissionManager.php b/includes/Permissions/PermissionManager.php index f9ad3ebb93..0a8e515a32 100644 --- a/includes/Permissions/PermissionManager.php +++ b/includes/Permissions/PermissionManager.php @@ -85,8 +85,8 @@ class PermissionManager { /** @var NamespaceInfo */ private $nsInfo; - /** @var string[] Cached results of getAllRights() */ - private $allRights = false; + /** @var string[]|null Cached results of getAllRights() */ + private $allRights; /** @var string[][] Cached user rights */ private $usersRights = null; @@ -231,6 +231,25 @@ class PermissionManager { return !count( $this->getPermissionErrorsInternal( $action, $user, $page, $rigor, true ) ); } + /** + * A convenience method for calling PermissionManager::userCan + * with PermissionManager::RIGOR_QUICK + * + * Suitable for use for nonessential UI controls in common cases, but + * _not_ for functional access control. + * May provide false positives, but should never provide a false negative. + * + * @see PermissionManager::userCan() + * + * @param string $action + * @param User $user + * @param LinkTarget $page + * @return bool + */ + public function quickUserCan( $action, User $user, LinkTarget $page ) { + return $this->userCan( $action, $user, $page, self::RIGOR_QUICK ); + } + /** * Can $user perform $action on a page? * @@ -1201,7 +1220,8 @@ class PermissionManager { * Check if user is allowed to make any action * * @param UserIdentity $user - * // TODO: HHVM can't create mocks with variable params @param string ...$actions + * // TODO: HHVM bug T228695#5450847 @param string ...$actions + * @suppress PhanCommentParamWithoutRealParam * @return bool True if user is allowed to perform *any* of the given actions * @since 1.34 */ @@ -1219,7 +1239,8 @@ class PermissionManager { * Check if user is allowed to make all actions * * @param UserIdentity $user - * // TODO: HHVM can't create mocks with variable params @param string ...$actions + * // TODO: HHVM bug T228695#5450847 @param string ...$actions + * @suppress PhanCommentParamWithoutRealParam * @return bool True if user is allowed to perform *all* of the given actions * @since 1.34 */ @@ -1450,7 +1471,7 @@ class PermissionManager { * @return string[] Array of permission names */ public function getAllPermissions() { - if ( $this->allRights === false ) { + if ( $this->allRights === null ) { if ( count( $this->options->get( 'AvailableRights' ) ) ) { $this->allRights = array_unique( array_merge( $this->coreRights,