Problem/Motivation

There seems to be an edge case in which the plugin information can become inconsistent.
The scenario is as follows:

  1. Fetch plugin information using ctools_get_plugins()
  2. Plugin info cache is hit - so ctools_plugin_load_includes() isn't triggered
  3. Plugin class loaded using ctools_plugin_get_class() - this includes the plugin file using require_once()!
  4. Plugin info cache (including static) is flushed
  5. Fetch plugin information using ctools_get_plugins()
  6. Plugin info cache not hit so ctools_plugin_load_includes() is triggered, but it can't re-include the previously included plugin file. So no plugin info available. The incomplete plugin info is cached.

This turns out to be fatal e.g. when using panelizer. Panelizer isn't able to load the handler, which means no panelizer property is set to the entities loaded - and those entities can be cached in the entitycache. So even if the plugin info cache is re-built, the impact is still there and can screw up quite some stuff ;)

Proposed resolution

I suggest to "outsource" the plugin arrays handling done by ctools_plugin_load_includes() to a dedicated function that only takes care of including files and keep track of the plugin arrays.
This newly introduced function is used where ever the plugin file is included:

  • ctools_plugin_load_includes()
  • ctools_plugin_get_function()
  • ctools_plugin_get_class()

The only function I'm not sure about is ctools_plugin_api_include(), haven't analysed it in-depth.

Remaining tasks

Reviews needed.

User interface changes

None.

API changes

New function ctools_plugin_include_plugin_file() which has to be used to load plugin files.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

das-peter created an issue. See original summary.

Chris Charlton’s picture

Just got bit by this.

darrenwh’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Could you add some tests for this new function

djdevin’s picture

FileSize
3.8 KB

Just rerolling.

joelpittet’s picture

Status: Needs work » Needs review