I created a custom theme for galleria based on the classic theme. Major difference, I removed the min.js and edited the css a bit. When the website went from develop to acceptance it was placed to a new server. Database was copied and the site worked accept for the galleria slider. The url admin/config/media/galleria/edit/default showed the following error:

Warning: rsort() expects parameter 1 to be array, boolean given in galleria_get_themes() (regel 263 van /sites/all/modules/galleria/galleria.module).

When viewing the advanced settings page (admin/config/media/galleria/advanced), the custom theme didn't had the javascript file.

I looked the line up in the code and it said the following (line 250 - 270):

  if (is_dir($path) && (($path_handle = opendir($path)) !== FALSE)) {
    while (($theme = readdir($path_handle)) !== FALSE) {

      if (!is_dir($path . $theme) || $theme[0] == '.')
        continue;

      // Search for the theme JavaScript file, minified version first
      $js = glob($path . $theme . '/*.min.js');
      if (count($js) == 0)
        $js = glob($path . $theme . '/*.js');

      // Sort by filename to (hopefully) get the newest version.
      if (count($js) > 0) {
        rsort($js);
        $themes[$theme] = $js[0];
      }
    }
    closedir($path_handle);

    cache_set('galleria_themes', $themes);
  }

The actual bug is on line 257:

      $js = glob($path . $theme . '/*.min.js');
      if (count($js) == 0)
        $js = glob($path . $theme . '/*.js');

The function glob returns either an array or false if there went something wrong. In my case, glob returned false. If you do a count on false it returns 1 so the part after if isn't called which should select the not minified version of the js file.

My suggestion is to add the following to the code:

      if (count($js) == 0 || $js == false)
        $js = glob($path . $theme . '/*.js');

It works for my settup.

CommentFileSizeAuthor
rsort-parameter.patch802 bytesh3rj4n

Comments

kroimon’s picture

Status: Needs review » Fixed

Committed your patch. Thanks for reporting this :)

Status: Fixed » Closed (fixed)

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