Add query string parameter when redirecting

Created on 26 March 2020, almost 5 years ago
Updated 22 July 2024, 5 months ago

Issue Summary:
We use this module in an environment that also uses CloudFlare caching. The redirects work as needed, but the part that is not working for us is the system message - when a user is redirected because there is no translation. We are pretty sure that this is occurring because CloudFlare has cached the page(s) without a system message, so when someone is correctly redirected to one of the pages in cache, they will unfortunately not get the message as to why they were redirected. This is a break in the user-experience, and something we would like to remedy.

Possible Workaround:
We thought if we redirected with query string parameters, and if the page has been cached and there is no system message, then we can use JavaScript to insert a message into the DOM.

About the Patch:
The patch first looks to see if there is an existing query string [by looking for a question mark character (?)]. Then, it will be able to correctly append to the existing query string [or create a new query string].

The query string values we would like to add to the Drupal redirect, and then "read" with JavaScript are:

'translation=0' and 'langcode=' . $current_language->getId()

What they are essentially signifying are:

  1. There is no translation for the content in the language originally submitted
  2. The language code the user originally wanted to see the content in

From there, we will use a JavaScript to look for these query string values. If they exist, and are acceptable, being careful to check for XSS, then we can look to see if there is a system message already on the page. If not, we can generate the message by appending a div with the message to where it belongs explaining to the user why they were redirected.

Thanks.

πŸ’¬ Support request
Status

Fixed

Version

1.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rod.homor

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