mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENH avoid multiple calls to records->count() In PermissionCheckboxSetField (#10839)
these calls are not cached and lead to duplicate queries Co-authored-by: Michal Kleiner <mk@011.nz>
This commit is contained in:
parent
110c9135e0
commit
6fa71bbf51
@ -193,6 +193,7 @@ class PermissionCheckboxSetField extends FormField
|
||||
$privilegedPermissions = Permission::config()->privileged_permissions;
|
||||
|
||||
// loop through all available categorized permissions and see if they're assigned for the given groups
|
||||
$hasMultipleRecords = $this->records?->count() > 1;
|
||||
foreach ($this->source as $categoryName => $permissions) {
|
||||
$options .= "<li><h5>$categoryName</h5></li>";
|
||||
foreach ($permissions as $code => $permission) {
|
||||
@ -222,7 +223,7 @@ class PermissionCheckboxSetField extends FormField
|
||||
// interface
|
||||
$disabled = ' disabled="true"';
|
||||
$inheritMessage = ' (' . join(', ', $inheritedCodes[$code]) . ')';
|
||||
} elseif ($this->records && $this->records->Count() > 1 && isset($uninheritedCodes[$code])) {
|
||||
} elseif ($hasMultipleRecords && isset($uninheritedCodes[$code])) {
|
||||
// If code assignments are collected from more than one "source group",
|
||||
// show its origin automatically
|
||||
$inheritMessage = ' (' . join(', ', $uninheritedCodes[$code]) . ')';
|
||||
|
Loading…
Reference in New Issue
Block a user