Closed
Description
Let's first define some classes here that I am going to mention a lot in the description.
use Magento\Framework\Filesystem\Io\IoInterface;
use Magento\Framework\Filesystem\Io\Sftp;
use Magento\Framework\Filesystem\Io\File;
I am using Sftp
class in order to download some files from a remote server. In my class, I depend on IoInterface
and resolve the dependency in di.xml
. In my test, I would like to use File
implementation, because I have more control over the local file system then the remote SFTP server.
In the method definition of IoInterface
, it says that the second argument can be a resource.
If I give the second argument as a resource it works just fine in the Sftp
implementation. However, the File
implementation uses copy
function of PHP, and it expects the second argument to be a string only.
Preconditions (*)
- Magento 2.4-develop
- PHP 7.4
Steps to reproduce (*)
- Try to run the following code block in a fresh magento installation.
$file = \Magento\Framework\App\ObjectManager::getInstance(\Magento\Framework\Filesystem\Io\File::class);
file_put_contents('/tmp/sample_file', 'Some test file');
$targetHandle = fopen('/tmp/' . rand(), 'w');
$file->cd('/tmp');
$result = $file->read('sample_file', $targetHandle);
var_dump($result);
Expected result (*)
- I expect the file to be copied to the target path.
Actual result (*)
- Unfortunately, it gives an error because the copy function requires the second argument to be string.
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.4-develop branchGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentA defect with this priority could have functionality issues which are not to expectations.Indicates original Magento version for the Issue report.The issue has been reproduced on latest 2.4-develop branchAffects non-critical data or functionality and does not force users to employ a workaround.Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Type
Projects
Status
Done