Bug #93964

Edit page, modify page slug causes HTTP 404 on old page URL. TYPO3\CMS\Redirects\Service\SlugService::rebuildSlugsForSlugChange must force-rebuild redirects cache.

Added by Leonie Philine Bitto 8 months ago. Updated 2 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Start date:
2021-04-21
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

When editing a page and changing its slug, then saving the page record, then a new redirect is added by \TYPO3\CMS\Redirects\Service\SlugService::createRedirect.

However, the redirects cache is not cleared (\TYPO3\CMS\Redirects\Service\RedirectCacheService::rebuild is not invoked), and the page whose slug was changed (requested via its old URI) consistently throws a HTTP 404 Not Found instead of redirecting to its new URI.

Until:

  • Either the entire 'pages' cache is cleared, in which the redirects are serialized under the 'redirects' key;
  • Or until a sys_redirects record is modified and saved, which invokes \TYPO3\CMS\Redirects\Hooks\DataHandlerCacheFlushingHook::rebuildRedirectCacheIfNecessary.

Saving a page record with modified slug does not invoke \TYPO3\CMS\Redirects\Hooks\DataHandlerCacheFlushingHook::rebuildRedirectCacheIfNecessary, because \TYPO3\CMS\Redirects\Service\SlugService::createRedirect does not use the DataHandler to store the newly added sys_redirect record:
DataHandlerCacheFlushingHook only listens to DataHandler commands involving sys_redirect records being saved. This is not the case here.
Instead, \TYPO3\CMS\Redirects\Service\SlugService::createRedirect inserts the new record via the \TYPO3\CMS\Core\Database\ConnectionPool API.

Solution:

Call \TYPO3\CMS\Redirects\Service\RedirectCacheService::rebuild in \TYPO3\CMS\Redirects\Service\SlugService::rebuildSlugsForSlugChange just before $this->sendNotification();.


Related issues

Related to TYPO3 Core - Feature #89115: Auto-create Redirects on Slug ChangesClosedFrank Naegler2019-09-09

Actions
#1

Updated by Felix Heller 2 months ago

I can confirm that this problem still exists in TYPO3 11.5.0. If a redirect entry is added, edited or deleted in the backend module "Redirects", the redirect cache is cleared, but if a redirect is created because a page's slug was changed, then the redirect cache remains unchanged.

#2

Updated by Felix Heller 2 months ago

  • Related to Feature #89115: Auto-create Redirects on Slug Changes added

Also available in: Atom PDF