diff --git a/core/model/ComponentSet.php b/core/model/ComponentSet.php index a8e0278f5bf..41266788088 100755 --- a/core/model/ComponentSet.php +++ b/core/model/ComponentSet.php @@ -89,9 +89,8 @@ function add($item, $extraFields = null) { } if(is_object($item)) { - // TODO Should this allow subclasses? - if($item->class != $this->childClass) { - user_error("ComponentSet::add() Tried to add an '{$item->class}' object, but '{$this->childClass}' expected", E_USER_ERROR); + if(!is_a($item, $this->childClass)) { + user_error("ComponentSet::add() Tried to add an '{$item->class}' object, but a '{$this->childClass}' object expected", E_USER_ERROR); } } else { $id = $item; @@ -196,8 +195,8 @@ function setByIDList($idList) { */ function remove($item) { if(is_object($item)) { - if($item->class != $this->childClass && !is_subclass_of($item, $this->childClass)) { - user_error("ComponentSet::remove() Tried to remove an '{$item->class}' object, but '{$this->childClass}' expected", E_USER_ERROR); + if(!is_a($item, $this->childClass)) { + user_error("ComponentSet::remove() Tried to remove an '{$item->class}' object, but a '{$this->childClass}' object expected", E_USER_ERROR); } } else { $item = DataObject::get_by_id($this->childClass, $item);