Blank admin page on Magento 2.3.0 CE in localhost

耗尽温柔 提交于 2019-11-29 07:08:45

This would be a bug that addresses this commit. Author changed $path to

$this->fileDriver->getRealPath($path)

which is simply calling realpath() on $path but that might change directory separators on the $path that previously were affected by

#/vendor/magento/framework/View/Element/Template/File/Validator.php:114
$filename = str_replace('\\', '/', $filename);

On a Windows OS this will revert changes of above str_replace so that a path like

D:/Magento2.3/vendor/magento

will be canonicalized to its Windows specific version:

D:\Magento2.3\vendor\magento

and this will not result in a successful comparison within isPathInDirectories() method of Magento\Framework\View\Element\Template\File\Validator class:

foreach ($directories as $directory) {
    if (0 === strpos($realPath, $directory)) {
        return true;
    }
}

Solution

Currently we can go for a dirty quick change in the above foreach loop so that we can run our magento with no further problems on this:

#/vendor/magento/framework/View/Element/Template/File/Validator.php:139
foreach ($directories as $directory) {
    // Add this line
    $realDirectory = $this->fileDriver->getRealPath($directory);
    // and replace `$directory` with `$realDirectory`
    if (0 === strpos($realPath, $realDirectory)) {
        return true;
    }
}

This is Magento 2.3.0's core issue. To fix this issue you have to change the code in the core file of Magento.

Go to path /vendor/magento/framework/View/Element/Template/File/Validator.php In this file find:

$realPath = $this->fileDriver->getRealPath($path);

Replace with:

$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));

Step 01. Go to this directory C:\xampp\htdocs\magento\vendor\magento\framework\View\Element\Template\File

Step 02. Open file validator.php Comment line 139($realPath = $this->fileDriver->getRealPath($path);) Add this code

$realPath=str_replace('\\','/', $this->fileDriver->getRealPath($path));

And also some time admin page load but not load css So how to fix this issue

Step _01 Goto the this directory App/etc/di.xml

step 02 Find this line

<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>

Step 03 change this like below

<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\copy</item>

And also some time the home page not load correctly so how can solve

Step 01 Go to the this directory var/cache

Step 02 Delete cache files and refresh your page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!