From d30b14eb0a4330311be9083b0e485a33f7d69fcb Mon Sep 17 00:00:00 2001 From: Caleb Mazalevskis Date: Mon, 28 Aug 2023 01:43:51 +0800 Subject: [PATCH] Events orchestrator patch. Changelog excerpt: - Added guard to the events orchestrator to prevent infinite looping via recursive event firing from within handlers. --- Changelog.txt | 3 +++ src/Events.php | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index aa8bcdf..dd88e0b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,6 +14,9 @@ found at: - [2023.08.18; Maikuolan]: Improved tests and documentation for the operation handler. +- [2023.08.28; Maikuolan]: Added guard to the events orchestrator to prevent + infinite looping via recursive event firing from within handlers. + === Version/Release 1.9.7 === PATCH RELEASE. diff --git a/src/Events.php b/src/Events.php index c480f8e..3006d53 100644 --- a/src/Events.php +++ b/src/Events.php @@ -1,6 +1,6 @@ Handlers[$Event], $this->Status[$Event])) { + if (!isset($this->Handlers[$Event], $this->Status[$Event]) || isset($this->Status[$Event]['In Progress'])) { return false; } + $this->Status[$Event]['In Progress'] = true; foreach ($this->Handlers[$Event] as $Handler) { $Handler($Data); } + unset($this->Status[$Event]['In Progress']); return true; }