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.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | context_undefined_property-966768-9.patch | 802 bytes | febbraro |
| #1 | context_undefined_property-966768-1.patch | 963 bytes | tekante |
Comments
Comment #1
tekante commentedAttached is a patch illustrating the code change which made the error disappear above. Feedback requested on the appropriateness of this change.
Comment #2
seth.vincent commentedI got this error after changing the title of a block in a context.
default theme: bartik.
context: sitewide.
drupal 7.0-rc2.
Comment #3
bmx269 commentedHaving the same error. Will try the patch.
Comment #4
hadsie commentedthis patch seems to do the trick for me too.
Comment #5
Anonymous (not verified) commentedThis patch worked for me.
I'm not using Bartik, but a custom theme built from Basic, by the way
Comment #6
Anonymous (not verified) commentedThis patch works for my configuration (D7.0, context 7.x-3.x-dev) too. Using a custom theme based on tao for D7.
Comment #7
henrijs.seso commentedthen
Comment #8
seth.vincent commentedI applied the patch and the error doesn't get thrown anymore.
Comment #9
febbraro commentedOk, 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.
Comment #10
seth.vincent commentedupdated 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.
Comment #11
febbraro commentedThanks!
http://drupal.org/cvs?commit=502508
Comment #12
ahimsauziGetting the same error in 7.x-3.0-beta5 using nodeblock.
Comment #13
tekante commentedahimsauzi - 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.
Comment #14
KarlKedrovsky commentedtekante - 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.
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.
Comment #15
KarlKedrovsky commentedNot 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:
This looks to have fixed this issue for me.
Comment #16
ckngcreated a new issue on this #2107877: Notice: Undefined property: stdClass::$content in _block_get_renderable_array