- Issue created by @boromino
- @boromino opened merge request.
- Status changed to Needs review
over 1 year ago 5:22pm 27 February 2023 - 🇩🇪Germany jurgenhaas Gottmadingen
This is a great finding, thanks a lot @boromino
However, it looks like setting value to NULL has a purpose, i.e. if the given key does not exist.
Looking at the code, I guess we could get rid of the for each loop and replace that while loop with this:
while (($key = array_shift($key_parts)) !== NULL) { if (isset($value[$key])) { $value = $value[$key]; } else { $value = NULL; break; } }
What do you think?
- 🇨🇭Switzerland boromino
That makes sense, I have updated the merge request accordingly.
- 🇩🇪Germany mxh Offenburg
The suggested change in #4 would remove the improvement that was added in #3292951: Improve handling on level of typed data in DTO and Configuration → . Removing
$value = NULL
from the while block would introduce the risk, that the value for a parent key is kept, while child keys may still be left and wouldn't have any value. - Assigned to mxh
- Status changed to Needs work
over 1 year ago 6:13pm 27 February 2023 - @mxh opened merge request.
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 6:22pm 27 February 2023 - Assigned to mxh
- Status changed to Needs work
over 1 year ago 8:12pm 27 February 2023 - Issue was unassigned.
- Status changed to Needs review
over 1 year ago 8:22pm 27 February 2023 - Status changed to Needs work
over 1 year ago 3:39pm 28 February 2023 - 🇩🇪Germany jurgenhaas Gottmadingen
Hope I'm not wrong but it looks like MR313 isn't catching it either. If the given config key is multi-part, then this MR finds the first part as a match and breaks out of the while loop, ignoring the subsequent parts of the key.
Maybe the correct approach is to not re-use
$value
. Instead initialize the$newvalue
with NULL and then walk through the while and foreach loops like originally implemented, overriding$newvalue
until we worked through all parts of the config key? - 🇩🇪Germany mxh Offenburg
The first commit in MR313 contained
break 2;
. Maybe you looked into that commit instead of the MR? I then changed that to acontinue 2
:
https://git.drupalcode.org/project/eca/-/merge_requests/313/diffs#d9c757...That means, it doesn't break out of the while loop and assigns NULL to $value if it couldn't find the (last) key part.
- 🇩🇪Germany jurgenhaas Gottmadingen
Oh, my bad. It wasn't even looking at the wrong commit, it was my brain tricking me by not distinguishing between "break" and "continue". Of course, MR313 is perfect and fixes this. Thanks @mxh and @boromino, I'll merge and back port this to 1.1 now.
- Status changed to RTBC
over 1 year ago 8:16am 1 March 2023 -
jurgenhaas →
committed 0b7934ad on 1.2.x authored by
mxh →
Issue #3344752 by boromino, mxh, jurgenhaas: Config read without...
-
jurgenhaas →
committed 0b7934ad on 1.2.x authored by
mxh →
-
jurgenhaas →
committed 131faed6 on 1.1.x authored by
mxh →
Issue #3344752 by boromino, mxh, jurgenhaas: Config read without...
-
jurgenhaas →
committed 131faed6 on 1.1.x authored by
mxh →
-
jurgenhaas →
committed 8cf42e41 on 1.0.x authored by
mxh →
Issue #3344752 by boromino, mxh, jurgenhaas: Config read without...
-
jurgenhaas →
committed 8cf42e41 on 1.0.x authored by
mxh →
- Status changed to Fixed
over 1 year ago 8:20am 1 March 2023 Automatically closed - issue fixed for 2 weeks with no activity.