WSOD when rendering a view on a disabled index with Search API cache plugin

Created on 16 February 2022, about 3 years ago
Updated 25 January 2024, about 1 year ago

Problem/Motivation

Search API cache plugins cause errors when the index is disabled. The error we see in logs is:

Error: Call to a member function preExecute() on null in Drupal\search_api\Plugin\views\cache\SearchApiTagCache->generateResultsKey()

May be related to 🐛 Call to a member function preExecute() on null in SearchApiTagCache->alterCacheMetadata() Fixed .

Steps to reproduce

  • Configure a Search API based view with a block.
  • Enable Search API tag-based cache plugin for the view, save it.
  • Enable the block.
  • Disable the index.
  • Observe failed page and errors in the log.

Proposed resolution

Cache plugins shouldn't access Search API query in case the view query is in an invalid state.

Remaining tasks

Submit MR/patch.

🐛 Bug report
Status

Needs work

Version

1.0

Component

Views integration

Created by

🇵🇹Portugal dmitriy.trt

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • 🇦🇹Austria drunken monkey Vienna, Austria

    Thanks for reporting this problem and already providing a patch!

    I just added a single additional shouldAbort() check – see the attached patch and please test/review.

    Also: Do we really want to cache an aborted query? Shouldn’t cacheSet() just return in case $query->shouldAbort() is TRUE?

    Finally, I think we should add a regression test for this before committing, to make sure this stays fixed. A WSoD is a rather nasty thing to run into, after all.

  • 🇦🇹Austria drunken monkey Vienna, Austria

    NW for the tests.

  • 🇬🇧United Kingdom Rob230

    I have re-rolled the patch against 1.31.

Production build 0.71.5 2024