{"record":{"id":"36769f8448b8ce29","repo":"phalcon/cphalcon","slug":"invalid-caching-options","errorCode":null,"errorMessage":"Invalid caching options","messagePattern":"Invalid caching options","errorType":"exception","errorClass":"Phalcon\\Mvc\\Model\\Query\\Exceptions\\InvalidCachingOptions","httpStatus":null,"severity":"error","filePath":"phalcon/Mvc/Model/Query.zep","lineNumber":343,"sourceCode":"    }\n\n    /**\n     * Executes a parsed PHQL statement\n     *\n     * @return mixed\n     */\n    public function execute(array bindParams = [], array bindTypes = [])\n    {\n        var adapter, cache, cacheLifetime, cacheOptions, cacheService,\n            defaultBindParams, defaultBindTypes, intermediate, key, lifetime,\n            mergedParams, mergedTypes, preparedResult, result, type, uniqueRow;\n\n        let uniqueRow    = this->uniqueRow,\n            cacheOptions = this->cacheOptions;\n\n        if cacheOptions !== null {\n            if unlikely typeof cacheOptions != \"array\" {\n                throw new InvalidCachingOptions();\n            }\n\n            /**\n             * The user must set a cache key\n             */\n            if unlikely !fetch key, cacheOptions[\"key\"] {\n                throw new MissingCacheKey();\n            }\n\n            if !fetch cacheService, cacheOptions[\"service\"] {\n                let cacheService = \"modelsCache\";\n            }\n\n            let cache = this->container->getShared(cacheService);\n\n            if unlikely (true !== is_a(cache,  CacheInterface::class)) {\n                throw new InvalidQueryCacheService();\n            }","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Mvc/Model/Query.zep#L325-L361","documentation":"Query::execute() reads cacheOptions set via cache(); if the stored value is not an array (e.g. true or a string) InvalidCachingOptions is thrown. The faulty input is the argument passed to Phalcon\\Mvc\\Model::query()->cache(...) — it must be an array of options.","triggerScenarios":"Thrown at phalcon/Mvc/Model/Query.zep:343 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an array to cache(), e.g. ['key' => 'my-key', 'lifetime' => 3600]","Remove the cache() call if caching is not intended","Check wrappers that forward cache options for type loss"],"exampleFix":"$robots = Robots::query(['key' => 'robots-all', 'lifetime' => 86400])->execute();","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize cache option construction in a helper with array type validation","Use IDE types/static analysis to catch non-array arguments"],"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"}