Problem/Motivation
When a redirect is triggered for this module on a site with different domains for different languages a fatal error occurs. This may be related to upgrading the site to D10, though it seems as though the problem should have existed in D9 as well.
Steps to reproduce
- Ensure you have a Drupal site set up with multilingual modules configured and this module installed and appropriately configured
- Ensure your site has language detection based on domain configured so, e.g., https://frenchexample.com is the French site and https://englishexample.com is the English site
- Ensure you have a node with an English translation but no French translation
- Attempt to visit the (nonexistent) French version of your node
- You will see a WSOD
The relevant error message is something like the following depending on your node path:
InvalidArgumentException: It is not safe to redirect to https://example.com/your-node in Drupal\Component\HttpFoundation\SecuredRedirectResponse->setTargetUrl() (line 58 of /var/www/html/docroot/core/lib/Drupal/Component/HttpFoundation/SecuredRedirectResponse.php).
Proposed resolution
Instead of producing a LocalRedirectResponse (which enforces the same base domain) produce a TrustedRedirectResponse.
Possibly some additional checks could be added to ensure a similar effect to LocalRedirectResponse but accounting for multilingual domains, but I'm not sure that's actually necessary for this module since as far as I know redirects are always generated from existing entities in Drupal.
Remaining tasks
Supply a patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3415979-fatal-error-when.patch | 3.82 KB | dylan donkersgoed |
Issue fork content_translation_redirect-3415979
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
dylan donkersgoed commentedPatch attached.
Comment #4
walkingdexter commentedMerged, thanks!