The function menu_css_names_menu_tree (line 162 menu_css_names.module) uses preg_replace with the /e switch, which is deprecated as of PHP 5.5 (http://php.net/manual/en/migration55.deprecated.php).
Here is an updated bit of code using the preg_replace_callback function. I've tested it on a PHP 5.5 install, and on a PHP 5.3 install, without issues.
Old code, line 164:
$menu = preg_replace('/(<li\s+class="[^"]+)("><a\s+[^>]+>)(.+?)(<\/a>)/e', "'\\1 ' . _make_class_name('\\3') . '\\2\\3\\4'", $menu);
Replace that with this:
$menu = preg_replace_callback(
'/(<li\s+class="[^"]+)("><a\s+[^>]+>)(.+?)(<\/a>)/',
function ($m) {
return $m[1] . ' ' . _make_class_name($m[3]) . $m[2] . $m[3] . $m[4];
},
$menu
);
I've spread the lines out for legibility for those encountering preg_replace_callback for the first time.
Figuring out how to patch via git is on my to-do list, so I'll try to roll a proper patch. But feel free to do so and move this little issue along.
Comments
Comment #1
13jupiters commentedAn attempt at a patch...
Comment #2
iaha commentedThis patch works for me. Thanks.
Comment #3
nightonfire commentedWorks for me as well. Can this be put into the new version?
Comment #4
bcjmpr commentedIt worked for me too, thanks!
Comment #5
tripper54 commented+1, Let's get this committed!
Comment #6
nebel54I can confirm that the code-change works (there are no warnings in php 5.6.5) and the resulting menu-html is the same as before.
But the patch was generated in the wrong directory, so it does not apply. The git diff needs to be done from within the module. So I applied your patch and made a new git diff from within the module.
So as there was no code-change from me i'm going to keep the status on RTBC.
Comment #7
klokie commentedThe patch in #6 works for me. Thanks!
Comment #8
pbull commentedTested and confirmed that #6 works under PHP 5.5.23 and 5.6.7
Re-rolling with minor adjustments to adhere to Drupal coding standards.
Comment #9
mikeegoulding#8 Works for me. Been using it for a little while with no issues.
Comment #11
mikeegoulding