Coming from Search API Autocomplete tests where a deprecation is triggered by this module:

Calling Drupal\Core\Render\Renderer::addCacheableDependency() with an object that doesn't implement Drupal\Core\Cache\CacheableDependencyInterface is deprecated in drupal:11.3.0 and will throw an error in drupal:13.0.0. See https://www.drupal.org/node/3525389

It’s caused by this code in \Drupal\search_api_page\Form\SearchApiPageBlockForm::buildForm():

    $this->renderer->addCacheableDependency($form, $search_api_page->getConfigDependencyName());
    $this->renderer->addCacheableDependency($form, $langcode);

Both of these $dependency arguments are actually just strings, which aren’t “cacheable dependencies”. You probably want to add $search_api_page itself as a dependency, and the current content language as a cache context.

Currently, this just makes the form uncacheable (which is also not intended, I think), but apparently it will even cause an error/exception in Drupal 13.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

drunken monkey created an issue. See original summary.

drunken monkey’s picture

Issue summary: View changes
Status: Active » Needs review

Should be fixed in this MR.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Nice @drunken monkey!

karlshea made their first commit to this issue’s fork.

karlshea’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

grevil’s picture

@karlshea. Any reason you added "url" as a cache context here: https://git.drupalcode.org/issue/search_api_page-3548259/-/commit/8a63ea...?

This causes: #3616112: Block should not use "url" as cache context?.

The only reason I can think of this was done is the following edge case:
-We have a global `search_api_page` block on every page including the search page `/search`.
- Now somebody visits `/search?keys=shoes` the block form renders with "shoes" prefilled and gets cached.
- Now somebody visits `/search?keys=hats`, Drupal doesn't know about the url, so it prefills the block form with the rendered "shoes" again (even though the user is actively searching for "hats")

In that case I provided a MR in the issue.