升级Shopware 6.4.8.2至6.4.13.0后出现ImageCmsElementResolver参数不足错误
Shopware 6.4.8.2 升级至6.4.13.0 后 ArgumentCountError 解决方法
出现的错误信息:
In ImageCmsElementResolver.php line 26: [ArgumentCountError] Too few arguments to function Shopware\Core\Content\Media\Cms\ImageCmsElementResolver::__construct(), 0 passed in /home/xxxx/yyyyy/var/cache/dev_h444cf98b71a1ac0a254d0a81916b032e/ContainerG5HDhmp/Shopware_Production_Kernel DevDebugContainer.php on line 6664 and exactly 1 expected
问题原因
Shopware 6.4.13.0 版本对ImageCmsElementResolver类的构造函数新增了依赖参数,但旧缓存的容器实例化逻辑未同步更新,导致实例化时未传入所需参数。
解决步骤
- 清理缓存:
执行命令清除旧缓存文件:
生产环境需指定环境参数:bin/console cache:clearbin/console cache:clear --env=prod - 预热缓存:
重新生成适配新版本的容器缓存:bin/console cache:warmup - 检查自定义扩展:
若你有自定义重写或继承ImageCmsElementResolver的代码,需同步更新构造函数,确保注入MediaUrlGeneratorInterface参数,与Shopware新版本的类定义保持一致。 - 确认依赖完整性:
执行composer install,确保所有依赖包都正确升级到对应版本,避免旧文件残留。
内容的提问来源于stack exchange,提问作者Marc Cheng
相关产品推荐
相关产品推荐

