On a fresh install of Drupal using drupal:8.6-apache Docker image, I observed the following behavior:
I get the following error:
TypeError: Argument 1 passed to Drupal\\s3fs\\EventSubscriber\\S3fsAdvAggSubscriber::__construct() must be an instance of Drupal\\s3fs\\Asset\\S3fsCssOptimizer, instance of Drupal\\cdn\\Asset\\CssOptimizer given, called in /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 in /var/www/html/modules/contrib/s3fs/src/EventSubscriber/S3fsAdvAggSubscriber.php on line 29 #0 /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(262): Drupal\\s3fs\\EventSubscriber\\S3fsAdvAggSubscriber->__construct(Object(Drupal\\cdn\\Asset\\CssOptimizer))\n#1 /var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(171): Drupal\\Component\\DependencyInjection\\Container->createService(Array, 's3fs.advagg.css...')\n#2 /var/www/html/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(105): Drupal\\Component\\DependencyInjection\\Container->get('s3fs.advagg.css...')\n#3 /var/www/html/modules/contrib/advagg/src/Asset/CssOptimizer.php(91): Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher->dispatch('advagg.optimize...', Object(Drupal\\advagg\\Asset\\AssetOptimizationEvent))\n#4 /var/www/html/modules/contrib/advagg/src/Asset/AssetOptimizer.php(226): Drupal\\advagg\\Asset\\CssOptimizer->optimizeFile(Array, Array)\n#5 /var/www/html/modules/contrib/advagg/src/Asset/AssetOptimizer.php(145): Drupal\\advagg\\Asset\\AssetOptimizer->scanFile(Array)\n#6 /var/www/html/modules/contrib/advagg/advagg.module(117): Drupal\\advagg\\Asset\\AssetOptimizer->processAssetArray(Array)\n#7 /var/www/html/core/lib/Drupal/Core/Extension/ModuleHandler.php(539): advagg_css_alter(Array, Object(Drupal\\Core\\Asset\\AttachedAssets), NULL)\n#8 /var/www/html/core/lib/Drupal/Core/Asset/AssetResolver.php(159): Drupal\\Core\\Extension\\ModuleHandler->alter('css', Array, Object(Drupal\\Core\\Asset\\AttachedAssets))\n#9 /var/www/html/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(291): Drupal\\Core\\Asset\\AssetResolver->getCssAssets(Object(Drupal\\Core\\Asset\\AttachedAssets), false)\n#10 /var/www/html/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(161): Drupal\\Core\\Render\\HtmlResponseAttachmentsProcessor->processAssetLibraries(Object(Drupal\\Core\\Asset\\AttachedAssets), Array)\n#11 /var/www/html/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php(94): Drupal\\Core\\Render\\HtmlResponseAttachmentsProcessor->processAttachments(Object(Drupal\\Core\\Render\\HtmlResponse))\n#12 /var/www/html/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php(45): Drupal\\big_pipe\\Render\\BigPipeResponseAttachmentsProcessor->processAttachments(Object(Drupal\\Core\\Render\\HtmlResponse))\n#13 [internal function]: Drupal\\Core\\EventSubscriber\\HtmlResponseSubscriber->onRespond(Object(Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent), 'kernel.response', Object(Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher))\n#14 /var/www/html/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent), 'kernel.response', Object(Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher))\n#15 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(191): Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher->dispatch('kernel.response', Object(Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent))\n#16 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(173): Symfony\\Component\\HttpKernel\\HttpKernel->filterResponse(Object(Drupal\\Core\\Render\\HtmlResponse), Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#17 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#18 /var/www/html/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#19 /var/www/html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#20 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#21 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\\page_cache\\StackMiddleware\\PageCache->pass(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#22 /var/www/html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\\page_cache\\StackMiddleware\\PageCache->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#23 /var/www/html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#24 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#25 /var/www/html/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\\StackedHttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#26 /var/www/html/index.php(19): Drupal\\Core\\DrupalKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#27 {main}, referer: http://www.iste.local/admin/reports
When the config $settings['s3fs.use_s3_for_public'] is set to FALSE or not configured or either of advagg and cdn modules are uninstalled, the error is gone.
I needed s3fs, cdn and advagg for my particular use case so I hacked away s3fs' module by the attached patch.
I am not a Drupal developer. I am a SysAdmin with a little bit of PHP knowledge.
Anyone encountered this issue?
Comments
Comment #2
trickfun commentedI have the same error. the patch works fine.
thanks
Comment #5
subhojit777Instead of removing the typehint, I think we should typehint with the main structure.
Comment #7
cmlaraResolved.
The typehint was actually just the tip of the issue here. We also had a further fault of that the CDN decorator does not pass rewriteFileURIBasePath() through.
Since the action we take on the S3fsAdvAggSubscriber is very specif and doesn't depend on other services removed the injection of 'asset.css.optimizer' and replace with injection of 'config.factory' to allow a direct construction of a S3fsCssOptimizer as the only feature we want is the ability to rewrite the URL's for S3.