Skip to content

Commit 0c17182

Browse files
authored
Fixes the cloning of a collection by also cloning the internal select object. (OpenMage#1183)
Without this fix, the original select object is used and every modification would also affect the original object. A second effect occurs if you clone a collection and use the load function. All the triggers in _beforeLoad function of the collection which add additional filters etc. will be modify the original select object and the select object will be scale up with identical filters and orders. Signed-off-by: Frank Rochlitzer <f.rochlitzer@b3-it.de>
1 parent 7f8ac27 commit 0c17182

File tree

1 file changed

+12
-0
lines changed
  • lib/Varien/Data/Collection

1 file changed

+12
-0
lines changed

lib/Varien/Data/Collection/Db.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,4 +863,16 @@ public function addFilterToMap($filter, $alias, $group = 'fields')
863863

864864
return $this;
865865
}
866+
867+
/**
868+
* Magic clone function
869+
*
870+
* Clone also Zend_Db_Select
871+
*
872+
* @return void
873+
*/
874+
public function __clone()
875+
{
876+
$this->_select = clone $this->_select;
877+
}
866878
}

0 commit comments

Comments
 (0)