Child plugins don't get passed to _ctools_process_data(). This means that they don't get defaults set (such as the module name), don't get passed to the alter hooks, and don't get passed to the plugin owner for processing.

In ctools_get_plugins():

  // Then see if we should load all files. We only do this if we
  // want a list of all plugins or there was a cache miss.
  if (empty($setup[$module][$type]) && ($build_cache || !$id)) {
    $setup[$module][$type] = TRUE;
###### This loads each plugin .inc file. For each file, ctools_plugin_process() is called, which then calls _ctools_process_data() which does the plugin processing work.
    $plugins[$module][$type] = array_merge($plugins[$module][$type], ctools_plugin_load_includes($info[$module][$type]));
    // If the plugin can have child plugins, and we're loading all plugins,
    // go through the list of plugins we have and find child plugins.
    if (!$id && !empty($info[$module][$type]['child plugins'])) {
      // If a plugin supports children, go through each plugin and ask.
      $temp = array();
      foreach ($plugins[$module][$type] as $name => $plugin) {
        // The strpos ensures that we don't try to find children for plugins
        // that are already children.
        if (!empty($plugin['get children']) && function_exists($plugin['get children']) && strpos($name, ':') === FALSE) {
#### The child plugins are merged into the array here -- they don't get processed.
          $temp = array_merge($plugin['get children']($plugin, $name), $temp);
        }
        else {
          $temp[$name] = $plugin;
        }
      }
      $plugins[$module][$type] = $temp;
    }
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Status: Active » Needs review
FileSize
912 bytes

Here's a patch.

joachim’s picture

FileSize
1.78 KB

I missed the 'get child' case -- updated patch.

Chris Matthews’s picture

The 9 July 2015 patch to plugins.inc applied cleanly to the latest ctools 7.x-1.x-dev and if still applicable needs to be reviewed.

Checking patch includes/plugins.inc...
Hunk #1 succeeded at 288 (offset 3 lines).
Hunk #2 succeeded at 335 (offset 2 lines).
Applied patch includes/plugins.inc cleanly.
joelpittet’s picture

This looks like a big oversight but not a lot of attention, I'll attach it to a release plan, probably won't make it into the next release but a future one and see if any others can test it out.

joelpittet’s picture

joelpittet’s picture