octobercms/october · error · ApplicationException
Safe mode is currently enabled that prevents PHP code…
Error message
Safe mode is currently enabled that prevents PHP code changes.
What it means
Safe-mode guard run before save: the CMS has safe mode enabled (config/system setting) and the object's 'code' section is both dirty and non-empty, so PHP code changes are blocked by policy rather than by a technical failure.
Solutions
- Disable safe mode (cms.enableSafeMode config) to allow PHP code editing
- Remove the PHP code section from the page/layout/partial being saved
- Make the code change outside safe mode (e.g. directly on disk or via deployments)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/cms/classes/CmsCompoundObject.php:160 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/6c6792684e9da6e8.
Report an issue: GitHub.
Appendix: source
Thrown at modules/cms/classes/CmsCompoundObject.php:160
* of the $settings property after the object is loaded from a file.
* @return void
*/
protected function parseSettings()
{
$this->fillViewBagArray();
}
/**
* checkSafeMode checks if safe mode is enabled by config, and the code
* attribute is modified and populated. If so an exception is thrown.
* @return void
*/
protected function checkSafeMode()
{
$safeMode = System::checkSafeMode();
if ($safeMode && $this->isDirty('code') && strlen(trim($this->code))) {
throw new ApplicationException(Lang::get('cms::lang.cms_object.safe_mode_enabled'));
}
}
//
// Components
//
/**
* runComponents defined in the settings, this process halts
* if a component returns a value.
*/
public function runComponents()
{
foreach ($this->components as $component) {
if ($result = $component->runLifeCycle()) {
return $result;
}
}View on GitHub (pinned to b608633a7e)