Commit ebbde86c authored by Stefan Bürk's avatar Stefan Bürk Committed by Benni Mack
Browse files

[BUGFIX] Create auto-redirects with default language page uid

Creating auto redirects, if page slug is changed, has been extended
to add the target with LinkHandler 't3://' uri schema with #89327,
adding language argument '_language' to enforce the language for the
redirect, missing that that did not worked, which was solved through
adding '_language' argument handling in #96043.

As languge arguments '_language' and 'L' are ignored, if the provided
page uid is already the uid of the localized page, the parameter was
meaning less. Further this breaks language fallback handling, if the
localized page record is deleted.

This patch uses now the default language page uid for creating target
of auto-redirects to mitigate the issue that redirect will break if
localized page is deleted but language fallback is configured.

Resolves: #96103
Related: #96043
Related: #89327
Releases: master, 11.5, 10.4
Change-Id: I2ece06bf053bda4edb542910c3f51b1e6c8e052c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72327

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent b105ec00
......@@ -122,7 +122,7 @@ class SlugService implements LoggerAwareInterface
if ($this->autoUpdateSlugs || $this->autoCreateRedirects) {
$this->createCorrelationIds($pageId, $correlationId);
if ($this->autoCreateRedirects) {
$this->createRedirect($currentSlug, (int)$currentPageRecord['uid'], (int)$currentPageRecord['sys_language_uid'], (int)$pageId);
$this->createRedirect($currentSlug, $defaultPageId, (int)$currentPageRecord['sys_language_uid'], (int)$pageId);
}
if ($this->autoUpdateSlugs) {
$this->checkSubPages($currentPageRecord, $currentSlug, $newSlug);
......@@ -207,7 +207,8 @@ class SlugService implements LoggerAwareInterface
foreach ($subPageRecords as $subPageRecord) {
$newSlug = $this->updateSlug($subPageRecord, $oldSlugOfParentPage, $newSlugOfParentPage);
if ($newSlug !== null && $this->autoCreateRedirects) {
$this->createRedirect($subPageRecord['slug'], (int)$subPageRecord['uid'], $languageUid, $pageId);
$subPageId = (int)$subPageRecord['sys_language_uid'] === 0 ? (int)$subPageRecord['uid'] : (int)$subPageRecord['l10n_parent'];
$this->createRedirect($subPageRecord['slug'], $subPageId, $languageUid, $pageId);
}
}
}
......
......@@ -259,8 +259,8 @@ class SlugServiceTest extends FunctionalTestCase
// This redirects should exists, after rebuildSlugsForSlugChange() has run
$redirects = [
['source_host' => 'de.example.com', 'source_path' => '/dummy-1-3', 'target' => 't3://page?uid=31&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/dummy-1-3/dummy-1-3-8', 'target' => 't3://page?uid=32&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/dummy-1-3', 'target' => 't3://page?uid=3&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/dummy-1-3/dummy-1-3-8', 'target' => 't3://page?uid=8&_language=1'],
];
$this->assertSlugsAndRedirectsExists($slugs, $redirects);
......@@ -298,8 +298,8 @@ class SlugServiceTest extends FunctionalTestCase
// This redirects should exists, after rebuildSlugsForSlugChange() has run
$redirects = [
['source_host' => 'de.example.com', 'source_path' => '/sub-folder/dummy-1-3', 'target' => 't3://page?uid=31&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/sub-folder/dummy-1-3/dummy-1-3-8', 'target' => 't3://page?uid=32&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/sub-folder/dummy-1-3', 'target' => 't3://page?uid=3&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/sub-folder/dummy-1-3/dummy-1-3-8', 'target' => 't3://page?uid=8&_language=1'],
];
$this->assertSlugsAndRedirectsExists($slugs, $redirects);
......@@ -373,10 +373,10 @@ class SlugServiceTest extends FunctionalTestCase
// This redirects should exists, after rebuildSlugsForSlugChange() has run
$redirects = [
['source_host' => 'de.example.com', 'source_path' => '/', 'target' => 't3://page?uid=5&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/dummy-1-2', 'target' => 't3://page?uid=6&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/dummy-1-3', 'target' => 't3://page?uid=7&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/dummy-1-2/dummy-1-2-3', 'target' => 't3://page?uid=8&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/', 'target' => 't3://page?uid=1&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/dummy-1-2', 'target' => 't3://page?uid=2&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/dummy-1-3', 'target' => 't3://page?uid=3&_language=1'],
['source_host' => 'de.example.com', 'source_path' => '/dummy-1-2/dummy-1-2-3', 'target' => 't3://page?uid=4&_language=1'],
];
$this->assertSlugsAndRedirectsExists($slugs, $redirects);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment