Deprecation: #111298 - DataHandler->clear_cacheCmd()
See forge#111298
Description
The method
\TYPO3\ has been
deprecated. Cache commands such as "pages", "all", a page id or
"cacheTag:<tag>" are flushed by
\TYPO3\, which needs no
Data instance, see
Feature: #111263 - Flush caches without DataHandler.
Impact
Calling the method triggers a PHP
E_ error. The
extension scanner reports usages.
Affected installations
Installations with extensions calling
Data, usually to flush caches without
processing any data map or command map.
Migration
Flush the cache command with
Cache. Pass a
Cache created from
the backend user to keep checking the permissions of User TSconfig
options.. Without it, the command is flushed
unrestricted, which fits scheduler tasks or console commands.
Before:
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$dataHandler->start([], []);
$dataHandler->clear_cacheCmd('pages');
After:
use TYPO3\CMS\Core\Cache\Flush\CacheFlushDemand;
use TYPO3\CMS\Core\Cache\Flush\CacheFlusher;
use TYPO3\CMS\Core\Cache\Flush\CacheFlushingContext;
public function __construct(
private readonly CacheFlusher $cacheFlusher,
) {}
public function flushPageCaches(): void
{
$this->cacheFlusher->flush(
CacheFlushDemand::forCommand('pages'),
CacheFlushingContext::fromBackendUser($GLOBALS['BE_USER'])
);
}