Merged revisions 49946 via svnmerge from

svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq

........
  r49946 | ischommer | 2008-02-21 15:21:48 +1300 (Thu, 21 Feb 2008) | 1 line
  
  fixed caching in getManyManyComponents (see r43848)
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@49940 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-02-21 02:23:39 +00:00
parent 24bd071767
commit 541c8a8904

View File

@ -862,7 +862,10 @@ class DataObject extends ViewableData implements DataObjectInterface {
* @todo Implement query-params * @todo Implement query-params
*/ */
public function getManyManyComponents($componentName, $filter = "", $sort = "", $join = "", $limit = "") { public function getManyManyComponents($componentName, $filter = "", $sort = "", $join = "", $limit = "") {
if(isset($this->components[$componentName])) return $this->components[$componentName]; $sum = md5("{$filter}_{$sort}_{$join}_{$limit}_{$having}");
if(isset($this->componentCache[$componentName . '_' . $sum]) && false != $this->componentCache[$componentName . '_' . $sum]) {
return $this->componentCache[$componentName . '_' . $sum];
}
list($parentClass, $componentClass, $parentField, $componentField, $table) = $this->many_many($componentName); list($parentClass, $componentClass, $parentField, $componentField, $table) = $this->many_many($componentName);
@ -896,7 +899,12 @@ class DataObject extends ViewableData implements DataObjectInterface {
$result = new ComponentSet(); $result = new ComponentSet();
} }
$result->setComponentInfo("many-to-many", $this, $parentClass, $table, $componentClass); $result->setComponentInfo("many-to-many", $this, $parentClass, $table, $componentClass);
$this->components[$componentName] = $result;
// 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 . '_' . $sum, $result);
}
return $result; return $result;
} }