Fix for drupal_get_library

Rob Loach's picture
  1. function drupal_get_library($module, $name) {
  2.   $libraries = &drupal_static(__FUNCTION__, array());
  3.  
  4.   // Make sure we have the libraries available from the hosting module.
  5.   if (!isset($libraries[$module])) {
  6.     // Retrieve all the libraries associated with the module.
  7.     $module_libraries = module_invoke($module, 'library');
  8.  
  9.     // Allow modules to alter the module's registered libraries
  10.     if (is_array($module_libraries)) {
  11.       drupal_alter('library', $module_libraries);
  12.  
  13.       // Store the libraries statically.
  14.       $libraries[$module] = $module_libraries;
  15.     }
  16.     else {
  17.       $libraries[$module] = array();
  18.     }
  19.   }
  20.   if (isset($libraries[$module][$name]) && is_array($libraries[$module][$name])) {
  21.     // Make sure the library has the default empty dependencies, JavaScript and
  22.     // stylesheets.
  23.     $libraries[$module][$name] += array('dependencies' => array(), 'js' => array(), 'css' => array());
  24.   }
  25.   else {
  26.     $libraries[$module][$name] = FALSE;
  27.   }
  28.  
  29.   return $libraries[$module][$name];
  30. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.