phalcon/cphalcon · error · CorruptedStatement
Corrupted statement
Error message
Corrupted statement
What it means
Thrown by compileAutoEscape() when the intermediate representation of an {% autoescape %} statement has no 'enable' key. The Volt parser turns template source into statement arrays before compilation; every autoescape statement must carry the enable flag (true/false). A statement without it is considered corrupted and compilation stops.
Source
Thrown at phalcon/Mvc/View/Engine/Volt/Compiler.zep:534
}
/**
* Compiles a "autoescape" statement returning PHP code
*
* @param array statement
* @param bool extendsMode
*
* @return string
*/
public function compileAutoEscape( array statement, bool extendsMode) -> string
{
var autoescape, oldAutoescape, compilation;
/**
* A valid option is required
*/
if unlikely !fetch autoescape, statement["enable"] {
throw new CorruptedStatement();
}
/**
* "autoescape" mode
*/
let oldAutoescape = this->autoescape,
this->autoescape = autoescape;
let compilation = this->statementList(
statement["block_statements"],
extendsMode
);
let this->autoescape = oldAutoescape;
return compilation;
}
View on GitHub (pinned to b7419de9cd)
Solutions
- Write the block with an explicit flag: {% autoescape true %} ... {% endautoescape %}
- Clear the compiled Volt cache (rm -rf storage/cache/volt/*) so templates re-parse with the current version
- Ensure the Phalcon extension and any PHP-level Volt code are the same release (no partial upgrades)
- Remove custom extension hooks that alter statement arrays and re-test
Example fix
// before (volt template)
{% autoescape %}{{ unsafe }}{% endautoescape %}
// after
{% autoescape true %}{{ unsafe }}{% endautoescape %} Defensive patterns
Strategy: try-catch
Try / catch
try {
$compiler->compile('template.volt');
} catch (\Phalcon\Mvc\View\Engine\Volt\Exception\CorruptedStatement $e) {
// statement tree from parser is incomplete: report template path, clear cache
$this->logger->error('Volt corrupted statement in ' . $compiler->getTemplatePath());
array_map('unlink', glob($cacheDir . '/*.php'));
throw $e;
} Prevention
- Always write {% autoescape true %} or {% autoescape false %} with an explicit flag
- Clear the compiled Volt cache after every Phalcon upgrade
- Run a compile-all pass in CI so malformed templates fail the build, not production
When it happens
Trigger: An {% autoescape %} ... {% endautoescape %} block whose parsed statement lacks the enable flag — usually a bare {% autoescape %} with no true/false argument, a hand-built/mangled statement array passed to compileStatement(), or parser/compiler version mismatch after a partial Phalcon upgrade.
Common situations: Typo in the autoescape directive, custom Volt extensions that modify or inject statements, or mixing an old compiled cache with a new Phalcon version so intermediate representations diverge.
Related errors
- 'path' must be a string or a closure
- The extension is not valid
- 'always' must be a bool value
- 'prefix' must be a string
- 'separator' must be a string
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/17e668eaaaff1214.
Report an issue: GitHub.