#91751Redirects are not tied to site configuation breaking referential integrity and making it impossible to test on/transfer from staging systems
Description
The select box for the source domain in the redirects module is filled by using the site configurations and the matching baseVariant. The base variant is shown then.
When saving the redirect it is persisted using the actually shown domain, however (so a baseVariant gets persited, for example). Not – contrary to what one would expect – the site id or the base (from where baseVariants could be retrieved as well) to have proper referential integrity.
Why is this relevant? Because with this you can not test redirects on base variant systems. Nor can you have staging system for testing from where you transfer rows of sys_redirect to the live system.
Currently I’m sitting in front 1000+ redirects having a wrong source_host because a baseVariant was persisted instead of the site id or actual base…. It’s also not possible this way to write a SQL update that transforms the source_host to the one relevant for the current system, because you can not join on yaml files obviously.
It must be possible to save redirects in a form that data integrity to the site configurations is preserved. If this is technically not possible there should not be a dropdown letting you select from site configurations implicitly suggesting that this creates sys_redirect rows actually pointing to the selected site configuration (suggesting that redirects can be transferred between baseVariant setups without losing their functionality).
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[BUGFIX] Redirects are not tied to site configuation breaking referential integrity and making it impossible to test on/transfer from staging systems Resolves: #91751 Releases: main
Related issues 2
History 12
-
Andreas Kießling commented <span data-processor="relativetime" data-value="2020-07-26T13:43:07+00:00" > 07/26/20, 13:43 </span>
-
Andreas Kießling changed Related to #91792 <span data-processor="relativetime" data-value="2020-08-04T23:34:16+00:00" > 08/04/20, 23:34 </span>
-
Andreas Kießling changed Related to #91936 <span data-processor="relativetime" data-value="2020-08-05T16:48:50+00:00" > 08/05/20, 16:48 </span>
-
S P commented <span data-processor="relativetime" data-value="2020-08-06T07:09:31+00:00" > 08/06/20, 07:09 </span>
I understand that the current way makes it posible to create redirects for domains which are NOT in any site yaml. Which is also nice in some cases (to use TYPO3 as a general redirects processor, or for situations where a vHost just redirects all subdomains to the same web root as the parent domian as well – some hoster do this and you can not change it).
I propose that redirects created from site yamls are stored something like “t3://site?id=my-site” to be able to choose between just entering a source domain manually or tie it to a site yaml.
-
S P changed TYPO3 Version
910 <span data-processor="relativetime" data-value="2021-10-20T05:51:50+00:00" > 10/20/21, 05:51 </span> -
S P commented and changed TYPO3 Version
1012 <span data-processor="relativetime" data-value="2024-12-18T09:42:28+00:00" > 12/18/24, 09:42 </span>Still valid on v12. The
sys_redirect.sourcefield is not tied to site configs in any way (e.g.baseVariantspersisted insys_redirect.sourceare not treated as belonging to the actualbaseof the site when redirects are transferred). -
S P commented and changed TYPO3 Version
1213 <span data-processor="relativetime" data-value="2024-12-19T09:59:52+00:00" > 12/19/24, 09:59 </span>Still in v13.
-
Simon Schaufelberger changed TYPO3 Version
1312 <span data-processor="relativetime" data-value="2024-12-19T10:19:57+00:00" > 12/19/24, 10:19 </span> -
S P commented and changed TYPO3 Version
1214 <span data-processor="relativetime" data-value="2026-06-11T08:56:34+00:00" > 06/11/26, 08:56 </span>Still valid on v14: redirects are still created with the current base variant persisted hard in the DB. It should be possible to create redirects bound to a site identifier (for example, the source field should then be
site:my-siteor similar, so that site-bound redirects work cross-environment when migrating them). -
Jonas Eberle commented <span data-processor="relativetime" data-value="2026-10-29T10:06:12+00:00" > 10/29/26, 10:06 </span>
Being able to test redirects on local systems after a pull from live would be really helpful.
For backwards compat. it should still allow free text, but map to a site config when matched.
An upgrade wizard would update to the new data model (one additional column “source_site”, and clean source_host when matched).
I might start work on this in the winter. -
Georg Ringer commented <span data-processor="relativetime" data-value="2026-11-01T09:43:31+00:00" > 11/01/26, 09:43 </span>
I had a look at what it would take to store the site identifier instead of the domain. It is the right direction, because it also covers bases that differ per environment, but it is not trivial. This is based on reading the code on main, nothing has been implemented or tested yet.
Storing the identifier alone loses information:
- Languages on their own domains: a site is not the same as a host.
/imprintonexample.deand onexample.comwould end up in the same cache bucket, so the first record wins and may point to the wrong language. A redirect meant for one domain would also fire on the other. - Paths outside the site base: with the base
example.com/shop/, a request to/oldresolves to aNullSite(SiteMatcher::matchSiteByUri()). Thesiterequest attribute is therefore not enough, the sites have to be looked up by request host. - URL output: the QR code and short URL elements and the QR code, short URL and redirect module templates build URLs directly from
source_hostandsource_path. They need a real host. - String comparisons:
RedirectPermissionGuard, the shadow detection inIntegrityServiceandShortUrlService::isUniqueShortUrl()comparesource_hostas a string.site:mainandexample.comwould look unrelated even though they compete for the same requests. - Validation: the
SourceHostevaluation turnssite:maininto an empty string, while a baremainpasses as a hostname and cannot be told apart from a real host. - API:
RedirectSourceInterface::getHost(), the events and third-party listeners all expect a host, so this needs a breaking changelog entry. - Renaming a site folder would silently detach all redirects bound to that site.
Possible solution:
- Store a prefixed reference in
source_host, e.g.site:<identifier>:<languageId>. The language only stands for its host, and languages sharing a host are normalized to the first one. This keeps today’s per-host behaviour across environments. - In
RedirectService::matchRedirect(), map the request host to these references using the bases of all site languages, and check them in addition to the literal host and*. - Add a small resolver that translates in both directions and use it for the URL output, the permission check and the value picker.
- Keep free-text domains for hosts without a site. Existing records keep matching, so an upgrade wizard is optional. It can only convert hosts that are found in the site configuration (
baseorbaseVariants).
The cache layer and the DataHandler hooks treat
source_hostas an opaque string, so they would not need to change, and no schema change is required.A separate
source_sitecolumn, as suggested in the previous comment, separates the data more cleanly. However, it needs a schema change, an upgrade wizard and its own cache handling, and the URL output has to be adapted either way. That’s why I would prefer the prefix, but I’m happy to discuss this before anyone starts on it. - Languages on their own domains: a site is not the same as a host.
-
Jonas Eberle commented <span data-processor="relativetime" data-value="2026-11-01T11:30:50+00:00" > 11/01/26, 11:30 </span>
Georg, thank you for thinking so thoroughly about it. And thank you immensely for this early feedback!
I absolutely forgot
source_languageto build the actual base URL!Your other points are very valid. It affects many places. Your possible solution sounds sound to me on first glance.
(Additional columns for site and language are just my preference)
I agree, that the current implementation needs to be improved.
In a multitree setup, an editor that should only be able maintain a single “domain”, all sites/domains are listed and the editor could potentially screw up the other sites. Limiting that to the sites that he has access to could prevent that