? 711664_deprecate_global_definiton_hook.patch Index: API.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ctools/API.txt,v retrieving revision 1.5.2.14 diff -u -p -r1.5.2.14 API.txt --- API.txt 23 Feb 2010 23:14:53 -0000 1.5.2.14 +++ API.txt 27 Feb 2010 00:31:39 -0000 @@ -12,6 +12,8 @@ API version 1.4: Generalized ctools_add_css(). Generalized ctools_add_js(). Generalized ctools_image_path(). + Deprecate the use of global hooks for plugin definition. Provide 'use hooks' + plugin option to re-enable their usage. API version 1.3.2: Introduce 'export callback' to individual fields in export.inc Index: help/plugins-creating.html =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ctools/help/plugins-creating.html,v retrieving revision 1.9 diff -u -p -r1.9 plugins-creating.html --- help/plugins-creating.html 22 Jun 2009 02:27:19 -0000 1.9 +++ help/plugins-creating.html 27 Feb 2010 00:31:39 -0000 @@ -69,6 +69,8 @@ The following information can be specifi
If set to TRUE, then the plugin will look for a .info file instead of a .inc. Internally, this will look exactly the same, though obviously a .info file cannot contain functions. This can be good for styles that may not need to contain code.
extension
Can be used to change the extension on a file. By default the extension will be "inc", though it will default to "info" if "info files" is set to true. Do not include the dot in the extension if changing it, that will be added automatically.
+
use hooks
+
Can be used re-enable support for deprecated plugin definition hooks. This only applies to global module definition hooks not hooks from plugin includes which are not deprecated.
In addition, there is a 'module', 'type' and 'hook' settings; these are for internal use of the plugin system and you should not change these. Index: includes/plugins.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ctools/includes/plugins.inc,v retrieving revision 1.18.2.13 diff -u -p -r1.18.2.13 plugins.inc --- includes/plugins.inc 26 Feb 2010 21:35:12 -0000 1.18.2.13 +++ includes/plugins.inc 27 Feb 2010 00:31:39 -0000 @@ -1,5 +1,5 @@ data)) { + // Cache load succeeded so use the cached plugin list. $plugins[$module][$type] = $cache->data; - $all_hooks[$module][$type] = TRUE; - $all_files[$module][$type] = TRUE; + // Set $setup to true so we know things where loaded. + $setup[$module][$type] = TRUE; } else { - $write_cache = TRUE; + // Cache load failed so store that we need to build and write the cache. + $build_cache = TRUE; } } - // Always load all hooks if we need them. - if (!isset($all_hooks[$module][$type])) { - $all_hooks[$module][$type] = TRUE; + // Always load all hooks if we need them. Note we only need them now if the + // plugin asks for them. We can assume that if we have plugins we've already + // called the global hook. + if (!empty($info[$module][$type]['use hooks']) && empty($plugins[$module][$type])) { $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; + // want a list of all plugins or there was a cache miss. + if (empty($setup[$module][$type]) && ($build_cache || !$id)) { + $setup[$module][$type] = TRUE; $plugins[$module][$type] = array_merge($plugins[$module][$type], ctools_plugin_load_includes($info[$module][$type])); } // If we were told earlier that this is cacheable and the cache was // empty, give something back. - if (!empty($write_cache)) { + if ($build_cache) { cache_set("plugins:$module:$type", $plugins[$module][$type], $info[$module][$type]['cache table']); } @@ -432,6 +435,8 @@ function ctools_find_base_themes($themes * 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() * @@ -557,6 +562,7 @@ function ctools_plugin_get_info($module, 'type' => $type, 'cache' => FALSE, 'cache table' => 'cache', + 'use hooks' => FALSE, // Enable use of deprecated global hook definitions. 'defaults' => array(), 'hook' => $module . '_' . $type, 'load themes' => FALSE,