Problem/Motivation
When a redirect rule matches (e.g., /old → /new), the request crashes with:
TypeError: Drupal\Core\Render\BubbleableMetadata::applyTo(): Argument #1 ($build) must be of type array, Drupal\Core\Routing\TrustedRedirectResponse given
This happens in src/EventSubscriber/RedirectSubscriber.php when cache metadata is applied to a TrustedRedirectResponse using BubbleableMetadata::applyTo(), which only accepts render arrays.
Steps to reproduce
Steps to reproduce
1.
Enable MyREST SEO redirect rules.
2.
Add rule: /old|/new|301|1.
3.
Visit /old.
Proposed resolution
•
Replace BubbleableMetadata::applyTo($response) with:
$response->addCacheableDependency($metadata);
•
Ensure the metadata sets:
◦
max-age: 0 (no caching of redirect)
◦
contexts: languages:language_interface, url.path (and url.query_args if the module supports preserving query)
◦
tags: config:myrest_seo.redirects
•
Issue fork myrest_seo-3567629
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 #4
sergeydruua commentedComment #6
sergeydruua commented