mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
#1490 - Caching in getManyManyComponents
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43846 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
cbbd5e118c
commit
3aade3643d
@ -735,9 +735,9 @@ class DataObject extends Controller {
|
|||||||
* @return ComponentSet The components of the one-to-many relationship.
|
* @return ComponentSet The components of the one-to-many relationship.
|
||||||
*/
|
*/
|
||||||
public function getComponents($componentName, $filter = "", $sort = "", $join = "", $limit = "", $having = "") {
|
public function getComponents($componentName, $filter = "", $sort = "", $join = "", $limit = "", $having = "") {
|
||||||
// TODO Does not take different SQL-parameters into account on subsequent calls
|
$sum = md5("{$filter}_{$sort}_{$join}_{$limit}_{$having}");
|
||||||
if(isset($this->componentCache[$componentName]) && false != $this->componentCache[$componentName]) {
|
if(isset($this->componentCache[$componentName . '_' . $sum]) && false != $this->componentCache[$componentName . '_' . $sum]) {
|
||||||
return $this->componentCache[$componentName];
|
return $this->componentCache[$componentName . '_' . $sum];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$componentClass = $this->has_many($componentName)) {
|
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,
|
// 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.
|
// because it's the only copy of the data that we have.
|
||||||
if(!$this->isInDB()) {
|
if(!$this->isInDB()) {
|
||||||
$this->setComponent($componentName, $result);
|
$this->setComponent($componentName . '_' . $sum, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
Loading…
Reference in New Issue
Block a user