typeError: unsupported operand types: string + int in panels_flexible_add_item_form_submit()

Created on 15 December 2022, over 1 year ago
Updated 3 August 2023, 11 months ago

When adding a region, I get the error below:
typeError: unsupported operand types: string + int in panels_flexible_add_item_form_submit() (line 1569 of /panels/plugin/layouts/flexible/flexible.inc

Related to PHP 8, not seeing this in PHP 7.4

πŸ› Bug report
Status

Active

Version

3.11

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium frank.schram

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States jvogt

    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;
    
Production build 0.69.0 2024