From 9c084c98a62318a460e7d4c8d7221a61495ade62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20H=C3=A4u=C3=9Fler?= Date: Tue, 10 Oct 2023 13:54:36 +0200 Subject: [PATCH] [BUGFIX] Inject TYPO3's client into sub-command --- Classes/Command/WarmupCommand.php | 8 ++++++++ composer.json | 1 + 2 files changed, 9 insertions(+) diff --git a/Classes/Command/WarmupCommand.php b/Classes/Command/WarmupCommand.php index 2bed7be3..38419828 100644 --- a/Classes/Command/WarmupCommand.php +++ b/Classes/Command/WarmupCommand.php @@ -29,6 +29,7 @@ use EliasHaeussler\Typo3Warming\Exception\UnsupportedSiteException; use EliasHaeussler\Typo3Warming\Service\CacheWarmupService; use EliasHaeussler\Typo3Warming\Sitemap\SitemapLocator; +use Psr\Http\Client\ClientInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; @@ -37,6 +38,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use TYPO3\CMS\Core\Exception\SiteNotFoundException; +use TYPO3\CMS\Core\Http\Client\GuzzleClientFactory; use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -189,6 +191,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $subCommandInput = $this->initializeSubCommandInput($subCommand, $input); $subCommandInput->setInteractive(false); + // Inject client + $client = GuzzleClientFactory::getClient(); + if ($client instanceof ClientInterface) { + $subCommand->setClient($client); + } + $output->writeln('Running cache warmup by Elias Häußler and contributors.'); // Run cache warmup in sub command from eliashaeussler/cache-warmup diff --git a/composer.json b/composer.json index 9faa3a96..40568c80 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "eliashaeussler/cache-warmup": ">= 0.5.0. < 1.0.0", "guzzlehttp/guzzle": "^6.3 || ^7.0", "guzzlehttp/psr7": "^1.4 || ^2.0", + "psr/http-client": "^1.0", "psr/http-message": "^1.0", "psr/log": "^1.0", "symfony/console": "^4.4 || ^5.4 || ^6.0",