Skip to content

Commit ff37c51

Browse files
authored
Use different clone logic for arrays (pterodactyl#4402)
Closes <pterodactyl#3985>
1 parent 44598bf commit ff37c51

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/Services/Eggs/EggConfigurationService.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,13 @@ private function iterate($data, array $structure)
243243
// Remember, in PHP objects are always passed by reference, so if we do not clone this object
244244
// instance we'll end up making modifications to the object outside the scope of this function
245245
// which leads to some fun behavior in the parser.
246-
$clone = clone $data;
246+
if (is_array($data)) {
247+
// Copy the array.
248+
// NOTE: if the array contains any objects, they will be passed by reference.
249+
$clone = $data;
250+
} else {
251+
$clone = clone $data;
252+
}
247253
foreach ($clone as $key => &$value) {
248254
if (is_iterable($value) || is_object($value)) {
249255
$value = $this->iterate($value, $structure);

0 commit comments

Comments
 (0)