Use isset in permission exists for improved efficiency(#7126)
Using isset on the key name of the array allows it to use a hash table lookup to improve the lookup times for a permission. The permission name is not set if it does not exist for the current user.
This commit is contained in:
parent
04125ef651
commit
2085c950ee
|
|
@ -127,21 +127,12 @@ if (!class_exists('permissions')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//set default to false
|
|
||||||
$result = false;
|
|
||||||
|
|
||||||
//search for the permission
|
//search for the permission
|
||||||
if (!empty($this->permissions) && !empty($permission_name)) {
|
if (!empty($permission_name)) {
|
||||||
foreach($this->permissions as $key => $value) {
|
return isset($this->permissions[$permission_name]);
|
||||||
if ($key == $permission_name) {
|
|
||||||
$result = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//return the result
|
return false;
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue