If multiple modules are enabled and the 2nd module uses the export_ui plugin the menu system is not correctly built until a subsequent cache clear is done. This appears to be because of static caching present in ctools_get_plugins for the $plugins variable which does not have the plugin data for the 2nd module.

To replicate enable both the context and context_ui modules at the same time, or, with drush use pm-enable with the arguments: blog context_ui. The module being enabled with context_ui is irrelevant as long as it is enabled first. After enabling, the menu link for context will not appear on admin/structure until a cache clear is performed. Using drush with arguments context_ui blog avoids this issue as context_ui (which provides export_ui plugin data) is enabled first.

Attached is a patch which clears the ctools_plugin_setup cache on hook_modules_enabled which resolves the issue.

This issue derived from research into issue #933946: Missing Context UI in admin/structure/context

CommentFileSizeAuthor
module_enabling.patch575 bytestekante

Comments

David_Rothstein’s picture

Status: Active » Needs review

Very nice coincidence... I was just looking into the exact same problem this morning!

We are running into this same issue in the Views UI sprint. The latest version of Views UI being developed will use Ctools for some of its menu items, and a similar bug occurs. If you enable both Views and Views UI at the same time, the menu items don't get registered correctly.

I confirmed that the above patch fixes the problem for the case of Views as well.

It looks mostly good to me, but the only question I would have would be if it's better to put this static cache clearing in the ctools_get_plugins_reset() function, and then call ctools_get_plugins_reset() from inside hook_modules_enabled(). This is because ctools_get_plugins_reset() is currently defined as follows:

/**
 * Reset all static caches that affect the result of ctools_get_plugins().
 */
function ctools_get_plugins_reset() {
  drupal_static_reset('ctools_plugin_load_includes');
  drupal_static_reset('ctools_plugin_api_info');
}

This indicates that it is intended to be the central place for clearing these static caches.

David_Rothstein’s picture

On a related note, while investigating this, I noticed that there are a number of other static caches that get hit from code paths inside ctools_get_plugins(), suggesting they should be cleared as well - given the stated purpose of the ctools_get_plugins_reset() function.

However, it doesn't seem like any of the others have known side effects, so maybe it's OK as is. I could make a list of the other statics if necessary, though.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed with David's suggestions in #2. #2 seems reasonable and could be filed as a patch in another issue.

Status: Fixed » Closed (fixed)

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

neurojavi’s picture

Status: Closed (fixed) » Active

Hi:

I'm having similar problems since my update of ctools and views to last dev version. I don't know if my problems are related to this issue. If they aren't please let me know and I'll open a new issue.

I have ctools, views 3 and context in their latest dev versions for D7. When I enable only one of views ui or context ui modules alone they work as expected, but if I have both modules enabled at the same time I only can acces to views ui. Context ui dissapears from menu and admin/structure/context doesn't appear (it shows admin/structure). It doesn't matter what module enable first, allways "win" views ui.

This doesn't happen with previous versions.

I've tried this with a empty drupal install and have spen't a lot of hours untill I've discovered it is views ui the module which causes context ui to dissapear.

Many thanks.-

merlinofchaos’s picture

Status: Active » Closed (fixed)

I fixed this in Views a couple of days ago. This issue is completely unrelated, as well. There is a recent issue for exactly what you found, though.

Returning to previous status.