magento 2.4 windows平台需要修改代码记录

31 篇文章 3 订阅
20 篇文章 0 订阅

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 下。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值