From 3aade3643dd5290a32b349b01a9e76418bc2c2fd Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Thu, 25 Oct 2007 03:20:55 +0000 Subject: [PATCH] #1490 - Caching in getManyManyComponents git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43846 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/DataObject.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 8e1547878..31d163a76 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -735,9 +735,9 @@ class DataObject extends Controller { * @return ComponentSet The components of the one-to-many relationship. */ public function getComponents($componentName, $filter = "", $sort = "", $join = "", $limit = "", $having = "") { - // TODO Does not take different SQL-parameters into account on subsequent calls - if(isset($this->componentCache[$componentName]) && false != $this->componentCache[$componentName]) { - return $this->componentCache[$componentName]; + $sum = md5("{$filter}_{$sort}_{$join}_{$limit}_{$having}"); + if(isset($this->componentCache[$componentName . '_' . $sum]) && false != $this->componentCache[$componentName . '_' . $sum]) { + return $this->componentCache[$componentName . '_' . $sum]; } if(!$componentClass = $this->has_many($componentName)) { @@ -761,7 +761,7 @@ class DataObject extends Controller { // If this record isn't in the database, then we want to hold onto this specific ComponentSet, // because it's the only copy of the data that we have. if(!$this->isInDB()) { - $this->setComponent($componentName, $result); + $this->setComponent($componentName . '_' . $sum, $result); } return $result;