Use different clone logic for arrays (#4402)
Closes <https://github.com/pterodactyl/panel/issues/3985>
This commit is contained in:
parent
44598bf724
commit
ff37c51eef
1 changed files with 7 additions and 1 deletions
|
@ -243,7 +243,13 @@ class EggConfigurationService
|
||||||
// Remember, in PHP objects are always passed by reference, so if we do not clone this object
|
// 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
|
// 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.
|
// 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) {
|
foreach ($clone as $key => &$value) {
|
||||||
if (is_iterable($value) || is_object($value)) {
|
if (is_iterable($value) || is_object($value)) {
|
||||||
$value = $this->iterate($value, $structure);
|
$value = $this->iterate($value, $structure);
|
||||||
|
|
Loading…
Reference in a new issue