1、vendor\magento\framework\View\Element\Template\File\Validator.php
提示错误:
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'C:/www/magento/vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml' in module: '' block's name: 'require.js'
修改代码:
protected function isPathInDirectories($path, $directories)
{
if (!is_array($directories)) {
$directories = (array)$directories;
}
//$realPath = $this->fileDriver->getRealPath($path);
$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
foreach ($directories as $directory) {
if (0 === strpos($realPath, $directory)) {
return true;
}
}
return false;
}
2、vendor\magento\framework\Image\Adapter\Gd2.php
提示错误:
In PatchApplier.php line 170:
Unable to apply data patch Magento\Theme\Setup\Patch\Data\RegisterThemes for module Magento_Theme. Original exception message: Wrong file
In Gd2.php line 64:
Wrong file
修改代码:
private function validateURLScheme(string $filename) : bool
{
$allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
$url = parse_url($filename);
//if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes)) {
if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) {
return false;
}
return true;
}
3、vendor\magento\framework\Interception\PluginListGenerator.php
错误提示:
In ErrorHandler.php line 61:
Warning: file_put_contents(C:/www/magento/generated/metadata/primary|global|plugin-list.php): failed to open stream: No such file or directory in C:\www\magento\lib\internal\Magento\Framework\Interception\PluginListGene
rator.php on line 414
修改代码:
public function write(array $scopes): void
{
foreach ($scopes as $scope) {
$this->scopeConfig->setCurrentScope($scope);
if (false === isset($this->loadedScopes[$scope])) {
if (false === in_array($scope, $this->scopePriorityScheme, true)) {
$this->scopePriorityScheme[] = $scope;
}
//$cacheId = implode('|', $this->scopePriorityScheme) . "|" . $this->cacheId;
$cacheId = implode('-', $this->scopePriorityScheme) . "-" . $this->cacheId;
....
注意:源码方式的文件在lib\internal\Magento 下。