From 1709f54e381b4404fe9d2e49e6c7863da09dfafa Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 26 Feb 2016 12:39:29 -0500 Subject: [PATCH] Update documentation for Model::_readDataSource() Update sample code to generate unique keys based on association conditions as well. Because association conditions are not part of the 'query' they need to be handled separately. Refs #8346 --- lib/Cake/Model/Model.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 5795814279e..ccbae1789fd 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -3011,15 +3011,15 @@ public function find($type = 'first', $query = array()) { * * ``` * protected function _readDataSource($type, $query) { - * $cacheName = md5(json_encode($query)); - * $cache = Cache::read($cacheName, 'cache-config-name'); - * if ($cache !== false) { - * return $cache; - * } - * - * $results = parent::_readDataSource($type, $query); - * Cache::write($cacheName, $results, 'cache-config-name'); - * return $results; + * $cacheName = md5(json_encode($query) . json_encode($this->hasOne) . json_encode($this->belongsTo)); + * $cache = Cache::read($cacheName, 'cache-config-name'); + * if ($cache !== false) { + * return $cache; + * } + * + * $results = parent::_readDataSource($type, $query); + * Cache::write($cacheName, $results, 'cache-config-name'); + * return $results; * } * ``` *