- Issue created by @ssantaeugenia
- 🇪🇸Spain ssantaeugenia
I am attaching a patch that solves the problem in case anyone encounters the same problem.
- Status changed to RTBC
4 months ago 10:22pm 18 July 2024 - 🇺🇸United States wylbur Minneapolis, Minnesota, USA
Confirming that we also experienced this error:
- drupal 10.3.1
- php 8.2
- menu_block 8.x-1.11
Applying the patch resolved the php errors.Marking this as RTBC
- First commit to issue fork.
- 🇺🇸United States daletrexel Minnesota, USA
Can confirm experiencing the same error and that patch/MR work to resolve the problem.
- 🇺🇸United States daletrexel Minnesota, USA
Digging into the source of the problem on my site, I believe that the problem may be due to inconsistency in the Link Attributes Widget module data schema (perhaps a change that wasn't fully migrated?).
We use the Link Attributes Widget module → , which allows you to add attributes such as classes to menu links. For the page that was throwing this menu block error, re-saving the parent menu item resolved the error and allowed the page to show.
In the database, that parent page's 'link_options' field in the 'menu_link_content_data' table looked like this prior to re-saving:
a:1:{s:10:"attributes";a:1:{s:5:"class";s:0:"";}}
And like this after saving:
a:1:{s:10:"attributes";a:1:{s:5:"class";a:1:{i:0;s:0:"";}}}
The class is changed from a string to an array, allowing
$attributes['class'][] = 'menu-item--active-trail';
to work without error.The current patch/MR approach of setting
$attributes['class']
to an empty array, regardless of what was there before seems to work for us, but I wonder if it's potentially removing classes that other users may want to keep?I'm not 100% certain Link Attributes Widget is to blame for the ultimate problem here, but it seems likely given what is involved.
- First commit to issue fork.
- 🇨🇦Canada AaronChristian Kelowna, BC
+1, also ran into this issue.
Same PHP & module combinations as mentioned previously.