Skip to content

Commit

Permalink
[BUGFIX] Inject TYPO3's client into sub-command
Browse files Browse the repository at this point in the history
  • Loading branch information
eliashaeussler committed Oct 10, 2023
1 parent c2b67ab commit 9c084c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Classes/Command/WarmupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Check warning on line 197 in Classes/Command/WarmupCommand.php

View check run for this annotation

Codecov / codecov/patch

Classes/Command/WarmupCommand.php#L195-L197

Added lines #L195 - L197 were not covered by tests
}

$output->writeln('Running <info>cache warmup</info> by <info>Elias Häußler</info> and contributors.');

// Run cache warmup in sub command from eliashaeussler/cache-warmup
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9c084c9

Please sign in to comment.