Commit 0793cd84 authored by tstoeckler's avatar tstoeckler

Issue #466090 by tstoeckler, sun: Cache library information.

parent adf8c860
<?php
/**
* @file
* Install, uninstall, and update functions for libraries.module.
*/
/**
* Implements hook_schema().
*/
function libraries_schema() {
$schema['cache_libraries'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_libraries']['description'] = 'Cache table to store library information';
return $schema;
}
......@@ -230,8 +230,9 @@ function libraries_info($name = NULL) {
* @see libraries_info()
*/
function libraries_detect($libraries) {
foreach ($libraries as &$library) {
foreach ($libraries as $name => &$library) {
libraries_detect_library($library);
cache_set($name, $library, 'cache_libraries');
}
return $libraries;
}
......@@ -359,8 +360,15 @@ function libraries_load($name, $variant = NULL) {
$loaded = &drupal_static(__FUNCTION__, array());
if (!isset($loaded[$name])) {
$library = libraries_info($name);
libraries_detect_library($library);
$library = cache_get($name, 'cache_libraries');
if ($library) {
$library = $library->data;
}
else {
$library = libraries_info($name);
libraries_detect_library($library);
cache_set($name, $library, 'cache_libraries');
}
// If a variant was specified, override the top-level properties with the
// variant properties.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment