Call to a member function preExecute() on null in SearchApiTagCache->alterCacheMetadata()

Created on 20 September 2021, over 3 years ago
Updated 16 October 2023, over 1 year ago

Problem/Motivation

Importing and altering the Search View with pre selected Cache setting set to "Search API (tag-based)" on module hook_install() results in the following error -

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

Steps to reproduce

1. Create a custom module. (See attached zipped folder for all files)
2. Write a hook_install() in .install file. (See attached zipped folder for all files)
3. Write a helper method in .module file that loads the search view and saves the view programatically. (See attached zipped folder for all files)
4. Inside module config/install directory, attach a views.view.search.yml file that has cache setting set to Search API (tag-based) (See attached zipped folder for all files).
5. Enable the module and notice the above mentioned error.

Proposed resolution

Add an "if" condition to the query variable, to check & proceed only if the query variable is not empty. Somehow $query returned is empty and hence the error shows up.

Remaining tasks

Please suggest if this needs any further improvements.

🐛 Bug report
Status

Fixed

Version

1.30

Component

Views integration

Created by

🇮🇳India panshulk Ghaziabad, Uttar Pradesh

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.

Production build 0.71.5 2024