Closed (fixed)
Project:
Special menu items
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Feb 2012 at 09:33 UTC
Updated:
1 Aug 2019 at 13:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
gagarine commentedI don't have duplicate classes. Can you please explain how to reproduce?
Comment #2
gagarine commentedReroll. But before commit this, I want to be sure it's necessary.
Comment #3
xen commentedAs far as I remember (it's two finished projects in the past):
If you have a theme or module that imlements hook_preprocess_menu_link that adds classes to links like so:
$vars['element']['#attributes']['class'][] = 'another-class';
You'll end up with duplicate classes, but that's only one possible side effect, other modules might do other things that results in misbehavior when the preprocess functions is called multiple times. Apart from the fact it's just messy and unperforming to run the same code multiple times, even if it is idempotent.
Comment #4
gagarine commentedComment #5
mvcuh, shouldn't the patch in #2 remove the line
return theme('special_menu_items_link_default', $variables);before trying to return something else?Comment #6
marcvangendmvc, you're right.
gagarine, steps to reproduce:
1) Add a preprocess function to your theme:
2) Clear cache and refresh the page.
3) Check your output and see the 'foo' class was added twice.
Here is a reroll which includes the fix for #5. Works great for me.
Comment #7
rossb89 commentedJust found this issue... a 5 year old patch still works, brilliant!
This should definitely be committed. I ended up with some classes added 6 times due to multiple contrib modules and a theme function preprocessing the link.
Comment #8
rossb89 commentedComment #10
gagarine commented