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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adamsro created an issue. See original summary.

adamsro’s picture

adamsro’s picture

markhalliwell’s picture

Status: Active » Needs work

Hm... 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).

adamsro’s picture

That's a good point. I suppose since order doesn't matter we could just use array unique though?

burnsjeremy’s picture

Status: Needs work » Needs review

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

markhalliwell’s picture

Status: Needs review » Needs work

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

adamsro’s picture

Here'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.

adamsro’s picture

Oh it looks like some trailing whitespace corrections slipped into the last patch... I can re-roll if it matters.

markhalliwell’s picture

@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:

+++ b/includes/utilities.inc
@@ -274,7 +274,13 @@ function icon_enabled_themes() {
+        foreach (array_keys($theme->base_themes) as $base_theme_machine_name) {

$base_theme_machine_name is rather unnecessarily verbose. Simply using $name would suffice since it's not used anywhere else in the function.

adamsro’s picture

Nop! Here's the patch with the variable named $name.

  • markcarver committed e0eb36c on 7.x-1.x authored by adamsro
    Issue #2552303 by adamsro: Icon bundles from base themes not loaded
    
markhalliwell’s picture

Version: 7.x-1.0-beta6 » 7.x-1.x-dev
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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