- πΊπΈUnited States jvogt Seattle, WA
Just encountered this. Looks like it's due to a change in how the max() function works in php 8+. Before php 8, it sounds like it treated strings as equal to 0. Now it does...something else, like maybe getting the ord() value of strings? Anyway, it takes strings into account and can return a string value.
In this case,
array_keys($settings['items'])
is being passed to max() and those array keys are a mix of ints and strings. If I'm understanding correctly, we only want to look at the int array keys. I'm not sure of the most efficient way to do that, but a foreach would work. Something like:$key = 0; foreach(array_keys($settings['items']) as $index) { if (is_int($index) && $index > $key) { $key++; } } $form_state['key'] = ++$key;