Skip to content

Commit d553c3c

Browse files
authored
Merge pull request #358 from magento-performance/MC-38613
2 parents a583f7a + d38d057 commit d553c3c

File tree

14 files changed

+30
-41
lines changed

14 files changed

+30
-41
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
/**

app/code/Magento/Eav/Model/AttributeRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function save(\Magento\Eav\Api\Data\AttributeInterface $attribute)
8888
try {
8989
$this->eavResource->save($attribute);
9090
} catch (\Exception $e) {
91-
throw new StateException(__("The attribute can't be saved."));
91+
throw new StateException(__("The attribute can't be saved."), $e);
9292
}
9393
return $attribute;
9494
}

app/code/Magento/Swatches/Helper/Media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ protected function getUniqueFileName($file)
197197
$file
198198
);
199199
} else {
200-
$destFile = dirname($file) . '/' . \Magento\MediaStorage\Model\File\Uploader::getNewFileName(
200+
$destFile = rtrim(dirname($file), '/.') . '/' . \Magento\MediaStorage\Model\File\Uploader::getNewFileName(
201201
$this->getOriginalFilePath($file)
202202
);
203203
}

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

0 commit comments

Comments
 (0)