部分M2(含最新2.4.5)版本在结账时会出现无法提交情况,并报错,报错信息如下
Internal Error. Details are available in Magento log file. Report ID: webapi-630cbf9ccaff1
查询具体的日志表现为
[2022-08-29T13:30:19.056049+00:00] main.CRITICAL: Zend_Validate_Exception: Validate class not found from basename 'Magento\Framework\Validator\EmailAddress' in /www/wwwroot/magento2-2.4.5/vendor/magento/zendframework1/library/Zend/Validate.php:244
如何解决?
打开文件
vendor/magento/zendframework1/library/Zend/Loader.php
修改
public static function isReadable($filename) { if (is_readable($filename)) { // Return early if the filename is readable without needing the // include_path return true; } if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' && preg_match('/^[a-z]:/i', $filename) ) { // If on windows, and path provided is clearly an absolute path, // return false immediately return false; } foreach (self::explodeIncludePath() as $path) { if ($path == '.') { if (is_readable($filename)) { return true; } continue; } $file = $path . '/' . $filename; if (is_readable($file)) { return true; } } return false; }
到
public static function isReadable($filename) { if (is_readable($filename)) { // Return early if the filename is readable without needing the // include_path return true; } if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' && preg_match('/^[a-z]:/i', $filename) ) { // If on windows, and path provided is clearly an absolute path, // return false immediately return false; } foreach (self::explodeIncludePath() as $path) { if ($path == '.') { if (self::is_readable2($filename)) { return true; } continue; } $file = $path . '/' . $filename; if (self::is_readable2($file)) { return true; } } return false; } private static function is_readable2($filename) { try { return is_readable($filename); } catch (Exception $ex) { return false; } }