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():

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

Patch coming.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alex_b’s picture

Assigned: alex_b » Unassigned
Status: Active » Needs review
FileSize
2.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().

alex_b’s picture

FileSize
2.4 KB

Missing a ctools_include().

alex_b’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
FileSize
716 bytes

Same as #2 but for Drupal 7.

alex_b’s picture

FileSize
2.03 KB

Please disregard #3.

alex_b’s picture

Title: Static cache in ctools_plugin_api_include() breaks installation routines » ctools_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

alex_b’s picture

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.

neclimdul’s picture

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:

  $cache = cache_get('ctools_plugin_type_info');
alex_b’s picture

Status: Needs work » Needs review
FileSize
2.97 KB
2.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).

neclimdul’s picture

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?

merlinofchaos’s picture

Status: Needs review » Fixed

Committed to all branches.

Status: Fixed » Closed (fixed)

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