Problem/Motivation
In includes/menu.inc, Radix adds a unique class based on the menu link title:
// Add a unique class using the title.
$title = strip_tags($element['#title']);
$element['#attributes']['class'][] = 'menu-link-' . drupal_html_class($title);
There are cases where $element['#title'] is null. This is the result of a wonky condition that I can't reliably reproduce, but when it happens, there is a PHP 8.1 warning.
Steps to reproduce
See above.
Proposed resolution
Cast the argument to string. Or alternatively, check if the argument is null, and if it is, skip adding the class. Casting to string would mean that the end result was the same as on previous versions of PHP, which is probably the best for backward compatibility.
Remaining tasks
Patch and test.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
cboyden commentedPatch is attached.
Comment #3
dsnopekThis seems fine to me! It's a very small change and keeps behavior the same as it would have been with previous versions of PHP, which reduces the chance of regressions.
Comment #4
doxigo commentedThanks for the patch, pushed to the dev
Comment #6
doxigo commented