From 2857f68c510d3c5f7b2c1b337e771cc3d7df27bd Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 17 Jul 2016 13:12:39 +0200 Subject: [PATCH] Throw exceptions in condition classes if unsupported object is checked --- .../condition/AbstractObjectTextPropertyCondition.class.php | 4 +++- .../lib/system/condition/AbstractTimestampCondition.class.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php index 82088daeea..2552125e42 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractObjectTextPropertyCondition.class.php @@ -55,7 +55,9 @@ abstract class AbstractObjectTextPropertyCondition extends AbstractTextCondition */ public function checkObject(DatabaseObject $object, array $conditionData) { $className = $this->getClassName(); - if (!($object instanceof $className)) return; + if (!($object instanceof $className)) { + throw new \InvalidArgumentException("Object is no instance of '{$className}', instance of '".get_class($object)."' given."); + } return in_array($object->{$this->getPropertyName()}, $conditionData[$this->fieldName]); } diff --git a/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php b/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php index d2667c18da..89c67f5fbe 100644 --- a/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/AbstractTimestampCondition.class.php @@ -64,7 +64,9 @@ abstract class AbstractTimestampCondition extends AbstractSingleFieldCondition i */ public function checkObject(DatabaseObject $object, array $conditionData) { $className = $this->getClassName(); - if (!($object instanceof $className)) return; + if (!($object instanceof $className)) { + throw new \InvalidArgumentException("Object is no instance of '{$className}', instance of '".get_class($object)."' given."); + } if (isset($conditionData['startTime']) && $object->{$this->getPropertyName()} < strtotime($conditionData['startTime'])) { return false; -- 2.20.1