Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#8 | 911362-8_D7_plugins_static.patch | 2.58 KB | alex_b |
#8 | 911362-8_D6_plugins_static.patch | 2.97 KB | alex_b |
#4 | 911362-3_static.patch | 2.03 KB | alex_b |
#3 | 919762-2_drush_cc_rebuild.patch | 716 bytes | alex_b |
#2 | 911362-2_static.patch | 2.4 KB | alex_b |
Comments
Comment #1
alex_b CreditAttribution: alex_b commentedThis patch:
- switches
ctools_plugin_api_include()
to usectools_static()
.- introduces a
ctools_get_plugins_reset()
function resetting all static variables affecting the result ofctools_get_plugins()
.- clean up
ctools_export_load_object_reset()
by moving the reset of 'ctools_plugin_api_info' static cache toctools_get_plugins_reset()
- call
ctools_get_plugins_reset()
fromctools_export_load_object_reset()
.Comment #2
alex_b CreditAttribution: alex_b commentedMissing a ctools_include().
Comment #3
alex_b CreditAttribution: alex_b commentedSame as #2 but for Drupal 7.
Comment #4
alex_b CreditAttribution: alex_b commentedPlease disregard #3.
Comment #5
alex_b CreditAttribution: alex_b commentedMore general title as this issue affects other usage of Plugin API as well - #919866: Registry is rebuilt with stale information
Comment #6
alex_b CreditAttribution: alex_b commentedAs 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.
Comment #7
neclimdulI 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:
Comment #8
alex_b CreditAttribution: alex_b commentedI 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).
Comment #9
neclimdulSo 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?
Comment #10
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted to all branches.