Closed
Description
In Magento\Framework\Filesystem\Directory::renameFile(), the source directory is used to calculate target path for the file, instead of the destination directory, resulting in wrong target absolute path being calculated and file not moved to target location.
Preconditions
Magento 2.0.7 to 2.1.0, not checked previous versions.
Any PHP or MySQL versions.
Steps to reproduce
Sample code to demonstrate the issue
/** @var \Magento\Framework\Filesystem $this->filesystem */
$filename = 'test.csv';
$srcDir = $this->filesystem->getDirectoryWrite(DirectoryList::TMP);
$srcDir->create();
/** @var \Magento\Framework\Filesystem\Directory\Write $dstDir */
$dstDir = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$dstDir->create('myexport/orders');
$srcDir->renameFile( $filename, 'myexport/orders/' . $filename, $dstDir );
Expected result
File test.csv
should be moved from var/tmp/
folder to var/myexport/orders/
folder, with the same name. This does not happen.
Actual result
File is not moved from source to target directory.
Proposed fix
// In vendor/magento/framework/Filesystem/Directory/Write.php:108
// replace:
$absoluteNewPath = $targetDirectory->driver->getAbsolutePath($this->path, $newPath);
// with:
$absoluteNewPath = $targetDirectory->driver->getAbsolutePath($targetDirectory->path, $newPath);