phalcon/cphalcon · error · ModelsListNotLoaded

The models list was not loaded correctly

Error message

The models list was not loaded correctly

What it means

Internal guard in Query::getQualified: after resolving a column, this->models is expected to be an array of loaded model sources, but it is not — the query's model list was never prepared correctly during earlier preparation steps. This signals an internal state corruption rather than user input.

Solutions

  1. Report/reproduce with the exact PHQL; this indicates broken internal preparation state.
  2. Ensure the query is prepared via the normal execute()/prepare() flow, not partial manual state changes.
  3. Clear PHQL caches and retry after a framework version check.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Query.zep:3276 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/caedfa850163aa6d. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Model/Query.zep:3276

                    let hasModel = model;
                }
            }

            /**
             * After check in every model, the column does not belong to any of
             * the selected models
             */
            if unlikely hasModel === false {
                throw new ColumnNotInSelectedModels(columnName, "1", this->phql);
            }

            /**
             * Check if the models property is correctly prepared
             */
            let models = this->models;

            if unlikely typeof models != "array" {
                throw new ModelsListNotLoaded();
            }

            /**
             * Obtain the model's source from the models list
             */
            let className = get_class(hasModel);

            if unlikely !fetch source, models[className] {
                throw new ModelSourceNotFound(className, this->phql);
            }

            /**
             * Rename the column
             */
            if Settings::get("orm.column_renaming") {
                let columnMap = metaData->getReverseColumnMap(hasModel);
            } else {
                let columnMap = null;

View on GitHub (pinned to b7419de9cd)