Problem/Motivation

When the context_layouts module is enabled, blocks disappear from the available context reactions.

Proposed resolution

The current patch clears all caches in hook_install(). This addresses the issue. However, some outstanding questions remain:

  • In the current patch, should cache flushing be wrapped in if (!drupal_installation_attempted()) to avoid unnecessary cache flushing, since caches will be flushed on install anyway?
  • Can we determine which specific caches need to be flushed and concentrate on those rather than doing a costly full cache flush? E.g., do we need to call _context_registry(NULL, TRUE) to flush the context registry cache? Do we need to call cache_clear_all('ctools_plugin_files:', 'cache', TRUE);? Flushing these two didn't address the issue.
  • Is this bug present for all context plugins that alter the context registry to extend other plugins?
  • Should Context handle this rather than requiring modules providing or altering context registry items to explicitly flush caches? E.g., should Context implement hook_modules_enabled() to flush specific caches when a module is enabled that implements hook_context_plugins() or hook_context_registry_alter()?

Temporary workaround: flush caches.

Remaining tasks

User interface changes

none

API changes

none

Original report by bensey

Hi there,

The blocks reactions are missing from contexts when I enable the "context layouts" module.
Once I disable it they reappear in the dropdown list.

Comments

idflood’s picture

Version: 7.x-3.0-beta2 » 7.x-3.x-dev

Same issue still exists in the dev version.

steveburge’s picture

Can confirm the bug - tested on two plain installs.

When context layouts is enabled, blocks disappears from reactions. When Views and context layouts are both enabled, blocks appears in reactions but nothing happens when clicking on Conditions or Reactions.

jkthng’s picture

Facing the same issue.

EvanDonovan’s picture

I also experienced this issue (in beta2). Clean install, have Views & Context Layouts enabled, and Blocks doesn't appear in Reactions.

nedjo’s picture

Clearing caches works as at least a temporary workaround.

#1202354: fusion_core_block_list causes fatal error with Context module is triggered by this bug.

nedjo’s picture

Which cache needs to be cleared?

I tried _context_registry(NULL, TRUE) and cache_clear_all('ctools_plugin_files:', 'cache', TRUE); but neither did the trick.

nedjo’s picture

Status: Active » Needs review
StatusFileSize
new334 bytes

Calling drupal_flush_all_caches() on enabling context layouts fixes the issue--patch attached. I'd rather though be able to determine just which cache or caches need to be flushed.

nedjo’s picture

Issue summary: View changes

Create summary.

tekante’s picture

Adding tag for tracking

tekante’s picture

It appears there is either a race condition or potentially some caching interaction between how Drupal 7 builds the class registry and how ctools tries to automatically register files that contain classes used in plugins. When ctools_registry_file_alter runs on initial enabling of the context layouts module it looks like the list of plugins for context may have been cached (and since context layouts provides a new plugin that is used to override the normal block handling) the class file doesn't get added to the registry until after a cache clear. This results in a failure when checking if the class exists within the ctools_plugin_get_class() function.

To make a long story short, it appears that adding the name of the class file to the .info file has no ill effects and resolves the problem and should be much less invasive than triggering full cache clears or trying to poke around in the ctools system or registry system.

The attached patch does that, please test it out and update if it resolves the problem for you.

Potentially related #1679546: ctools_plugin_get_class incorrectly returns NULL until cache cleared

nedjo’s picture

Wow, nice sleuthing! Haven't tested but this looks like a great fix.

willieseabrook’s picture

Status: Needs review » Reviewed & tested by the community

@tekante

Although this doesn't apply as the drupal packaging info messes with the patch application, the patch fix works.

I manually added "files[] = plugins/context_layouts_reaction_block.inc" and blocks are available again.

Thanks for the patch, I was stumped.

tekante’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x-3.x branch. http://drupalcode.org/project/context.git/commit/7d5e4795a343485385eb28f...

Thanks for the bug report.

Status: Fixed » Closed (fixed)

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

Kim A. Jakobsen’s picture

Version: 7.x-3.x-dev » 7.x-3.0-beta7
Status: Closed (fixed) » Active

I just got this bug again. I use context modules 7.x-1.1.

The problem was resolved by clearing caches.

As easy it is to solve this problem can be quite confusing.

rylynchen’s picture

Got the same issue in 7.x-3.0-beta7.

Does anyone have a solution ?

aleck_wi’s picture

Get the same/
problems with JS. avoided by using FireFox

aleck_wi’s picture

Issue summary: View changes

Updated issue summary.

mareks’s picture

Same problem over here. No blocks at all under context Reactions. Using 7.x-3.1

mareks’s picture

In my case, it helps if I turn off "Context UI" and flush the cache.

falc0’s picture

The only way I was able to fix this was to completely disable, uninstall and reinstall the module. I had a backup of my context items on a different server, so I could import them one by one.

themic8’s picture

We are using 7.x-3.2 and are having the same issue. Comment #19, falc0s, solution has restored blocks for us.

Solution, to completely disable, uninstall and re-install the module. Then we re-imported all of our context items.

  • tekante committed 7d5e479 on 8.x-4.x
    Issue #1297776 by tekante, bensey: Blocks missing from reactions when...

  • tekante committed 7d5e479 on 8.x-0.x
    Issue #1297776 by tekante, bensey: Blocks missing from reactions when...
clemens.tolboom’s picture

[edit]Drupal 7.41 + Context 7.x-3.6[/edit]

We just migrated a site and the block reaction disappeared. Exporting the context shows the correct settings still but the blocks don't display on the targeted pages. Rebuilding the registry / cache did not help.

  • tekante committed 7d5e479 on 8.x-1.x
    Issue #1297776 by tekante, bensey: Blocks missing from reactions when...