- Issue created by @agentrickard
- πΊπΈUnited States agentrickard Georgia (US)
In our version 1.2 data for these fields
$element['#value']
seems to be either a valid array or an empty array. - Status changed to Needs review
over 1 year ago 6:01pm 19 April 2023 - πΊπΈUnited States agentrickard Georgia (US)
Here's a patch.
So far as I can tell, this is an error in the existing code. Here's the logic (pre-patch):
if ($value_valid && ((!$value_is_array && (string) $element['#value'] === $key || ($value_is_array && in_array($key, $element['#value']))) || $empty_choice)) { $options[array_search($key, $element['#value'])] = [ 'type' => 'option', 'value' => $key, 'label' => $choice, ]; }
That translates to:
- If the element value is not an array and equals the key, add it to the array
- If the element value is an array and contains the key, add it to the array
But each of these cases then treats $element['#value'] as an array, even though we just checked that it might not be.
Since we are checking that $key exists and equals the value, just using $key here seems correct.
- last update
over 1 year ago 3 pass - πΊπΈUnited States agentrickard Georgia (US)
Bumping to critical, since this can break node editing.
- πΊπΈUnited States cindytwilliams Nashville, TN
Patch #5 no longer applies, so here is a re-roll that applies to the current 2.x-dev version.
- First commit to issue fork.
- Merge request !9Issue #3355182: Potentially Invalid array_search() call in Multiselect.php β (Open) created by mparker17
- π¨π¦Canada mparker17 UTC-4
I've created a merge request, and happily, it seems like everything is working.
Can I trouble someone experiencing this issue to see if they still experience this problem on multiselect-2.0.0-beta4 β , and if so, does the code in the merge request fix the problem?
It would be super-helpful if we could add a regression test, so we can detect if this regresses again in the future.
Thank you in advance for your patience with me! I'm reviewing issues in the queue as part of π± [Plan] Stable 2.0.0 release Active .