phalcon/cphalcon · error · Phalcon\Mvc\Model\Query\Exceptions\CorruptedAst
Corrupted AST
Error message
Corrupted AST
What it means
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.
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
Example fix
$query->setIR(null); // let parse() rebuild the IR from the PHQL string
Defensive patterns
Strategy: type-guard
Prevention
- Never hand-craft or persist the IR between requests
- Pin framework versions when IR formats change across releases
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Query.zep:708 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/f90cb87b84dabe0b.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Query.zep:708
let irPhql = this->prepareInsert();
break;
case PHQL_T_UPDATE:
let irPhql = this->prepareUpdate();
break;
case PHQL_T_DELETE:
let irPhql = this->prepareDelete();
break;
default:
throw new UnknownPhqlStatement(type, phql);
}
}
}
if unlikely typeof irPhql != "array" {
throw new CorruptedAst();
}
/**
* Store the prepared AST in the cache
*/
if typeof uniqueId == "int" {
let self::internalPhqlCache[uniqueId] = irPhql;
}
let this->intermediate = irPhql;
return irPhql;
}
/**
* Set default bind parameters
*/
public function setBindParams( array bindParams, bool merge = false) -> <QueryInterface>View on GitHub (pinned to b7419de9cd)