we_megamenu blocks using "\Drupal\system\Entity\Menu" object as admin label

Created on 1 May 2023, over 1 year ago
Updated 20 July 2023, over 1 year ago

I ran into this in the release version, but found that it persists in the current branch as well. We're using Quick Tabs, and when editing a tabset, it tries to pull a complete list of the available blocks that might be used in a tab. Recently (sometime in the past three weeks), it started throwing the following error:

TypeError: strnatcasecmp(): Argument #1 ($string1) must be of type string, Drupal\system\Entity\Menu given in strnatcasecmp() (line 104 of core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php).

I added a few variable dumps into CategorizingPluginManagerTrait.php to try to figure out what was going on, and found that it was breaking here:

    uasort($definitions, function ($a, $b) use ($label_key) {
      if ((string) $a['category'] != (string) $b['category']) {
        return strnatcasecmp($a['category'], $b['category']);
      }
      return strnatcasecmp($a[$label_key], $b[$label_key]);
    });

When a we_megamenu block hits that second return statement, the value of $label_key is "admin_label" and the contents of $a['admin_label'] is a Drupal\system\Entity\Menu object. Since strnatcasecmp wants strings, it's unhappy.

Now we're still using 8.x-1.13, so I know this isn't the result of some recent change in we_megamenu. I'm thinking perhaps there was a core change recently that triggered this problem? I'm not sure...and maybe this isn't where the problem needs to be fixed. But it seemed like the place to start.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States wrd-oaitsd

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

Comments & Activities

Production build 0.71.5 2024