octobercms/october · error · SystemException
Unable to remove permissions before they are loaded.
Error message
Unable to remove permissions before they are loaded.
What it means
Thrown by RoleManager::removePermission when the permissions registry is still null, meaning permissions have not been loaded/registered yet. It guards against removing permissions before the plugin permission definitions are initialized — an ordering mistake, not a missing-permission condition.
Solutions
- Call removePermission only after permissions are registered (e.g. from a system.ready or plugin boot listener that runs later)
- Instead of removing, filter permissions via the permission event or override in plugin registration
- Ensure a loadPermissions/registerPermissions call has run before removal in custom code
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/backend/classes/RoleManager.php:155 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/48c5f5cd5eabe08f.
Report an issue: GitHub.
Appendix: source
Thrown at modules/backend/classes/RoleManager.php:155
$permission = new RolePermission(array_merge($definition, [
'code' => $code,
'owner' => $owner
]));
$this->permissions[] = $permission;
}
}
}
/**
* removePermission removes a single back-end permission. Where owner specifies the
* permissions' owner plugin or module in the format Author.Plugin. Where code is
* the permission to remove.
*/
public function removePermission(string $owner, string $code)
{
if ($this->permissions === null) {
throw new SystemException('Unable to remove permissions before they are loaded.');
}
$ownerPermissions = array_filter($this->permissions, function ($permission) use ($owner) {
return $permission->owner === $owner;
});
foreach ($ownerPermissions as $key => $permission) {
if ($permission->code === $code) {
unset($this->permissions[$key]);
}
}
}
/**
* listPermissions returns a list of the registered permissions items.
*/
public function listPermissions(): array
{View on GitHub (pinned to b608633a7e)