From ff37c51eef4aeffd2f18b691254dc838f6b530f8 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Tue, 4 Oct 2022 19:48:08 -0600 Subject: [PATCH] Use different clone logic for arrays (#4402) Closes --- app/Services/Eggs/EggConfigurationService.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Services/Eggs/EggConfigurationService.php b/app/Services/Eggs/EggConfigurationService.php index 4dce8fd25..bfcdc1eee 100644 --- a/app/Services/Eggs/EggConfigurationService.php +++ b/app/Services/Eggs/EggConfigurationService.php @@ -243,7 +243,13 @@ class EggConfigurationService // Remember, in PHP objects are always passed by reference, so if we do not clone this object // instance we'll end up making modifications to the object outside the scope of this function // which leads to some fun behavior in the parser. - $clone = clone $data; + if (is_array($data)) { + // Copy the array. + // NOTE: if the array contains any objects, they will be passed by reference. + $clone = $data; + } else { + $clone = clone $data; + } foreach ($clone as $key => &$value) { if (is_iterable($value) || is_object($value)) { $value = $this->iterate($value, $structure);