当我从后端管理面板上传产品图像时,我收到了这个错误。
Warrning: Invalid argument supplied for foreach() in /Applications/AMPPS/www/magento/app/code/core/Mage/Core/Model/File/Validator/NotProtectedExtension.php on line 91
经过一点调试,我明白
$extensions = $helper->getProtectedFileExtensions()
返回null,因此返回foreach错误。
我最近没有上传任何图片,所以我不知道是什么特殊的变化引发了这种情况。
在调试错误时浪费了一天时间,解决了问题
我可能把设置脚本搞砸了,它在core_config_data表中插入了以下行
path => 'general', value => NULL
这导致"general"的配置树指向NULL,从而导致密钥
'general/file/protected_extensions'
永远都不会下降。由于数据库值是在稍后从xml文件获取配置值后填充和添加的,所以上面的行删除了以路径general
检查您是否有这个:
<protected_extensions>
<!-- PHP script file extension -->
<php>php</php>
<!-- File extension of configuration of an Apache Web server -->
<htaccess>htaccess</htaccess>
<!-- Java script file extension -->
<jsp>jsp</jsp>
<!-- Perl script file extension -->
<pl>pl</pl>
<!-- Python script file extension -->
<py>py</py>
<!-- Active Server Page script file extension -->
<asp>asp</asp>
<!-- UNIX command prompt file extension -->
<sh>sh</sh>
<!-- Common Gateway Interface script extension type -->
<cgi>cgi</cgi>
<!-- BOF HTML file extensions -->
<htm>htm</htm>
<html>html</html>
<phtml>phtml</phtml>
<shtml>shtml</shtml>
<!-- EOF HTML file extensions -->
</protected_extensions>
在app'code'Core'Magento'Core'etc'config.xml
中(Magento 1.7.0.1中的377-400行)
如果没有,那么您已经编辑了一个核心文件,这不是一个好主意。如果存在,请检查您的数据库,core_config_table,path='general/file/protected_extensions'。不应该有任何东西
最后,检查其他模块(社区和本地)的config.xml中是否为该参数设置了默认值,例如:
<config>
....
<default>
....
<general>
<file>
<protected_extensions>
....
</protected_extensions>
</file>
</general>
</default>
....
</config>