Leuchtfeuer / typo3-aws-tools

This extension connects your TYPO3 instance to Amazon CloudFront. It rewrites all file paths in the frontend to match your CDN domain. You also have the possibility to invalidate Amazon CloudFront entries.
https://www.Leuchtfeuer.com
GNU General Public License v2.0
2 stars 5 forks source link

TYPO3 11 - Invalidate via a CLI - Error #5

Open TWT-MW opened 2 years ago

TWT-MW commented 2 years ago

I've noticed the "Symfony Command (CLI Only)" doesn't work as documented in the documentation: Amazon CloudFront entries can be invalidated via a CLI call. The command expects one or more paths (to files or folders).

Tested with Branch: TYPO3-11 Commit: 0c1800fe3938674c383bb3278039a0b841288473 Used TYPO3 Version: 11.5.16

Doc: vendor/bin/typo3cms aws:cf:invalidate PATH_1 PATH_2 [...] PATH_X

CLI: [user@server typo3]$ vendor/bin/typo3cms aws:cf:invalidate public/typo3conf/ext/ext-templates/Resources/Public/Css/*

ERROR: [ ArgumentCountError ] Too few arguments to function Leuchtfeuer\AwsTools\Domain\Repository\CloudFrontRepository::__construct(), 0 passed in /var/www/vhosts/dev.domain.de/typo3/public/typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 3220 and exactly 1 expected

TRACE:

#0 ()
   typo3conf/ext/aws_tools/Classes/Domain/Repository/CloudFrontRepository.php:20
#1 Leuchtfeuer\AwsTools\Domain\Repository\CloudFrontRepository->__construct()
   typo3/sysext/core/Classes/Utility/GeneralUtility.php:3220
#2 TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance()
   typo3conf/ext/aws_tools/Classes/Command/InvalidationCommand.php:41
#3 Leuchtfeuer\AwsTools\Command\InvalidationCommand->initialize()
   vendor/symfony/console/Command/Command.php:264
#4 Symfony\Component\Console\Command\Command->run()
   vendor/symfony/console/Application.php:1028
#5 Symfony\Component\Console\Application->doRunCommand()
   vendor/helhum/typo3-console/Classes/Console/Mvc/Cli/Symfony/Application.php:189
#6 Helhum\Typo3Console\Mvc\Cli\Symfony\Application->doRunCommand()
   vendor/symfony/console/Application.php:299
#7 Symfony\Component\Console\Application->doRun()
   vendor/symfony/console/Application.php:171
#8 Symfony\Component\Console\Application->run()
   vendor/helhum/typo3-console/Classes/Console/Core/Kernel.php:114
#9 Helhum\Typo3Console\Core\Kernel->handle()
   vendor/helhum/typo3-console/Scripts/typo3-console.php:18
#10 {closure}()
   vendor/helhum/typo3-console/Scripts/typo3-console.php:20
#11 require()
   vendor/helhum/typo3-console/typo3cms:3
#12 include()
   vendor/bin/typo3cms:117

Suggested Change:

diff --git a/app/public/typo3conf/ext/aws_tools/Classes/Command/InvalidationCommand.php b/app/public/typo3conf/ext/aws_tools/Classes/Command/InvalidationCommand.php
--- a/Classes/Command/InvalidationCommand.php
+++ b/Classes/Command/InvalidationCommand.php   (date 1666942303703)
@@ -38,7 +38,8 @@
     protected function initialize(InputInterface $input, OutputInterface $output): void
     {
         $this->io = new SymfonyStyle($input, $output);
-        $this->cloudFrontRepository = GeneralUtility::makeInstance(CloudFrontRepository::class);
+        $cloudFrontClient = \Leuchtfeuer\AwsTools\Factory\CloudFrontFactory::getClient();
+        $this->cloudFrontRepository = GeneralUtility::makeInstance(CloudFrontRepository::class, $cloudFrontClient);
         $this->distributions = GeneralUtility::makeInstance(ExtensionConfiguration::class)->getCloudFrontDistributions();
     }

Best regards

akmatthies commented 2 years ago

In general the question: Is an update of the extension for TYPO3 v11 to be expected?