phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\CursorIsImmutable
Cursor is an immutable ArrayAccess object
Error message
Cursor is an immutable ArrayAccess object
What it means
Unconditional guard: Resultset::offsetSet (and offsetUnset) always throws because resultsets are immutable; ArrayAccess mutation is only implemented to satisfy the interface. Any write like $resultset[0] = $model fires it regardless of input.
Solutions
- Do not mutate resultsets; build a new array from toArray() and modify that.
- Remove code that assigns into resultset objects (common after refactors from array to resultset).
- Wrap legacy mutation sites in try/catch only when migrating behavior.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at phalcon/Mvc/Model/Resultset.zep:620 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/1b330ffc4b3a2f98.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Mvc/Model/Resultset.zep:620
}
/**
* Move the cursor to the specific position
*/
this->seek(index);
return this->{"current"}();
}
/**
* Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface
*
* @param int offset
* @param \Phalcon\Mvc\ModelInterface value
*/
public function offsetSet(var offset, var value) -> void
{
throw new CursorIsImmutable();
}
/**
* Resultsets cannot be changed. It has only been implemented to meet the definition of the ArrayAccess interface
*/
public function offsetUnset(var offset) -> void
{
throw new CursorIsImmutable();
}
/**
* Rewinds resultset to its beginning
*/
final public function rewind() -> void
{
this->seek(0);
}
View on GitHub (pinned to b7419de9cd)