{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/7043","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/7043/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/7043/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/7043/events","html_url":"https://github.com/cakephp/cakephp/issues/7043","id":95541239,"number":7043,"title":"passing options to subqueries on treebehavior finders for proper caching","user":{"login":"urulab","id":220011,"avatar_url":"https://avatars.githubusercontent.com/u/220011?v=3","gravatar_id":"","url":"https://api.github.com/users/urulab","html_url":"https://github.com/urulab","followers_url":"https://api.github.com/users/urulab/followers","following_url":"https://api.github.com/users/urulab/following{/other_user}","gists_url":"https://api.github.com/users/urulab/gists{/gist_id}","starred_url":"https://api.github.com/users/urulab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urulab/subscriptions","organizations_url":"https://api.github.com/users/urulab/orgs","repos_url":"https://api.github.com/users/urulab/repos","events_url":"https://api.github.com/users/urulab/events{/privacy}","received_events_url":"https://api.github.com/users/urulab/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cakephp/cakephp/labels/ORM","name":"ORM","color":"ffffff"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/47","html_url":"https://github.com/cakephp/cakephp/milestones/3.0.9","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/47/labels","id":1184300,"number":47,"title":"3.0.9","description":"Bugfixes and minor improvements for 3.0.x","creator":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":87,"state":"closed","created_at":"2015-06-28T17:20:20Z","updated_at":"2015-07-17T02:27:27Z","due_on":"2015-07-16T04:00:00Z","closed_at":"2015-07-17T02:27:27Z"},"comments":2,"created_at":"2015-07-16T22:05:42Z","updated_at":"2015-07-17T13:36:35Z","closed_at":"2015-07-16T23:43:34Z","body":"When I try to cache an object using TreeBehavior::find('path'), caching works fine on first query but in subqueries (lazy loading) not. The options array must be passed or extract some keys for use in get().\r\n\r\nMy call:\r\n```php\r\n$this->categories->find('path', ['for' => $id])->cache('path-' . $id);\r\n```\r\nTreeBehavior.php:\r\n```php\r\npublic function findPath(Query $query, array $options)\r\n        $node = $this->_table->get($options['for'], ['fields' => [$left, $right]]);\r\n\r\n/*** COULD BE ***/\r\n        //In $options: ['cache' => 'default', 'key' => 'path-x'] or put these 2 indexes on new $_options\r\n        $options += ['fields' => [$left, $right]];\r\n        $node = $this->_table->get($options['for'], $options);\r\n\r\n//Same for other finders...\r\n``"},"comment":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/comments/122276131","html_url":"https://github.com/cakephp/cakephp/issues/7043#issuecomment-122276131","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/7043","id":122276131,"user":{"login":"urulab","id":220011,"avatar_url":"https://avatars.githubusercontent.com/u/220011?v=3","gravatar_id":"","url":"https://api.github.com/users/urulab","html_url":"https://github.com/urulab","followers_url":"https://api.github.com/users/urulab/followers","following_url":"https://api.github.com/users/urulab/following{/other_user}","gists_url":"https://api.github.com/users/urulab/gists{/gist_id}","starred_url":"https://api.github.com/users/urulab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urulab/subscriptions","organizations_url":"https://api.github.com/users/urulab/orgs","repos_url":"https://api.github.com/users/urulab/repos","events_url":"https://api.github.com/users/urulab/events{/privacy}","received_events_url":"https://api.github.com/users/urulab/received_events","type":"User","site_admin":false},"created_at":"2015-07-17T13:36:35Z","updated_at":"2015-07-17T13:36:35Z","body":"When I rewrite based in your indications:\r\n```php\r\n$path = Cache::remember('path-' . $id, function () use ($id) {\r\n    return $this->categories->find('path', ['for' => $id]);\r\n});\r\n```\r\nI have: ```Error: You cannot serialize or unserialize PDO instances ```"}}