Hi,

When not using the provided CSS generation (in this case because I don't want them as background images) menu icons show a bug behaviour handling cache.

In the code it is assumed that the way to refresh the icons after submit is through

image_path_flush (clears the styles)
menu_icons_css_generate (recreates the css)

However the menu's cache is not cleared. Because the way menu icons works is assuming the icon is part of the menu link (e.g like menu attributes) the following function should be called when the icon changes:

menu_cache_clear_all();

This assures the menu information gets refreshed when there is a change.

This is particularly useful to people (like myself) that are implementing theme_menu_link hooks to change the rendering of the menu item (in my case to make the images inline). By clearing the menu's cache we ensure that theme_menu_link can get called again if there is a change in the menu item (e.g menu icon changed).

I will submit a small patch in the following comment.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kyuubi’s picture

Status: Active » Needs review
FileSize
372 bytes

Here is the patch.

kyuubi’s picture

Updating the patch as this needs to happen also in menu_icons_node_save

kyuubi’s picture

Hi,

Also I would like to volunteer to be a maintainer for this module.

Let me know if you are interested.

Thanks,

jomarocas’s picture

thanks for your patch, but the second patch #2 is for a git? no working and is wrong the method

--- profiles/dg_land/modules/contrib/menu_icons/menu_icons.module (revision 63e98989c83bd705798d196525a4c87291ded6c6)
+++ profiles/dg_land/modules/contrib/menu_icons/menu_icons.module

thanks for patch

NewZeal’s picture

There is no need to clear the menu cache. Cache clear all works because it rebuilds the menu_icons css which is where all the action is. It would be better if menu_icons had the following in form_alter

switch ($form_id) {
    case 'image_style_form':
    case 'menu_edit_item':
      $form['#submit'][] = 'menu_icons_menu_edit_submit';
      break;
}

With the following function available

function menu_icons_menu_edit_submit($form, $form_state) {
    menu_icons_css_generate();
}

As it is, it has been two years since anyone last committed to this module so not much chance of anything happening soon!

NewZeal’s picture

Here is a patch to accompany my previous comment.