Bug #88939
closedCustom CacheAction cannot send success state and custom flash messages
100%
Description
Content:
Add a cacheAction via $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions']. Everything is fine and the cache icon is displayed in the topbar. Sending a JsonResponse via interface:
/**
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
public function flush(ServerRequestInterface $request): ResponseInterface
{
return new JsonResponse(['success' => true]);
}
We get a red FlashMessage with the hardcoded "An error occurred while clearing the cache. It is likely not all caches were cleared as expected." text.
The message is thrown from https://github.com/TYPO3/TYPO3.CMS/blob/master/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/Toolbar/ClearCacheMenu.ts#L72 because we have a response. It does not matter what is inside, as you can see.
Solution:
We need a proper solution for this typescript case. Luckily we have a similar solution here: https://github.com/TYPO3/TYPO3.CMS/blob/master/Build/Sources/TypeScript/recordlist/Resources/Public/TypeScript/ClearCache.ts#L67
Files