{"record":{"id":"f90cb87b84dabe0b","repo":"phalcon/cphalcon","slug":"corrupted-ast","errorCode":null,"errorMessage":"Corrupted AST","messagePattern":"Corrupted AST","errorType":"exception","errorClass":"Phalcon\\Mvc\\Model\\Query\\Exceptions\\CorruptedAst","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":708,"sourceCode":"                        let irPhql = this->prepareInsert();\n                        break;\n\n                    case PHQL_T_UPDATE:\n                        let irPhql = this->prepareUpdate();\n                        break;\n\n                    case PHQL_T_DELETE:\n                        let irPhql = this->prepareDelete();\n                        break;\n\n                    default:\n                        throw new UnknownPhqlStatement(type, phql);\n                }\n            }\n        }\n\n        if unlikely typeof irPhql != \"array\" {\n            throw new CorruptedAst();\n        }\n\n        /**\n         * Store the prepared AST in the cache\n         */\n        if typeof uniqueId == \"int\" {\n            let self::internalPhqlCache[uniqueId] = irPhql;\n        }\n\n        let this->intermediate = irPhql;\n\n        return irPhql;\n    }\n\n    /**\n     * Set default bind parameters\n     */\n    public function setBindParams( array bindParams, bool merge = false) -> <QueryInterface>","sourceCodeStart":690,"sourceCodeEnd":726,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L690-L726","documentation":"Query::parse() expects the intermediate representation (irPhql) produced by prepareSelect/prepareInsert/prepareUpdate/prepareDelete to be an array; when it is anything else the AST is considered corrupt and CorruptedAst is thrown. This is an internal-consistency guard, usually triggered by passing a malformed value to setIR() or a broken PHQL parse.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:708 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass only IR produced by parse() (or null) to setIR()","Re-check the PHQL string for syntax anomalies that break parsing","Clear any cached/persisted intermediate representation that may be corrupted"],"exampleFix":"$query->setIR(null); // let parse() rebuild the IR from the PHQL string","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-craft or persist the IR between requests","Pin framework versions when IR formats change across releases"],"tags":[],"backgroundTag":null,"analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","contentChangedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}