{"record":{"id":"17e668eaaaff1214","repo":"phalcon/cphalcon","slug":"corrupted-statement","errorCode":null,"errorMessage":"Corrupted statement","messagePattern":"Corrupted statement","errorType":"exception","errorClass":"CorruptedStatement","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/View/Engine/Volt/Compiler.zep","lineNumber":534,"sourceCode":"    }\n\n    /**\n     * Compiles a \"autoescape\" statement returning PHP code\n     *\n     * @param array statement\n     * @param bool extendsMode\n     *\n     * @return string\n     */\n    public function compileAutoEscape( array statement, bool extendsMode) -> string\n    {\n        var autoescape, oldAutoescape, compilation;\n\n        /**\n         * A valid option is required\n         */\n        if unlikely !fetch autoescape, statement[\"enable\"] {\n            throw new CorruptedStatement();\n        }\n\n        /**\n         * \"autoescape\" mode\n         */\n        let oldAutoescape = this->autoescape,\n            this->autoescape = autoescape;\n\n        let compilation = this->statementList(\n            statement[\"block_statements\"],\n            extendsMode\n        );\n\n        let this->autoescape = oldAutoescape;\n\n        return compilation;\n    }\n","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/View/Engine/Volt/Compiler.zep#L516-L552","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (volt template)\n{% autoescape %}{{ unsafe }}{% endautoescape %}\n\n// after\n{% autoescape true %}{{ unsafe }}{% endautoescape %}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $compiler->compile('template.volt');\n} catch (\\Phalcon\\Mvc\\View\\Engine\\Volt\\Exception\\CorruptedStatement $e) {\n    // statement tree from parser is incomplete: report template path, clear cache\n    $this->logger->error('Volt corrupted statement in ' . $compiler->getTemplatePath());\n    array_map('unlink', glob($cacheDir . '/*.php'));\n    throw $e;\n}","preventionTips":["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"],"tags":["volt","template","compiler","autoescape","internal"],"backgroundTag":"template-syntax-error","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}