octobercms/october · error · SystemException
Unable to remove a widget before widgets are loaded.
Error message
Unable to remove a widget before widgets are loaded.
What it means
Thrown by WidgetManager's removeReportWidget when the internal reportWidgets registry is falsy (not yet populated). It is an initialization-order guard: report widgets must be registered/loaded before any can be removed, so this fires when removal is attempted too early in the boot cycle.
Solutions
- Defer the removal until after widget registration (e.g. inside an event listener that fires post-boot)
- Register widgets via registerReportWidgets in the plugin instead of mutating the manager early
- Ensure the WidgetManager instance has been initialized/loaded before calling removeReportWidget
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/backend/classes/widgetmanager/HasReportWidgets.php:191 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/3b942ca873e8f086.
Report an issue: GitHub.
Appendix: source
Thrown at modules/backend/classes/widgetmanager/HasReportWidgets.php:191
}
$_name = Str::normalizeClassName($name);
if (isset($this->reportWidgets[$_name])) {
return $_name;
}
return $name;
}
/**
* removeReportWidget removes a registered ReportWidget.
* @param string $className Widget class name.
* @return void
*/
public function removeReportWidget($className)
{
if (!$this->reportWidgets) {
throw new SystemException('Unable to remove a widget before widgets are loaded.');
}
unset($this->reportWidgets[$className]);
}
}
View on GitHub (pinned to b608633a7e)