Skip to content

Commit d6ccfb5

Browse files
committed
MC-38613: Support by Magento CatalogGraphQl
1 parent a583f7a commit d6ccfb5

File tree

10 files changed

+26
-38
lines changed

10 files changed

+26
-38
lines changed

app/code/Magento/AwsS3/Driver/AwsS3.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,11 @@ public function isFile($path): bool
344344
$path = $this->normalizeRelativePath($path);
345345
$path = rtrim($path, '/');
346346

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;
348352
}
349353

350354
/**

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ProcessorTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ public static function setUpBeforeClass(): void
4646
$mediaDirectory->create($config->getBaseTmpMediaPath());
4747
$mediaDirectory->create($config->getBaseMediaPath());
4848

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+
5253
}
5354

5455
public static function tearDownAfterClass(): void

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ protected function _copyFileToBaseTmpMediaPath($sourceFile)
246246

247247
$mediaDirectory->create($config->getBaseTmpMediaPath());
248248
$targetFile = $config->getTmpMediaPath(basename($sourceFile));
249-
copy($sourceFile, $mediaDirectory->getAbsolutePath($targetFile));
249+
$mediaDirectory->getDriver()->filePutContents($mediaDirectory->getAbsolutePath($targetFile), file_get_contents($sourceFile));
250250

251251
return $targetFile;
252252
}

dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_image.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
1111

1212
/** @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);
1514
$fileName = 'magento_small_image.jpg';
1615
$fileNameLong = 'magento_long_image_name_magento_long_image_name_magento_long_image_name.jpg';
1716
$filePath = 'catalog/category/' . $fileName;
1817
$filePathLong = 'catalog/category/' . $fileNameLong;
1918
$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);

dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_tmp_category_image.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@
1515
$fileName = 'magento_small_image.jpg';
1616
$tmpFilePath = 'catalog/tmp/category/' . $fileName;
1717
$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));

dev/tests/integration/testsuite/Magento/Catalog/_files/product_image.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
$images = ['magento_image.jpg', 'magento_small_image.jpg', 'magento_thumbnail.jpg'];
2525

2626
foreach ($images as $image) {
27-
$targetTmpFilePath = $mediaDirectory->getAbsolutePath() . DIRECTORY_SEPARATOR . $targetTmpDirPath
28-
. DIRECTORY_SEPARATOR . $image;
27+
$targetTmpFilePath = $mediaDirectory->getAbsolutePath() . $targetTmpDirPath . $image;
2928

3029
$sourceFilePath = __DIR__ . DIRECTORY_SEPARATOR . $image;
30+
$mediaDirectory->getDriver()->filePutContents($targetTmpFilePath, file_get_contents($sourceFilePath));
3131

32-
copy($sourceFilePath, $targetTmpFilePath);
3332
// Copying the image to target dir is not necessary because during product save, it will be moved there from tmp dir
3433
$database->saveFile($targetTmpFilePath);
3534
}

dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_image.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
$mediaDirectory->create($targetTmpDirPath);
3939

4040
$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'));
4242

4343
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
4444
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);

dev/tests/integration/testsuite/Magento/Catalog/_files/validate_image_info.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
/** @var Magento\Catalog\Model\Product\Media\Config $config */
1313
$config = $objectManager->get(\Magento\Catalog\Model\Product\Media\Config::class);
1414

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());
1818

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'));
2121
// Copying the image to target dir is not necessary because during product save, it will be moved there from tmp dir

dev/tests/integration/testsuite/Magento/Catalog/controllers/_files/products.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
$baseTmpMediaPath = $config->getBaseTmpMediaPath();
2626
$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'));
2828

2929
/** @var $productOne \Magento\Catalog\Model\Product */
3030
$productOne = $objectManager->create(\Magento\Catalog\Model\Product::class);

lib/internal/Magento/Framework/Api/Uploader.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,4 @@ public function processFileAttributes($fileAttributes)
3939
$this->_fileExists = true;
4040
}
4141
}
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-
}
5842
}

0 commit comments

Comments
 (0)