diff --git includes/plugins.inc includes/plugins.inc index f0044a0..2c7159d 100644 --- includes/plugins.inc +++ includes/plugins.inc @@ -164,8 +164,7 @@ function ctools_plugin_api_include($owner, $api, $minimum_version, $current_vers */ function ctools_get_plugins($module, $type, $id = NULL) { static $plugins = array(); - static $all_hooks = array(); - static $all_files = array(); + static $setup = array(); static $info = array(); if (!isset($info[$module][$type])) { @@ -178,32 +177,26 @@ function ctools_get_plugins($module, $type, $id = NULL) { // with content updates is convenient. $cache = cache_get("plugins:$module:$type", $info[$module][$type]['cache table']); - // if cache load successful, set $all_hooks and $all_files to true. if (!empty($cache->data)) { - $plugins[$module][$type] = $cache->data; - $all_hooks[$module][$type] = TRUE; - $all_files[$module][$type] = TRUE; + // Cache loaded successfuly. + $plugins[$module][$type] = $cache->data; + // Set $setup to true so we know things where loaded. + $setup[$module][$type] = TRUE; } else { + // Cache load failed so store that we need to write cache later. $write_cache = TRUE; } } - // Always load all hooks if we need them. - if (!isset($all_hooks[$module][$type])) { - $all_hooks[$module][$type] = TRUE; - $plugins[$module][$type] = ctools_plugin_load_hooks($info[$module][$type]); - } - - // First, see if it's in our hooks before we even bother. - if ($id && array_key_exists($id, $plugins[$module][$type])) { - return $plugins[$module][$type][$id]; - } - - // Then see if we should load all files. We only do this if we - // want a list of all plugins. - if ((!$id || $info[$module][$type]['cache']) && empty($all_files[$module][$type])) { - $all_files[$module][$type] = TRUE; + // See if we should load plugins. We only do this if we want a list of all + // plugins or the cache missed. + if ((!$id || $info[$module][$type]['cache']) && empty($setup[$module][$type])) { + $setup[$module][$type] = TRUE; + $plugins[$module][$type] = array(); + if ($info['use hooks']) { + $plugins[$module][$type] = ctools_plugin_load_hooks($info[$module][$type]); + } $plugins[$module][$type] = array_merge($plugins[$module][$type], ctools_plugin_load_includes($info[$module][$type])); } @@ -419,6 +412,8 @@ function ctools_find_base_themes($themes, $key, $used_keys = array()) { * Load plugin info for the provided hook; this is handled separately from * plugins from files. * + * @deprecated plugin includes should be used in favor of this method. + * * @param $info * The info array about the plugin as created by ctools_plugin_get_info() * @@ -493,6 +488,7 @@ function _ctools_process_data($result, $info, $module, $path, $file) { 'name' => $name, 'path' => $path, 'file' => $file, + 'use hooks' => FALSE, // Use deprecated hook definitions. 'plugin module' => $info['module'], 'plugin type' => $info['type'], );