From 0cd5074d4e49145abda39d37555b80334cb01235 Mon Sep 17 00:00:00 2001 From: Olof Pettersson Date: Tue, 2 Apr 2024 14:34:24 +0200 Subject: [PATCH] Add extra catch-block for TypeErrors In php 8.0 internal functions now throw errors instead of warnings which aren't getting caught by the normal catch block exception. So here we add a specific catch block for the TypeError so that the old behaviour is somewhat restored. --- src/SWP/Component/Rule/Evaluator/RuleEvaluator.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SWP/Component/Rule/Evaluator/RuleEvaluator.php b/src/SWP/Component/Rule/Evaluator/RuleEvaluator.php index d8fe71152e..18809cbfed 100644 --- a/src/SWP/Component/Rule/Evaluator/RuleEvaluator.php +++ b/src/SWP/Component/Rule/Evaluator/RuleEvaluator.php @@ -52,6 +52,8 @@ public function evaluate(RuleInterface $rule, RuleSubjectInterface $subject) return (bool) $this->expression->evaluate($rule->getExpression(), [$subject->getSubjectType() => $subject]); } catch (\Exception $e) { $this->logger->error(sprintf('%s', $e->getMessage()), ['exception' => $e]); + } catch (\TypeError $e) { + $this->logger->error(sprintf('%s', $e->getMessage()), ['exception' => $e]); } return false;