From 842ee145bcf364e32ba5cdee312b57f72a96baff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Wed, 18 Sep 2019 12:48:27 +0200 Subject: [PATCH] Check also inheritance in type checking of isChild to prevent exceptions --- src/Entity/Base/StructuralDBElement.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Entity/Base/StructuralDBElement.php b/src/Entity/Base/StructuralDBElement.php index b924476e..dfea183c 100644 --- a/src/Entity/Base/StructuralDBElement.php +++ b/src/Entity/Base/StructuralDBElement.php @@ -146,8 +146,9 @@ abstract class StructuralDBElement extends AttachmentContainingDBElement { $class_name = \get_class($this); - //Check if both elements compared, are from the same type: - if ($class_name !== \get_class($another_element)) { + //Check if both elements compared, are from the same type + // (we have to check inheritance, or we get exceptions when using doctrine entities (they have a proxy type): + if (!is_a($another_element, $class_name) && !is_a($this, get_class($another_element))) { throw new \InvalidArgumentException('isChildOf() only works for objects of the same type!'); }