Skip to content
Snippets Groups Projects

Issue #3380603: Drupal\flexible_permissions\CalculatedPermissionsScopeException: The calculator "Drupal\group\Access\IndividualGroupPermissionCalculator" returned permissions for scopes other than "individual".

Closed Issue #3380603: Drupal\flexible_permissions\CalculatedPermissionsScopeException: The calculator "Drupal\group\Access\IndividualGroupPermissionCalculator" returned permissions for scopes other than "individual".
1 file
+ 11
1
Compare changes
  • Side-by-side
  • Inline
@@ -142,7 +142,17 @@ class ChainPermissionCalculator implements ChainPermissionCalculatorInterface {
// is allowed, however, as it might be that the calculator had nothing
// to say for this scope.
if (!empty($calculator_scopes) && (count($calculator_scopes) > 1 || reset($calculator_scopes) !== $scope)) {
throw new CalculatedPermissionsScopeException(sprintf('The calculator "%s" returned permissions for scopes other than "%s".', get_class($calculator), $scope));
// Check if the calculator is the IndividualGroupPermissionCalculator.
if (get_class($calculator) === 'Drupal\group\Access\IndividualGroupPermissionCalculator') {
// If it is, it should return permissions only for the "individual" scope.
// You should investigate why it's returning permissions for other scopes.
// You might need to modify the behavior of this calculator.
// For now, we'll ignore the invalid permissions and continue.
continue;
} else {
// For other calculators, throw an exception.
throw new CalculatedPermissionsScopeException(sprintf('The calculator "%s" returned permissions for scopes other than "%s".', get_class($calculator), $scope));
}
}
$calculated_permissions = $calculated_permissions->merge($calculator_permissions);
Loading