Problem/Motivation
This was reported by a client. On a multilingual site, the language for redirects is not preserved so the redirects are not correct.
Steps to reproduce
- Install D9 with Umami Demo profile
- Install redirect module
- Install quant_api module
- Configure site to push content to quant
- Make sure to seed the redirects
- Go to:
/es/node/1/edit
- Open
Redirecciones de URL
- Click
Add URL Redirect
(note, text is not translated)
- Enter redirect
testing-spanish-redirect
, choose Espaรฑol for the language, and save
- Go to:
/es/testing-spanish-redirect
and it should redirect you to /es/recipes/quiche-mediterrรกneo-profundo
(node/1)
- Create an English redirect via
/en/node/1/edit
in the same way using testing-english-redirect
and English language
- Go to:
/en/testing-english-redirect
and it should redirect you to /en/recipes/deep-mediterranean-quiche
(node/1)
- Create a general redirect via
/en/node/1/edit
in the same way using testing-general-redirect
and "All languages"
- Go to:
/en/testing-general-redirect
and it should redirect you to /en/recipes/deep-mediterranean-quiche
(node/1)
- Go to:
/es/testing-general-redirect
and it should redirect you to /es/recipes/quiche-mediterrรกneo-profundo
(node/1)
- You now have different redirects for the same node for Spanish, English, and all languages
- Run the queue, e.g.
drush quant:run-queue
- In the Quant Dashboard, go to
/redirects
and you should see the redirects listed but they all have /en/
as the language prefix
Proposed resolution
Update the redirect logic so the language prefix of the redirect is included. Note that if All languages
is chosen, a redirect will need to be created for every single enabled language.
Test the following use cases
Language configuration
- Non-multilingual site
- Multilingual site, one language, no language path prefix
- Multilingual site, one language, language path prefix
- Multilingual site, multiple languages, no language path prefix
- Multilingual site, multiple languages, language path prefix
Redirects for non-multilingual site (language/translation modules uninstalled)
- One node without a redirect, shouldn't create a redirect except for node/[nid]
- One node with redirect, should create redirect and node/[nid] redirect
Redirects for multilingual site, one language, no language path prefix (language/translation modules installed)
- One node without a redirect, shouldn't create a redirect except for node/[nid]
- One node with 1 redirect with language chosen, should create redirect without path prefix and node/[nid] redirect
- One node with 1 redirect with all languages chosen, should create redirect without path prefix and node/[nid] redirect
Redirects for multilingual site, one language, language path prefix (language/translation modules installed)
- One node without a redirect, shouldn't create redirects except for node/[nid] and [langcode]/node/[nid]
- One node with 1 redirect with language chosen, should create redirect with path prefix and node/[nid] and [langcode]/node/[nid]
- One node with 1 redirect with all languages chosen, should create redirect with path prefix and node/[nid] and [langcode]/node/[nid]
Redirects for multilingual site, multiple languages, no language path prefix
- One untranslated node without a redirect, shouldn't create a redirect except for node/[nid]
- One translated node without a redirect, shouldn't create a redirect except for node/[nid]
- One untranslated node with 1 redirect with language chosen, should create redirect without path prefix and node/[nid] redirect
- One translated node with 1 redirect with language chosen, should create redirect without path prefix and node/[nid] redirect
- One untranslated node with 1 redirect with all languages chosen, should create redirect without path prefix and node/[nid] redirect
- One translated node with 1 redirect with all languages chosen, should create redirect without path prefix and node/[nid] redirect
- One untranslated node with 3 redirects for each language, should create 3 redirects without path prefix and node/[nid] redirect
- One translated node (only 2 of the languages) with 3 redirects for each language, should create 3 redirects without path prefix and node/[nid] redirect
Redirects for multilingual site, multiple languages, language path prefix
- One untranslated node without a redirect, shouldn't create a redirect except for node/[nid] and [langcode]/node/[nid]
- One translated node without a redirect, shouldn't create a redirect except for node/[nid] and [langcode]/node/[nid]
- One untranslated node with 1 redirect with language chosen, should create redirect with path prefix and node/[nid] and [langcode]/node/[nid]
- One translated node with 1 redirect with language chosen, should create redirect with path prefix and node/[nid] and [langcode]/node/[nid]
- One untranslated node with 1 redirect with all languages chosen, should create redirect with path prefix and node/[nid] and [langcode]/node/[nid]
- One translated node with 1 redirect with all languages chosen, should create redirect with path prefix and node/[nid] and [langcode]/node/[nid]
- One untranslated node with 3 redirects for each language, should create 3 redirects with path prefix and node/[nid] and [langcode]/node/[nid]
- One translated node (only 2 of the languages) with 3 redirects for each language, should create 3 redirects with path prefix and node/[nid] and [langcode]/node/[nid]
Remaining tasks
- Debug
- Choose approach for fix
- Create patch
- Review and test
- Commit :)
User interface changes
API changes
Data model changes