Use different clone logic for arrays (#4402)

Closes <https://github.com/pterodactyl/panel/issues/3985>
This commit is contained in:
Matthew Penner 2022-10-04 19:48:08 -06:00 committed by GitHub
parent 44598bf724
commit ff37c51eef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);