On my current project, the same global filter block is used on the page twice, so that it can appear in the header on desktop and the footer on mobile.

Because global_filter_block_view() caches its output, the same HTML ID attributes are then duplicated on the page.

CommentFileSizeAuthor
#1 global_filter-2408867-1.patch5.36 KBgapple

Comments

gapple’s picture

Status: Active » Needs review
StatusFileSize
new5.36 KB

I don't think there is a significant benefit from caching the form in this way.
I don't think there are any side effects from removing the caching in hook_init(), but if there were they should be refactored instead of relied upon.

alexverb’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#2623246: Array to string conversion (when used with search_api and hierarchical_select)

Patch works for me. And it also solves a side issue I had with combining fulltext search and hierarchical select errors. Array to string conversion (when used with search_api and hierarchical_select). Shurely the caching mechanism has more drawbacks than benefits.

I'm marking this issue as reviewed.

alexverb’s picture

Looks like I talked too soon. On the related issue: Removing the caching has as side effect that the filters aren't picked up before the view is built. In other words the view is built before the global filter is set, which is weird. I now need to load the page twice to get the filtering going. But the warnings are gone.

I still feel like we need to apply this patch and look at what is causing this double loading behavior. Gonna open another issue for that if this patch gets committed.

What do you think RdeBoer?

alexverb’s picture

Status: Reviewed & tested by the community » Needs review
Related issues: -#2623246: Array to string conversion (when used with search_api and hierarchical_select)

Aargh, wrong again. Wasn't this patch that solved my problem but the latest dev version did. Back to needs review :(

alexverb’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#2623246: Array to string conversion (when used with search_api and hierarchical_select)

Ya might start to think I've got a dissociative identity disorder but I stumbled upon the error again. This time on the edit page where the hierarchical select is used that I reuse for the global filter. So again I have to tie that issue to this one. And again it seems this patch solves the problem for me. Don't worry I tripple checked this time that the patch really does the work for me. Thx gapple. I never would have found this by myself.

rdeboer’s picture

Thank you all above.
Time for me to to apply this patch
Rik