Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
icon.inc is not loaded for base themes.
icon_enabled_themes()
was just patched to properly use base themes' machine names but now when the array is appended to $themes array keys may be duplicate, e.g. array([0] => 'barnik') + array([0] => 'bootstrap')
in which case the left hand side is preferred and the base theme is not added to the array.
Comment | File | Size | Author |
---|---|---|---|
#11 | icon-bundles-in-base-themes-not-loaded-2552303-11.patch | 1.45 KB | adamsro |
Comments
Comment #2
adamsro CreditAttribution: adamsro commentedComment #3
adamsro CreditAttribution: adamsro commentedComment #4
markhalliwellHm... interesting. Ok. In hind sight, this function should also be checking to see if a theme's base themes are already in the $themes array as well (e.g. loop over each base theme and check if it doesn't already exist and only then add it).
Comment #5
adamsro CreditAttribution: adamsro commentedThat's a good point. I suppose since order doesn't matter we could just use array unique though?
Comment #6
burnsjeremy CreditAttribution: burnsjeremy as a volunteer commentedI was having the same issue when I updated 2 different sites, one using Bootstrap and another using Zurb with my own font icon provider. The patch above fixed the issue and allowed me to use icons through the icon API again. Not entirely sure if the other change would need to happen since array unique works but I didn't check the full array to see if there could be a possible performance issue either. Although I have seen in some instances that array_unique has performance issues but this function is cached so it does not get ran all the time due to awesome implementation :) Therefore I am placing in Needs Review again so Mark can chime in, I can roll another patch if you want to take the array_unique out and do it the other way.
Comment #7
markhalliwellI would prefer to do a for loop with isset checks here. Having 3 array function calls on one line makes it too easy to overlook/debug. There should also be a comment explaining what is happening there and why we're looping over it I think.
Comment #8
adamsro CreditAttribution: adamsro commentedHere's a patch with loops instead of array_unique. Another option would be to move the array_unique call under the loop and properly comment it. This attached patch is probably easier to read, though.
Comment #9
adamsro CreditAttribution: adamsro commentedOh it looks like some trailing whitespace corrections slipped into the last patch... I can re-roll if it matters.
Comment #10
markhalliwell@adamsro, thanks for the re-roll :) Yes, this is more of what I had in mind. The whitespace changes are fine as they're actually removing extra whitespace on those lines.
Just one tiny nitpick:
$base_theme_machine_name
is rather unnecessarily verbose. Simply using$name
would suffice since it's not used anywhere else in the function.Comment #11
adamsro CreditAttribution: adamsro commentedNop! Here's the patch with the variable named
$name
.Comment #13
markhalliwell