Bug #93964
closedEdit page, modify page slug causes HTTP 404 on old page URL. TYPO3\CMS\Redirects\Service\SlugService::rebuildSlugsForSlugChange must force-rebuild redirects cache.
0%
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();
.
Updated by Felix Heller about 3 years 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.
Updated by Felix Heller about 3 years ago
- Related to Feature #89115: Auto-create Redirects on Slug Changes added
Updated by Helmut Hummel almost 3 years ago
- Has duplicate Bug #94808: Clear Cache when creating new redirect after slug change added
Updated by Helmut Hummel almost 3 years ago
- Status changed from New to Closed
Solved in the duplicate