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

13jupiters’s picture

Status: Active » Needs review
StatusFileSize
new610 bytes

An attempt at a patch...

iaha’s picture

Issue summary: View changes

This patch works for me. Thanks.

nightonfire’s picture

Works for me as well. Can this be put into the new version?

bcjmpr’s picture

It worked for me too, thanks!

tripper54’s picture

Status: Needs review » Reviewed & tested by the community

+1, Let's get this committed!

nebel54’s picture

I 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.

klokie’s picture

The patch in #6 works for me. Thanks!

pbull’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +PHP 5.5
StatusFileSize
new1.08 KB

Tested 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.

mikeegoulding’s picture

Status: Needs review » Reviewed & tested by the community

#8 Works for me. Been using it for a little while with no issues.

  • mikethedude committed c5f2aa6 on 7.x-1.x authored by pbull
    Issue #2114327 by 13jupiters, pbull, Nebel54: Update...
mikeegoulding’s picture

Version: 7.x-1.0-beta1 » 7.x-1.0-beta2
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.