Hi,
in 7.33 ( https://www.drupal.org/drupal-7.33-release-notes ) was added a "theme_hook_original" variable to templates and theme functions.
Added a "theme_hook_original" variable to templates and theme functions and an optional sitewide theme debug mode, to provide contextual information in the page's HTML to theme developers. The theme debug mode is based on the one used with Twig in Drupal 8 and can be accessed by setting the "theme_debug" variable to TRUE (API addition).
When using DS to theme search results in Apachesolr, starting from Drupal 7.33 (7.34 affected as well) it starts throwing warnings like:
Warning: Invalid argument supplied for foreach() in element_children() (line 6481 of /includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5933 of /includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5943 of /includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5981 of /includes/common.inc).
Warning: Illegal string offset '#printed' in drupal_render() (line 5988 of /includes/common.inc).
In theme.inc, line 1094, there is
$variables['theme_hook_original'] = $theme_hook_original;
and this adds string "ds_search_page" (name of hook) on $build array which later, when sent to drupal_render, doesn't know what to do with that string as it doesn't have any children defined that render function uses to display output.
Now, since 7.33 added this, a lot of modules complain about it, and are handling on their side instead in core. That variable can be unset and ds will work just fine, but there sohuld be much better solution. I am not 100% sure if this should be reported to core as well, but if module maintainers decided to go with fixing on their side until core doesn't react, DS might as well "patch" this up too.
Here are some issues related to new variable added:
https://www.drupal.org/node/2371907
https://www.drupal.org/node/2379771
Update: removed DS and it no errors appeared anymore. Probably DS related issue regarding newly added variable?
Comment | File | Size | Author |
---|---|---|---|
#13 | ds-theme_hook_original_triggers_warning-2385835.patch | 520 bytes | Daemon_Byte |
Comments
Comment #1
milovan CreditAttribution: milovan commentedComment #2
crutch CreditAttribution: crutch commentedI'm experiencing this issue with DS search without solr. Looks like it may be here that needs altering?
sites\all\modules\ds\ds.module
Comment #3
stephane-v CreditAttribution: stephane-v commentedI also experience this issue with DS.
I just added 2 lines in begining of the theme_ds_search_page function to fix this :
Comment #4
joverYou don't need to patch the Display Suite module to solve this problem.
You can easily remove the "theme_hook_original" variable in a custom theme override and still using the theme_ds_search_page()-function like so:
Comment #5
crutch CreditAttribution: crutch commentedThanks jover works perfectly. Just now got back to this.
I added and replaced MYTHEME with my theme name and added to template.php located in my theme folder. Re-save theme by just visiting it and clicking save, then flush cache and all is well.
Comment #6
milovan CreditAttribution: milovan commentedI confirm this works and is better solution than patching DS. Thanks jover!
Comment #7
sanette CreditAttribution: sanette commentedThe jover technique works for me too; thanks!
however there is still a warning when the search produces no result:
Comment #8
webservant316 CreditAttribution: webservant316 commented#4/5 worked for me. hey what is the future of this issue? I just pasted the fix into 6 theme template files. however, I looked forward to removing that code when I can.
Comment #9
aspilicious CreditAttribution: aspilicious commentedI think there a deeper underlaying issues with the search templates.
Sadly enough, I *never* use this functionality myself so it's hard for me to find the time to properly fix this.
It's possible I'm going to apply the bandaid from #3 for now.
Comment #10
webservant316 CreditAttribution: webservant316 commentedI reversed my use of #4/5 so that I did not need to maintain the fix in all my template files. Instead I patched ds directly with #3 and it works fine.
Comment #11
d1m5n CreditAttribution: d1m5n commentedPatch #3 works,
Added:
// fix for Drupal 7.33+
if(isset($build['theme_hook_original'])) {
unset($build['theme_hook_original']);
}
@line 58 in ds/modules/ds_search/ds_search.module
Is this going to be solved in the next version?
If not, i need to repatch this when we update DS.
Comment #12
Daemon_Byte CreditAttribution: Daemon_Byte as a volunteer commented#3 worked for me.
Comment #13
Daemon_Byte CreditAttribution: Daemon_Byte as a volunteer commentedIn the hopes it will speed things up I have rolled #3 into a git patch for the latest development version.
Comment #14
Daemon_Byte CreditAttribution: Daemon_Byte as a volunteer commentedComment #15
webservant316 CreditAttribution: webservant316 commentedhey this didn't get committed to ds-7.x-2.8. I am reapplying patch #3 now. Hope this gets fixed.
Comment #17
aspilicious CreditAttribution: aspilicious commentedAdded the bandaid, forgot this patch when making the 2.9 so I made a 2.10 for all of you affected by this one. (which will be available in a few minutes)
Comment #19
raj45 CreditAttribution: raj45 commentedThanks @aspilicious, upgrading to 2.11 makes the warnings go away.
Comment #20
gchalker@princeton.edu CreditAttribution: gchalker@princeton.edu commentedThanks Cruch, had the same error with my search function. Your script in the theme.php file solved the issue!
Regards, gg
Comment #21
capysara CreditAttribution: capysara commentedI'm still using version 1.9. I was getting these error messages, but the fix in #4/5 worked for me. Thanks!