File tree Expand file tree Collapse file tree 10 files changed +26
-38
lines changed
app/code/Magento/AwsS3/Driver
dev/tests/integration/testsuite/Magento/Catalog
lib/internal/Magento/Framework/Api Expand file tree Collapse file tree 10 files changed +26
-38
lines changed Original file line number Diff line number Diff line change @@ -344,7 +344,11 @@ public function isFile($path): bool
344
344
$ path = $ this ->normalizeRelativePath ($ path );
345
345
$ path = rtrim ($ path , '/ ' );
346
346
347
- return $ this ->adapter ->has ($ path ) && $ this ->adapter ->getMetadata ($ path )['type ' ] === self ::TYPE_FILE ;
347
+ if ($ this ->adapter ->has ($ path ) && ($ meta = $ this ->adapter ->getMetadata ($ path ))) {
348
+ return ($ meta ['type ' ] ?? null ) === self ::TYPE_FILE ;
349
+ }
350
+
351
+ return false ;
348
352
}
349
353
350
354
/**
Original file line number Diff line number Diff line change @@ -46,9 +46,10 @@ public static function setUpBeforeClass(): void
46
46
$ mediaDirectory ->create ($ config ->getBaseTmpMediaPath ());
47
47
$ mediaDirectory ->create ($ config ->getBaseMediaPath ());
48
48
49
- copy ($ fixtureDir . "/magento_image.jpg " , self ::$ _mediaTmpDir . "/magento_image.jpg " );
50
- copy ($ fixtureDir . "/magento_image.jpg " , self ::$ _mediaDir . "/magento_image.jpg " );
51
- copy ($ fixtureDir . "/magento_small_image.jpg " , self ::$ _mediaTmpDir . "/magento_small_image.jpg " );
49
+ $ mediaDirectory ->getDriver ()->filePutContents (self ::$ _mediaTmpDir . "/magento_image.jpg " , file_get_contents ($ fixtureDir . "/magento_image.jpg " ));
50
+ $ mediaDirectory ->getDriver ()->filePutContents (self ::$ _mediaDir . "/magento_image.jpg " , file_get_contents ($ fixtureDir . "/magento_image.jpg " ));
51
+ $ mediaDirectory ->getDriver ()->filePutContents (self ::$ _mediaTmpDir . "/magento_small_image.jpg " , file_get_contents ($ fixtureDir . "/magento_small_image.jpg " ));
52
+
52
53
}
53
54
54
55
public static function tearDownAfterClass (): void
Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ protected function _copyFileToBaseTmpMediaPath($sourceFile)
246
246
247
247
$ mediaDirectory ->create ($ config ->getBaseTmpMediaPath ());
248
248
$ targetFile = $ config ->getTmpMediaPath (basename ($ sourceFile ));
249
- copy ( $ sourceFile , $ mediaDirectory ->getAbsolutePath ($ targetFile ));
249
+ $ mediaDirectory -> getDriver ()-> filePutContents ( $ mediaDirectory ->getAbsolutePath ($ targetFile), file_get_contents ( $ sourceFile ));
250
250
251
251
return $ targetFile ;
252
252
}
Original file line number Diff line number Diff line change 10
10
$ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
11
11
12
12
/** @var $mediaDirectory \Magento\Framework\Filesystem\Directory\WriteInterface */
13
- $ mediaDirectory = $ objectManager ->get (\Magento \Framework \Filesystem::class)
14
- ->getDirectoryWrite (DirectoryList::MEDIA );
13
+ $ mediaDirectory = $ objectManager ->get (\Magento \Framework \Filesystem::class)->getDirectoryWrite (DirectoryList::MEDIA );
15
14
$ fileName = 'magento_small_image.jpg ' ;
16
15
$ fileNameLong = 'magento_long_image_name_magento_long_image_name_magento_long_image_name.jpg ' ;
17
16
$ filePath = 'catalog/category/ ' . $ fileName ;
18
17
$ filePathLong = 'catalog/category/ ' . $ fileNameLong ;
19
18
$ mediaDirectory ->create ('catalog/category ' );
20
-
21
- copy (__DIR__ . DIRECTORY_SEPARATOR . $ fileName , $ mediaDirectory ->getAbsolutePath ($ filePath ));
22
- copy (__DIR__ . DIRECTORY_SEPARATOR . $ fileNameLong , $ mediaDirectory ->getAbsolutePath ($ filePathLong ));
19
+ $ shortImageContent = file_get_contents (__DIR__ . DIRECTORY_SEPARATOR . $ fileName );
20
+ $ longImageContent = file_get_contents (__DIR__ . DIRECTORY_SEPARATOR . $ fileNameLong );
21
+ $ mediaDirectory ->getDriver ()->filePutContents ($ mediaDirectory ->getAbsolutePath ($ filePath ), $ shortImageContent );
22
+ $ mediaDirectory ->getDriver ()->filePutContents ($ mediaDirectory ->getAbsolutePath ($ filePathLong ), $ longImageContent );
23
+ unset($ shortImageContent , $ longImageContent );
Original file line number Diff line number Diff line change 15
15
$ fileName = 'magento_small_image.jpg ' ;
16
16
$ tmpFilePath = 'catalog/tmp/category/ ' . $ fileName ;
17
17
$ mediaDirectory ->create ('catalog/tmp/category ' );
18
-
19
- copy (__DIR__ . DIRECTORY_SEPARATOR . $ fileName , $ mediaDirectory ->getAbsolutePath ($ tmpFilePath ));
18
+ $ mediaDirectory ->getDriver ()->filePutContents ($ mediaDirectory ->getAbsolutePath ($ tmpFilePath ), file_get_contents (__DIR__ . DIRECTORY_SEPARATOR . $ fileName ));
Original file line number Diff line number Diff line change 24
24
$ images = ['magento_image.jpg ' , 'magento_small_image.jpg ' , 'magento_thumbnail.jpg ' ];
25
25
26
26
foreach ($ images as $ image ) {
27
- $ targetTmpFilePath = $ mediaDirectory ->getAbsolutePath () . DIRECTORY_SEPARATOR . $ targetTmpDirPath
28
- . DIRECTORY_SEPARATOR . $ image ;
27
+ $ targetTmpFilePath = $ mediaDirectory ->getAbsolutePath () . $ targetTmpDirPath . $ image ;
29
28
30
29
$ sourceFilePath = __DIR__ . DIRECTORY_SEPARATOR . $ image ;
30
+ $ mediaDirectory ->getDriver ()->filePutContents ($ targetTmpFilePath , file_get_contents ($ sourceFilePath ));
31
31
32
- copy ($ sourceFilePath , $ targetTmpFilePath );
33
32
// Copying the image to target dir is not necessary because during product save, it will be moved there from tmp dir
34
33
$ database ->saveFile ($ targetTmpFilePath );
35
34
}
Original file line number Diff line number Diff line change 38
38
$ mediaDirectory ->create ($ targetTmpDirPath );
39
39
40
40
$ dist = $ mediaDirectory ->getAbsolutePath ($ mediaConfig ->getBaseMediaPath () . DIRECTORY_SEPARATOR . 'magento_image.jpg ' );
41
- copy ( __DIR__ . '/magento_image.jpg ' , $ dist );
41
+ $ mediaDirectory -> getDriver ()-> filePutContents ( $ dist , file_get_contents ( __DIR__ . '/magento_image.jpg ' ) );
42
42
43
43
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
44
44
$ productRepository = $ objectManager ->create (\Magento \Catalog \Api \ProductRepositoryInterface::class);
Original file line number Diff line number Diff line change 12
12
/** @var Magento\Catalog\Model\Product\Media\Config $config */
13
13
$ config = $ objectManager ->get (\Magento \Catalog \Model \Product \Media \Config::class);
14
14
15
- /** @var $tmpDirectory \Magento\Framework\Filesystem\Directory\WriteInterface */
16
- $ tmpDirectory = $ filesystem ->getDirectoryWrite (\Magento \Framework \App \Filesystem \DirectoryList::MEDIA );
17
- $ tmpDirectory ->create ($ config ->getBaseTmpMediaPath ());
15
+ /** @var $mediaDirectory \Magento\Framework\Filesystem\Directory\WriteInterface */
16
+ $ mediaDirectory = $ filesystem ->getDirectoryWrite (\Magento \Framework \App \Filesystem \DirectoryList::MEDIA );
17
+ $ mediaDirectory ->create ($ config ->getBaseTmpMediaPath ());
18
18
19
- $ targetTmpFilePath = $ tmpDirectory ->getAbsolutePath ($ config ->getBaseTmpMediaPath () . '/magento_small_image.jpg ' );
20
- copy ( __DIR__ . '/magento_small_image.jpg ' , $ targetTmpFilePath );
19
+ $ targetTmpFilePath = $ mediaDirectory ->getAbsolutePath ($ config ->getBaseTmpMediaPath () . '/magento_small_image.jpg ' );
20
+ $ mediaDirectory -> getDriver ()-> filePutContents ( $ targetTmpFilePath , file_get_contents ( __DIR__ . '/magento_small_image.jpg ' ) );
21
21
// Copying the image to target dir is not necessary because during product save, it will be moved there from tmp dir
Original file line number Diff line number Diff line change 24
24
25
25
$ baseTmpMediaPath = $ config ->getBaseTmpMediaPath ();
26
26
$ mediaDirectory ->create ($ baseTmpMediaPath );
27
- copy ( __DIR__ . '/product_image.png ' , $ mediaDirectory -> getAbsolutePath ( $ baseTmpMediaPath . '/product_image.png ' ));
27
+ $ mediaDirectory -> getDriver ()-> filePutContents ( $ mediaDirectory -> getAbsolutePath ( $ baseTmpMediaPath . '/product_image.png ' ), file_get_contents ( __DIR__ . '/product_image.png ' ));
28
28
29
29
/** @var $productOne \Magento\Catalog\Model\Product */
30
30
$ productOne = $ objectManager ->create (\Magento \Catalog \Model \Product::class);
Original file line number Diff line number Diff line change @@ -39,20 +39,4 @@ public function processFileAttributes($fileAttributes)
39
39
$ this ->_fileExists = true ;
40
40
}
41
41
}
42
-
43
- /**
44
- * Move files from TMP folder into destination folder
45
- *
46
- * @param string $tmpPath
47
- * @param string $destPath
48
- * @return bool|void
49
- */
50
- protected function _moveFile ($ tmpPath , $ destPath )
51
- {
52
- if (is_uploaded_file ($ tmpPath )) {
53
- return move_uploaded_file ($ tmpPath , $ destPath );
54
- } elseif (is_file ($ tmpPath )) {
55
- return rename ($ tmpPath , $ destPath );
56
- }
57
- }
58
42
}
You can’t perform that action at this time.
0 commit comments