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.
Issue fork search_api_page-3548259
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
Comment #3
drunken monkeyShould be fixed in this MR.
Comment #4
anybodyNice @drunken monkey!
Comment #7
karlsheaComment #10
grevil commented@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.