In installation routines, when trying to use default configurations enabled in the same page load, proper API files are not always included. The culprit is a static cache in ctools_plugin_api_include():

<?php
function ctools_plugin_api_include($owner, $api, $minimum_version, $current_version) {
  static =
$already_done = array();
?>

Patch coming.

Comments

Assigned:alex_b» Unassigned
Status:Active» Needs review
StatusFileSize
new2.35 KB

This patch:

- switches ctools_plugin_api_include() to use ctools_static().
- introduces a ctools_get_plugins_reset() function resetting all static variables affecting the result of ctools_get_plugins().
- clean up ctools_export_load_object_reset() by moving the reset of 'ctools_plugin_api_info' static cache to ctools_get_plugins_reset()
- call ctools_get_plugins_reset() from ctools_export_load_object_reset().

StatusFileSize
new2.4 KB

Missing a ctools_include().

Version:6.x-1.x-dev» 7.x-1.x-dev
StatusFileSize
new716 bytes

Same as #2 but for Drupal 7.

StatusFileSize
new2.03 KB

Please disregard #3.

Title:Static cache in ctools_plugin_api_include() breaks installation routinesctools_get_plugins_reset() to reset all static plugin caches

More general title as this issue affects other usage of Plugin API as well - #919866: Registry is rebuilt with stale information

Status:Needs review» Needs work

As neclimdul commented on IRC, #4 will break in some circumstances as the static variable that it removes protects a file include that may include the same class definition, function definition twice.

I think I may have figured out how to sort this out and its staged in my github branch. However, I wonder if #919866: Registry is rebuilt with stale information needs more from this function. Specifically clearing the cache table for this line:

<?php
  $cache
= cache_get('ctools_plugin_type_info');
?>

Status:Needs work» Needs review
StatusFileSize
new2.97 KB
new2.58 KB

I have not yet further investigated registry rebuild issues in Drupal 7. However, I think we should clean up the caching situation in plugins.inc.

- In ctools_plugin_api_include() only throw static flag module files that have actually been included.
- Do not return a modified info array in ctools_plugin_api_include() because it will change depending on whether the static cache is hit or missed.
- Introduce a ctools_get_plugins_reset() to reset all drupal_static caches in plugins.inc
- Use ctools_get_plugins_reset() in export.inc rather than resetting drupal statics directly.

The enclosed patches fix the above issues for Drupal 6 and Drupal 7.

These patches fix a problem where static caches can't be cleared properly on installation (as reported in initial issue).

These patches fix a problem where static caches can't be cleared properly on installation (as reported in initial issue).

So this is getting fixed by the second half of the patch where you move the static cache testing inside the first foreach in ctools_plugin_api_include?

Status:Needs review» Fixed

Committed to all branches.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.