首页 > 解决方案 > 在自定义模块 Magento2.4.0 中出现奇怪的错误

问题描述

我在 Magento 2.4.0 中安装了一个自定义模块,但是当我尝试从后端访问它时,我遇到了奇怪的错误。

1 exception(s):
Exception #0 (InvalidArgumentException): Either remote URL or hashable content is required to whitelist

标签: magentomagento2

解决方案


这是由于试图将资产标签呈现给没有 url 或哈希的页面造成的。

如果你多读一点堆栈跟踪,你应该知道问题出在哪里。

在我们的例子中,我们Ebizmarts_Mailchimp安装了模块。这是一个例外:

1 exception(s):
Exception #0 (InvalidArgumentException): Either remote URL or hashable content is required to whitelist

Exception #0 (InvalidArgumentException): Either remote URL or hashable content is required to whitelist
<pre>#1 Magento\Csp\Helper\InlineUtil\Proxy->processTag() called at [vendor/magento/framework/View/Helper/SecureHtmlRenderer.php:67]
#2 Magento\Framework\View\Helper\SecureHtmlRenderer->renderTag() called at [vendor/mailchimp/mc-magento2/view/frontend/templates/mailchimpjs.phtml:8]
#3 include() called at [vendor/magento/framework/View/TemplateEngine/Php.php:71]
#4 Magento\Framework\View\TemplateEngine\Php->render() called at [vendor/magento/framework/View/Element/Template.php:273]
#5 Magento\Framework\View\Element\Template->fetchView() called at [vendor/magento/framework/View/Element/Template.php:303]
#6 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1111]
...

注意vendor/mailchimp/mc-magento2/view/frontend/templates/mailchimpjs.phtml:8at 行#2

我们的解决方法是应用这个补丁

如果你安装了cweagans/composer-patches,你可以把它添加到你的composer.json

"extra": {
    "patches": {
        "mailchimp/mc-magento2":{
            "Either remote URL or hashable content is required to whitelist": "https://raw.githubusercontent.com/zero1limited/magento2-patches/eb137aaaf90ffa86add6566116d08723b1acfc26/patches/Ebizmarts_Mailchimp_mailchimpjs.patch"
        }
    }
}

然后运行composer install --no-dev并刷新缓存。


推荐阅读