Breaking: #111263 - Removed cache clearing hooks of DataHandler 

See forge#111263

Description 

The cache flushing logic of \TYPO3\CMS\Core\DataHandling\DataHandler has been moved to \TYPO3\CMS\Core\Cache\Flush\CacheFlusher , see Feature: #111263 - Flush caches without DataHandler. The following hooks have been removed in favor of PSR-14 events:

  • $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearPageCacheEval']
  • $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']

The protected methods prepareCacheFlush() and getOriginalParentOfRecord() of DataHandler have been removed. Its constructor receives CacheFlusher and CacheFlushLogger instead of \TYPO3\CMS\Core\Cache\CacheManager and \TYPO3\CMS\Core\Service\OpcodeCacheService .

Flushing the "pages" cache group or all caches in the backend, for example via the cache toolbar or Page TSconfig TCEMAIN.clearCacheCmd , now dispatches \TYPO3\CMS\Core\Cache\Event\CacheFlushEvent , like the cache:flush command. Flushing all caches flushes every cache group, including the default group of caches configured without groups . Caches configured with an empty list of groups, such as the runtime cache, are flushed directly, as before.

Impact 

Hook implementations registered under clearPageCacheEval or clearCachePostProc are no longer executed.

Affected installations 

Installations with extensions registering one of the hooks are affected. The extension scanner reports their usage as a strong match.

Migration 

Implementations of clearPageCacheEval , and implementations of clearCachePostProc that changed the cache tags or commands of a record, become listeners of \TYPO3\CMS\Core\Cache\Event\BeforeRecordRelatedCachesAreFlushedEvent :

EXT:my_extension/Classes/EventListener/FlushNewsListPage.php
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Cache\Event\BeforeRecordRelatedCachesAreFlushedEvent;

final readonly class FlushNewsListPage
{
    #[AsEventListener('my-extension/flush-news-list-page')]
    public function __invoke(BeforeRecordRelatedCachesAreFlushedEvent $event): void
    {
        if ($event->table === 'tx_news_domain_model_news') {
            $event->addPageId(42);
        }
    }
}
Copied!

Implementations that reacted to a cache command or flushed further caches become listeners of \TYPO3\CMS\Core\Cache\Event\BeforeCacheFlushEvent , whose plan holds the requested records and commands and accepts further cache tags and groups. Follow-up work such as purging a reverse proxy belongs into a listener of \TYPO3\CMS\Core\Cache\Event\AfterCacheFlushedEvent .

Implementations that read the data map, command map or history records of the passed DataHandler should use the DataHandler hooks processDatamap_afterAllOperations and processCmdmap_afterFinish instead.