non security modules update
This commit is contained in:
@@ -9,6 +9,14 @@
|
||||
* Implements hook_flush_caches().
|
||||
*/
|
||||
function libraries_flush_caches() {
|
||||
// Clear static caches.
|
||||
// We don't clear the 'libraries_load' static cache, because that could result
|
||||
// in libraries that had been loaded before the cache flushing to be loaded
|
||||
// again afterwards.
|
||||
foreach (array('libraries_get_path', 'libraries_info') as $name) {
|
||||
drupal_static_reset($name);
|
||||
}
|
||||
|
||||
// @todo When upgrading from 1.x, update.php attempts to flush caches before
|
||||
// the cache table has been created.
|
||||
// @see http://drupal.org/node/1477932
|
||||
@@ -133,7 +141,7 @@ function libraries_scan_info_files() {
|
||||
$files = array();
|
||||
foreach ($directories as $dir) {
|
||||
if (file_exists($dir)) {
|
||||
$files = array_merge($files, file_scan_directory($dir, '@^[a-z0-9._-]+\.libraries\.info$@', array(
|
||||
$files = array_merge($files, file_scan_directory($dir, '@^[A-Za-z0-9._-]+\.libraries\.info$@', array(
|
||||
'key' => 'name',
|
||||
'recurse' => FALSE,
|
||||
)));
|
||||
@@ -158,6 +166,13 @@ function libraries_scan_info_files() {
|
||||
* An array of library information, passed by reference.
|
||||
*/
|
||||
function libraries_invoke($group, &$library) {
|
||||
// When introducing new callback groups in newer versions, stale cached
|
||||
// library information somehow reaches this point during the database update
|
||||
// before clearing the library cache.
|
||||
if (empty($library['callbacks'][$group])) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($library['callbacks'][$group] as $callback) {
|
||||
libraries_traverse_library($library, $callback);
|
||||
}
|
||||
@@ -333,27 +348,31 @@ function &libraries_info($name = NULL) {
|
||||
|
||||
if (!isset($libraries)) {
|
||||
$libraries = array();
|
||||
// Gather information from hook_libraries_info().
|
||||
|
||||
// Gather information from hook_libraries_info() in enabled modules.
|
||||
foreach (module_implements('libraries_info') as $module) {
|
||||
foreach (module_invoke($module, 'libraries_info') as $machine_name => $properties) {
|
||||
$properties['info type'] = 'module';
|
||||
$properties['module'] = $module;
|
||||
$libraries[$machine_name] = $properties;
|
||||
}
|
||||
}
|
||||
|
||||
// Gather information from hook_libraries_info() in enabled themes.
|
||||
// @see drupal_alter()
|
||||
global $theme, $base_theme_info;
|
||||
if (isset($theme)) {
|
||||
$theme_keys = array();
|
||||
foreach ($base_theme_info as $base) {
|
||||
$theme_keys[] = $base->name;
|
||||
}
|
||||
$theme_keys[] = $theme;
|
||||
foreach ($theme_keys as $theme_key) {
|
||||
$function = $theme_key . '_' . 'libraries_info';
|
||||
$themes = array();
|
||||
foreach (list_themes() as $theme_name => $theme_info) {
|
||||
if ($theme_info->status && file_exists(drupal_get_path('theme', $theme_name) . '/template.php')) {
|
||||
// Collect a list of viable themes for re-use when calling the alter
|
||||
// hook.
|
||||
$themes[] = $theme_name;
|
||||
|
||||
include_once drupal_get_path('theme', $theme_name) . '/template.php';
|
||||
|
||||
$function = $theme_name . '_libraries_info';
|
||||
if (function_exists($function)) {
|
||||
foreach ($function() as $machine_name => $properties) {
|
||||
$properties['theme'] = $theme_key;
|
||||
$properties['info type'] = 'theme';
|
||||
$properties['theme'] = $theme_name;
|
||||
$libraries[$machine_name] = $properties;
|
||||
}
|
||||
}
|
||||
@@ -364,6 +383,7 @@ function &libraries_info($name = NULL) {
|
||||
// .info files override module definitions.
|
||||
foreach (libraries_scan_info_files() as $machine_name => $file) {
|
||||
$properties = drupal_parse_info_file($file->uri);
|
||||
$properties['info type'] = 'info file';
|
||||
$properties['info file'] = $file->uri;
|
||||
$libraries[$machine_name] = $properties;
|
||||
}
|
||||
@@ -373,8 +393,20 @@ function &libraries_info($name = NULL) {
|
||||
libraries_info_defaults($properties, $machine_name);
|
||||
}
|
||||
|
||||
// Allow modules to alter the registered libraries.
|
||||
drupal_alter('libraries_info', $libraries);
|
||||
// Allow enabled modules and themes to alter the registered libraries.
|
||||
// drupal_alter() only takes the currently active theme into account, not
|
||||
// all enabled themes.
|
||||
foreach (module_implements('libraries_info_alter') as $module) {
|
||||
$function = $module . '_libraries_info_alter';
|
||||
$function($libraries);
|
||||
}
|
||||
foreach ($themes as $theme) {
|
||||
$function = $theme . '_libraries_info_alter';
|
||||
// The template.php file was included above.
|
||||
if (function_exists($function)) {
|
||||
$function($libraries);
|
||||
}
|
||||
}
|
||||
|
||||
// Invoke callbacks in the 'info' group.
|
||||
foreach ($libraries as &$properties) {
|
||||
@@ -418,6 +450,8 @@ function libraries_info_defaults(&$library, $name) {
|
||||
'versions' => array(),
|
||||
'integration files' => array(),
|
||||
'callbacks' => array(),
|
||||
// @todo Remove in 7.x-3.x
|
||||
'post-load integration files' => FALSE,
|
||||
);
|
||||
$library['callbacks'] += array(
|
||||
'info' => array(),
|
||||
@@ -461,9 +495,11 @@ function libraries_detect($name) {
|
||||
// Re-use the statically cached value of libraries_info() to save memory.
|
||||
$library = &libraries_info($name);
|
||||
|
||||
// Exit early if the library was not found.
|
||||
if ($library === FALSE) {
|
||||
return $library;
|
||||
}
|
||||
|
||||
// If 'installed' is set, library detection ran already.
|
||||
if (isset($library['installed'])) {
|
||||
return $library;
|
||||
@@ -600,6 +636,12 @@ function libraries_load($name, $variant = NULL) {
|
||||
cache_set($name, $library, 'cache_libraries');
|
||||
}
|
||||
|
||||
// Exit early if the library was not found.
|
||||
if ($library === FALSE) {
|
||||
$loaded[$name] = $library;
|
||||
return $loaded[$name];
|
||||
}
|
||||
|
||||
// If a variant was specified, override the top-level properties with the
|
||||
// variant properties.
|
||||
if (isset($variant)) {
|
||||
@@ -652,13 +694,30 @@ function libraries_load($name, $variant = NULL) {
|
||||
*/
|
||||
function libraries_load_files($library) {
|
||||
// Load integration files.
|
||||
if (!empty($library['integration files'])) {
|
||||
foreach ($library['integration files'] as $module => $files) {
|
||||
libraries_load_files(array(
|
||||
'files' => $files,
|
||||
'path' => '',
|
||||
'library path' => drupal_get_path('module', $module),
|
||||
));
|
||||
if (!$library['post-load integration files'] && !empty($library['integration files'])) {
|
||||
$enabled_themes = array();
|
||||
foreach (list_themes() as $theme_name => $theme) {
|
||||
if ($theme->status) {
|
||||
$enabled_themes[] = $theme_name;
|
||||
}
|
||||
}
|
||||
foreach ($library['integration files'] as $provider => $files) {
|
||||
if (module_exists($provider)) {
|
||||
libraries_load_files(array(
|
||||
'files' => $files,
|
||||
'path' => '',
|
||||
'library path' => drupal_get_path('module', $provider),
|
||||
'post-load integration files' => FALSE,
|
||||
));
|
||||
}
|
||||
elseif (in_array($provider, $enabled_themes)) {
|
||||
libraries_load_files(array(
|
||||
'files' => $files,
|
||||
'path' => '',
|
||||
'library path' => drupal_get_path('theme', $provider),
|
||||
'post-load integration files' => FALSE,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,15 +765,60 @@ function libraries_load_files($library) {
|
||||
foreach ($library['files']['php'] as $file => $array) {
|
||||
$file_path = DRUPAL_ROOT . '/' . $path . '/' . $file;
|
||||
if (file_exists($file_path)) {
|
||||
require_once $file_path;
|
||||
_libraries_require_once($file_path);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load integration files.
|
||||
if ($library['post-load integration files'] && !empty($library['integration files'])) {
|
||||
$enabled_themes = array();
|
||||
foreach (list_themes() as $theme_name => $theme) {
|
||||
if ($theme->status) {
|
||||
$enabled_themes[] = $theme_name;
|
||||
}
|
||||
}
|
||||
foreach ($library['integration files'] as $provider => $files) {
|
||||
if (module_exists($provider)) {
|
||||
libraries_load_files(array(
|
||||
'files' => $files,
|
||||
'path' => '',
|
||||
'library path' => drupal_get_path('module', $provider),
|
||||
'post-load integration files' => FALSE,
|
||||
));
|
||||
}
|
||||
elseif (in_array($provider, $enabled_themes)) {
|
||||
libraries_load_files(array(
|
||||
'files' => $files,
|
||||
'path' => '',
|
||||
'library path' => drupal_get_path('theme', $provider),
|
||||
'post-load integration files' => FALSE,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function for require_once.
|
||||
*
|
||||
* A library file could set a $path variable in file scope. Requiring such a
|
||||
* file directly in libraries_load_files() would lead to the local $path
|
||||
* variable being overridden after the require_once statement. This would
|
||||
* break loading further files. Therefore we use this trivial wrapper which has
|
||||
* no local state that can be tampered with.
|
||||
*
|
||||
* @param $file_path
|
||||
* The file path of the file to require.
|
||||
*/
|
||||
function _libraries_require_once($file_path) {
|
||||
require_once $file_path;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the version information from an arbitrary library.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user