1
0
Fork 0
mirror of synced 2024-10-02 10:16:27 +13:00

Ensure vars are not lost during upgrade

Using a reference on an array element while iterating over it caused
some unexpected behavior. Instead of using a reference, this change
uses a key to allow us to edit the array element.

For reference on the problem, see https://stackoverflow.com/questions/70691375/foreach-with-reference-causing-arrays-last-element-to-repeat.
This commit is contained in:
Steven Nguyen 2023-04-14 16:18:31 -07:00
parent d1740d2121
commit d41df04b6a
No known key found for this signature in database

View file

@ -95,9 +95,9 @@ $cli
if (is_null($value)) {
continue;
}
foreach ($vars as &$var) {
foreach ($vars as $i => $var) {
if ($var['name'] === $key) {
$var['default'] = $value;
$vars[$i]['default'] = $value;
}
}
}
@ -114,9 +114,9 @@ $cli
if (is_null($value)) {
continue;
}
foreach ($vars as &$var) {
foreach ($vars as $i => $var) {
if ($var['name'] === $key) {
$var['default'] = $value;
$vars[$i]['default'] = $value;
}
}
}
@ -146,7 +146,7 @@ $cli
$input = [];
foreach ($vars as $key => $var) {
foreach ($vars as $var) {
if (!empty($var['filter']) && ($interactive !== 'Y' || !Console::isInteractive())) {
if ($data && $var['default'] !== null) {
$input[$var['name']] = $var['default'];