magento-engcom / import-export-improvements

Open Software License 3.0
31 stars 29 forks source link

Tablerate import fails when upload_tmp_dir is not related to sys_temp_dir #74

Closed piotrekkaminski closed 6 years ago

piotrekkaminski commented 6 years ago

From @jean-bernard-valentaten on December 28, 2017 10:34

Importing tablerates via backend fails with an error message like 'The file "/tmp/var/www/dist/var/upload/phpi1qs6p" doesn't exist' when PHP setting upload_tmp_dir is set to anything that does not relate to setting sys_temp_dir. This is due to the first line of the private method \Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::getCsvFile() in which a directory reader for DirectoryList::SYS_TMP is requsted.

Preconditions

  1. Magento 2.1.11 is installed
  2. PHP 7.0 FPM is used
  3. Nginx is used
  4. PHP setting upload_tmp_dir is set to a folder that does not relate to the folder defined by sys_temp_dir

Steps to reproduce

  1. In php.ini set upload_tmp_dir to an existing folder, e.g. /var/php/upload
  2. Leave PHP setting sys_temp_dir unconfigured such that PHP defaults it, e.g. /tmp
  3. In Backend navigate to Stores > Configuration > Sales > Shipping Methods
  4. Select any website as scope
  5. Open panel Table Rates
  6. On field Import select a file to upload
  7. Click on Save Config to trigger import

Expected result

  1. The tablerates should be imported

Actual result

  1. An error message pops up, stating something like 'The file "/tmp/var/php/upload/phpi1qs6p" doesn't exist'

When looking at \Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::getCsvFile() you'll notice the first line stating

$tmpDirectory = $this->filesystem->getDirectoryRead(DirectoryList::SYS_TMP);

This results in the sys_temp_dir being prepended to the actual file path when executing the line

return $tmpDirectory->openFile($path);

Copied from original issue: magento/magento2#12904

piotrekkaminski commented 6 years ago

From @dmanners on January 3, 2018 8:54

This has been fixed in 2.3-develop with the pull request https://github.com/magento/magento2/pull/12376

dmanners commented 6 years ago

This is already fixing in 2.3-develop.

jean-bernard-valentaten commented 6 years ago

Is this going to be backported to 2.1?