Hi,

On line 327 'name' => $list['info']['name'] in context_addassets.module file, i find it not reliable as the theme machine name or folder name is not always the same as the arbitrary theme name. So, I change it to 'name' => $list['name']. Is it going to break anything? Thanks!

Comments

jstoller’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev

Dev version has same issue.

jstoller’s picture

Now that I think about it, why is this code running repeatedly on every page load? From what I can tell, this function is scanning my theme directory eight times on every page load—four times for css and four times for js files. I can understand the module scanning the directory for all files when I'm setting up a new context, but when a page loads, shouldn't the module already know which files its activating and where they are? Forgive me if this is just my ignorance in how context works.

And just because its in the same section of code, I noticed you define the $list variable twice, the same way, for no apparent reason. See my comments in ALL CAPS bellow.

<?php
      foreach ($themes as $item) {

        // Only lists the theme if the theme is enabled.
        // Drupal's list_themes() function returns an array of objects, so we extract an array from each of the objects.
        $list = get_object_vars($item);    /* <--- YOU DEFINE $list HERE. */

        // Only list the theme if it is enabled.
        if ($include_all == FALSE and $list['status'] or $include_all == TRUE) {
          $list = get_object_vars($item);    /* <--- WHY IS $list DEFINED AGAIN HERE. */
          $path = explode('/', $list['filename']);
          unset($path[count($path)-1]);
          $path = implode('/', $path);
          $selected_themes[] = array(
            'name' => $list['info']['name'],    /* <--- THIS SHOULD BE: 'name' => $list['name'], */
            'path' => $path
          );
        }
      }
?>