Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

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

Closed
@piotrekkaminski

Description

@piotrekkaminski

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions