octobercms/october · error · ApplicationException
Cannot reset template from file.
Error message
Cannot reset template from file.
What it means
resetFromTemplateFile() discards the database (first-layer) copy of a template so the filesystem version takes effect again. It requires canResetFromTemplateFile(): the template must be a Halcyon model, the theme's second layer (database templates) must be enabled, and the template must exist in BOTH datasource layers; otherwise it throws 'Cannot reset template from file.'
Source
Thrown at modules/cms/classes/editorextension/HasExtensionCrud.php:401
}
if (!$this->getTheme()->secondLayerEnabled()) {
return false;
}
$datasource = $this->getThemeDatasource();
return $datasource->hasModelAtIndex(0, $template) &&
$datasource->hasModelAtIndex(1, $template);
}
/**
* resetFromTemplateFile
*/
protected function resetFromTemplateFile($documentType, $templatePath)
{
$template = $this->loadTemplate($documentType, $templatePath);
if (!$this->canResetFromTemplateFile($template)) {
throw new ApplicationException('Cannot reset template from file.');
}
// Delete first layer
$datasource = $this->getThemeDatasource();
$datasource->forceDeleteModelAtIndex(0, $template);
}
/**
* getThemeDatasource returns a theme datasource object
*/
protected function getThemeDatasource()
{
return $this->getTheme()->getDatasource();
}
/**
* getRequestMetadata
*/View on GitHub (pinned to b608633a7e)
Solutions
- Ensure the template exists in both layers: a file under themes/<theme>/<typeDir>/ AND a database copy
- Verify the theme's second layer (database templates) is enabled
- If the file is missing, recreate it, or use 'update template file' (debug mode required) to write database content to disk first
Defensive patterns
Strategy: validation
Validate before calling
$ds = $theme->getDatasource();
$canReset = $template instanceof \October\Rain\Halcyon\Model
&& $theme->secondLayerEnabled()
&& $ds->hasModelAtIndex(0, $template)
&& $ds->hasModelAtIndex(1, $template);
if (!$canReset) {
// hide or disable 'reset from file' rather than calling it
} Prevention
- Only show 'reset from file' when both datasource layers contain the template
- Write templates to both layers before advertising reset actions
- Monitor theme datasource configuration changes when enabling/disabling database templates
When it happens
Trigger: The editor's 'reset from file' action on a template that exists in only one layer — database-only (created in the editor, never written to disk) or file-only (file deleted/never copied) — or on a theme whose second layer is disabled.
Common situations: Templates created via the editor's database layer with no file counterpart; theme files removed from disk; theme datasource config missing the second layer; environments where database templates were switched off.
Related errors
- The template cannot be updated.
- cms::lang.template.not_found
- cms::lang.partial.not_found_name
- cms::lang.content.not_found_name
- Component not found
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/745f9386754dc517.
Report an issue: GitHub.