setDescription('Warmup TYPO3 caches.'); $this->setHelp( <<<'EOF' This command is useful for deployments to warmup caches during release preparation. Cache warming does not work if the PHP version used to execute the command differs from the PHP version used in the web context. See: https://docs.typo3.org/permalink/changelog:important-107649-1760090777 EOF ); $this->setDefinition([ new InputOption('group', 'g', InputOption::VALUE_OPTIONAL, 'The cache group to warmup (system, pages, di or all)', 'all'), ]); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output): int { $group = $input->getOption('group') ?? 'all'; if ($group === 'di' || $group === 'system' || $group === 'all') { $this->containerBuilder->warmupCache($this->packageManager, $this->dependencyInjectionCache); if ($group === 'di') { return Command::SUCCESS; } } $container = $this->bootService->getContainer(); $allowExtFileCaches = true; if ($group === 'system' || $group === 'all') { $allowExtFileCaches = false; $container->get(ExtLocalconfFactory::class)->createCacheEntry(); } // Perform a full boot to load localconf (requirement for extensions and for TCA loading). $this->bootService->loadExtLocalconfDatabase(false, $allowExtFileCaches); if ($group === 'system' || $group === 'all') { $tcaFactory = $container->get(TcaFactory::class); $tcaFactory->createBaseTcaCacheFile($GLOBALS['TCA']); } $eventDispatcher = $container->get(EventDispatcherInterface::class); $groups = $group === 'all' ? $container->get(CacheManager::class)->getCacheGroups() : [$group]; $event = new CacheWarmupEvent($groups); $eventDispatcher->dispatch($event); if (count($event->getErrors()) > 0) { return Command::FAILURE; } return Command::SUCCESS; } }