Magento-2-server-installation icon indicating copy to clipboard operation
Magento-2-server-installation copied to clipboard

PHP Fatal error: Uncaught TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, bool given in /home/dw/public_html/vendor/magento/framework/Filesystem/DirectoryList.php:137

Open gladroger opened this issue 3 years ago • 2 comments

thrown in /home/dw/public_html/vendor/magento/framework/Filesystem/DirectoryList.php on line 137 [16-Sep-2022 10:38:45 Europe/Stockholm] PHP Fatal error: Uncaught TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, bool given in /home/dw/public_html/vendor/magento/framework/Filesystem/DirectoryList.php:137 Stack trace: #0 /home/dw/public_html/vendor/magento/framework/Filesystem/DirectoryList.php(137): str_replace() #1 /home/dw/public_html/vendor/magento/framework/Filesystem/DirectoryList.php(117): Magento\Framework\Filesystem\DirectoryList->normalizePath() #2 /home/dw/public_html/vendor/magento/framework/App/Filesystem/DirectoryList.php(193): Magento\Framework\Filesystem\DirectoryList->__construct() #3 /home/dw/public_html/vendor/magento/framework/App/Bootstrap.php(172): Magento\Framework\App\Filesystem\DirectoryList->__construct() #4 /home/dw/public_html/vendor/magento/framework/App/Bootstrap.php(139): Magento\Framework\App\Bootstrap::createFilesystemDirectoryList() #5 /home/dw/public_html/app/bootstrap.php(45): Magento\Framework\App\Bootstrap::populateAutoloader() #6 /home/dw/public_html/pub/health_check.php(18): require('...') #7 {main} thrown in /home/dw/public_html/vendor/magento/framework/Filesystem/DirectoryList.php on line 137

Anyone know the workaround to get this working? I found the same issue on magento github https://github.com/magento/magento2/issues/36082 but no response or activity there in 13 days, seems the problem is not that common.

gladroger avatar Sep 16 '22 12:09 gladroger

Temporary fix. vendor/magento/framework/Filesystem/DirectoryList.php on line 137

image

artmouse avatar Sep 16 '22 12:09 artmouse

The problem is related to changing the default path upload_tmp_dir in PHP-FPM setting. ... \Magento\Framework\Filesystem\DirectoryList::__construct ...

        $sysTmpPath = get_cfg_var('upload_tmp_dir') ?: sys_get_temp_dir();
        $this->directories[self::SYS_TMP] = [self::PATH => realpath($sysTmpPath)];

realpath may return false

artmouse avatar Sep 19 '22 19:09 artmouse

make sure you have var/tmp folder

magenx avatar Nov 07 '22 20:11 magenx