To reproduce: Using Drupal 7 Beta 2, perform a standard install, enable context and context ui, choose Bartik as the main theme and admin theme, use the admin overlay while on home page to create a sitewide context placing the search form block in the header. Edit and save this context and error message will appear.

I am not sure whether this issue is because of something the theme is doing, something the core block module is doing or something that context is doing. I've traced it to the following code at which point I am uncertain of whether adjusting the code is the appropriate action. I'm filing it here due to the location of a potential fix is in the context code and it seems context is passing the block module function bad data.

context/plugins/context_reaction_block.inc calls _block_get_renderable_array on line 303 (in block_get_blocks_by_region). The block list handed to the block module do not have a content property in the case where the block_list function has context_blocks set by the call to drupal_static on line 317. Moving the foreach loop on line 335 outside of the block guarded by the isset condition on line 319 causes the error to disappear.

I will attach a patch with this change but feedback is requested on whether this is the appropriate way to resolve the error.

Additional notes:

This message does not appear when using Bartik as the admin theme and not using the admin overlay for editing
This message does not appear when using Bartik as the main theme, Seven as the admin theme and the admin overlay for editing.

Comments

tekante’s picture

StatusFileSize
new963 bytes

Attached is a patch illustrating the code change which made the error disappear above. Feedback requested on the appropriateness of this change.

seth.vincent’s picture

I got this error after changing the title of a block in a context.

default theme: bartik.
context: sitewide.

drupal 7.0-rc2.

bmx269’s picture

Having the same error. Will try the patch.

hadsie’s picture

Status: Active » Needs review

this patch seems to do the trick for me too.

Anonymous’s picture

This patch worked for me.

I'm not using Bartik, but a custom theme built from Basic, by the way

Anonymous’s picture

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

This patch works for my configuration (D7.0, context 7.x-3.x-dev) too. Using a custom theme based on tao for D7.

henrijs.seso’s picture

Status: Needs review » Reviewed & tested by the community

then

seth.vincent’s picture

I applied the patch and the error doesn't get thrown anymore.

febbraro’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new802 bytes

Ok, the patch for this turned out to be pretty tricky and not what was used above. The patch in #1 actually caused a lot more work to be done to satisfy an edge case condition. In any case, it is actually related to #687666: When the search form is placed in the dashboard (which is shown in the overlay) searching doesn't work.

Turns out on form submissions in the overlay context_page_build is called twice. The first time it statically caches a block list that is altered by _block_get_renderable_array (it removes the $content property), then the overlay calls context_page_build again and the block list is cached but not in a form that is usable by _block_get_renderable_array the second time around. So the fix to the problem is actually the same as what is used in block_page_build. After context render the blocks into regions, clear that static cache in case something calls it again.

seth.vincent’s picture

updated to context-7.x-3.x-dev and applied patch in #9.
not getting the error and everything seems to be working ok in the ui.

febbraro’s picture

Status: Needs review » Closed (fixed)
ahimsauzi’s picture

Getting the same error in 7.x-3.0-beta5 using nodeblock.

tekante’s picture

ahimsauzi - I am unable to replicate this error with beta5. Please provide information about the steps necessary to trigger the error and if they are different than the steps in the original report it may be best to open a new issue as the underlying cause may be different.

KarlKedrovsky’s picture

tekante - I'm able to reproduce the error reported by ahimsauzi using beta5 by having the call to block_get_blocks_by_region() in a template_preprocess_views_view() hook in my theme's template.php file. I don't get the error when I make the call from template_preprocess_node().

Here's the code that works in the node preprocess method but not the views preprocess method. The "sidebar" region contains a nodeblock block (and others) in both cases.

if ($plugin = context_get_plugin('reaction', 'block')) {
  $variables['sidebar_content'] = $plugin->block_get_blocks_by_region('sidebar');
}

I'm still looking into it, and I'll let you know if I find anything, but let me know if any other information would be helpful.

KarlKedrovsky’s picture

Not sure if this will help or not but I took a look at the context_page_build() function (as suggested in another issue) and modified the above to this:

if ($plugin = context_get_plugin('reaction', 'block')) {
  $variables['sidebar_content'] = $plugin->block_get_blocks_by_region('sidebar');
  drupal_static_reset('context_reaction_block_list');
}

This looks to have fixed this issue for me.

ckng’s picture