#93964Edit page, modify page slug causes HTTP 404 on old page URL. TYPO3\CMS\Redirects\Service\SlugService::rebuildSlugsForSlugChange must force-rebuild redirects cache.
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_redirectsrecord 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();.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.