Save Search block does not display consistently with Views cache

Created on 12 June 2019, about 5 years ago
Updated 12 February 2024, 7 months ago

Firstly, thank you for your time and work on this very useful module.

EDIT:
Problem: the Save Search block displays inconsistently and erratically for all users. It seems the problem is due to views caching. The Save Search block displays as expected only when views caching is disabled.

Temporary solution: Disable views caching for the search api index view.

How can we fix this so that views caching can be used?

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom sameer

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & SQLite 3.27
    last update 8 months ago
    51 pass, 2 fail
  • 🇦🇹Austria drunken monkey Vienna, Austria

    OK, finally got around to working on this, and I can confirm that this problem indeed exists: as soon as you activate a Views cache plugin (tag- or time-based, doesn’t matter) and a user is served a cached view, the “Save search” block disappears.

    The problem is that this doesn’t even go through the Views cache plugin’s cacheGet() method (which we amended, in the Search API module, to add the search results to the global context) but already produces a hit in the render cache, completely circumventing any of the Views code. See the attached regression test.

    Now, my problem is that I have no idea at all how this could be fixed. Obviously, it would be bad to just disable render caching for the view whenever the “Save search” block is present on the page – but I don’t even know how we could do that.
    The same goes for the (probably) proper solution to execute something like the code in \Drupal\search_api\Plugin\views\cache\SearchApiCachePluginTrait::cacheGet() (i.e., simulate a search query having been executed) for render cache hits, too. I don’t think it’s possible to hook into render cache hits, and it would sound like a performance nightmare even if it were possible.

    Does anyone have any ideas here?
    I’m in any case increasing the priority to “Major”, but I might need to drop the “Release blocker” tag and just create a stable release even if it does have this pretty large flaw.

    (Setting to NR so the test bot will test the patch, but it is of course expected to fail.)

  • 🇦🇹Austria drunken monkey Vienna, Austria

    Note: 📌 Convert README.txt to Markdown Fixed added a link to this issue to README.md, so we should remember to remove this again when we get this issue resolved.

  • 🇦🇹Austria drunken monkey Vienna, Austria

    At this point, unless someone suggests a viable solution very soon I’m pretty sure I’m gonna create a stable release even without resolving this first.

Production build 0.71.5 2024