diff --git a/app/code/Magento/Analytics/etc/config.xml b/app/code/Magento/Analytics/etc/config.xml
index 27d608ab46039..d3066e186b25a 100644
--- a/app/code/Magento/Analytics/etc/config.xml
+++ b/app/code/Magento/Analytics/etc/config.xml
@@ -23,5 +23,12 @@
+
+
+
+ analytics
+
+
+
diff --git a/app/code/Magento/AwsS3/Driver/AwsS3.php b/app/code/Magento/AwsS3/Driver/AwsS3.php
index 4f753210ca0f6..6b3da8c848fb7 100644
--- a/app/code/Magento/AwsS3/Driver/AwsS3.php
+++ b/app/code/Magento/AwsS3/Driver/AwsS3.php
@@ -304,6 +304,7 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
* Resolves relative path.
*
* @param string $path Absolute path
+ * @param bool $fixPath
* @return string Relative path
*/
private function normalizeRelativePath(string $path, bool $fixPath = false): string
@@ -358,7 +359,7 @@ public function isFile($path): bool
return false;
}
- $path = $this->normalizeRelativePath($path, true);;
+ $path = $this->normalizeRelativePath($path, true);
if ($this->adapter->has($path) && ($meta = $this->adapter->getMetadata($path))) {
return ($meta['type'] ?? null) === self::TYPE_FILE;
diff --git a/app/code/Magento/AwsS3/Driver/AwsS3Factory.php b/app/code/Magento/AwsS3/Driver/AwsS3Factory.php
index 581c1c276c7e1..a4d3676bffa07 100644
--- a/app/code/Magento/AwsS3/Driver/AwsS3Factory.php
+++ b/app/code/Magento/AwsS3/Driver/AwsS3Factory.php
@@ -86,6 +86,10 @@ public function createConfigured(
throw new DriverException(__('Bucket and region are required values'));
}
+ if (!empty($config['http_handler'])) {
+ $config['http_handler'] = $this->objectManager->create($config['http_handler'])($config);
+ }
+
$client = new S3Client($config);
$adapter = new AwsS3Adapter($client, $config['bucket'], $prefix);
diff --git a/app/code/Magento/AwsS3/Model/HttpLoggerHandler.php b/app/code/Magento/AwsS3/Model/HttpLoggerHandler.php
new file mode 100644
index 0000000000000..9971a81f155d4
--- /dev/null
+++ b/app/code/Magento/AwsS3/Model/HttpLoggerHandler.php
@@ -0,0 +1,61 @@
+directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
+ $this->file = $file;
+ }
+
+ public function __invoke()
+ {
+ $this->directory->create(pathinfo($this->file, PATHINFO_DIRNAME));
+ $localStream = $this->directory->getDriver()->fileOpen($this->directory->getAbsolutePath($this->file), 'a');
+ $streamHandler = new StreamHandler($localStream, Logger::DEBUG, true, null, true);
+ $logger = new \Monolog\Logger('S3', [$streamHandler]);
+ $stack = HandlerStack::create();
+ $stack->push(
+ Middleware::log(
+ $logger,
+ new MessageFormatter('{code}:{method}:{target} {error}')
+ )
+ );
+ return new GuzzleHandler(new Client(['handler' => $stack]));
+ }
+}
diff --git a/app/code/Magento/Catalog/Model/Product/Image.php b/app/code/Magento/Catalog/Model/Product/Image.php
index 842ee197f83fe..34ce5cad70b04 100644
--- a/app/code/Magento/Catalog/Model/Product/Image.php
+++ b/app/code/Magento/Catalog/Model/Product/Image.php
@@ -6,15 +6,13 @@
namespace Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
+use Magento\Catalog\Model\Product\Image\ParamsBuilder;
use Magento\Catalog\Model\View\Asset\ImageFactory;
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
-use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Image as MagentoImage;
use Magento\Framework\Serialize\SerializerInterface;
-use Magento\Catalog\Model\Product\Image\ParamsBuilder;
-use Magento\Framework\Filesystem\Driver\File as FilesystemDriver;
/**
* Image operations
@@ -202,11 +200,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
*/
private $serializer;
- /**
- * @var FilesystemDriver
- */
- private $filesystemDriver;
-
/**
* Constructor
*
@@ -227,7 +220,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
* @param array $data
* @param SerializerInterface $serializer
* @param ParamsBuilder $paramsBuilder
- * @param FilesystemDriver $filesystemDriver
* @throws \Magento\Framework\Exception\FileSystemException
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
@@ -249,8 +241,7 @@ public function __construct(
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [],
SerializerInterface $serializer = null,
- ParamsBuilder $paramsBuilder = null,
- FilesystemDriver $filesystemDriver = null
+ ParamsBuilder $paramsBuilder = null
) {
$this->_storeManager = $storeManager;
$this->_catalogProductMediaConfig = $catalogProductMediaConfig;
@@ -265,7 +256,6 @@ public function __construct(
$this->viewAssetPlaceholderFactory = $viewAssetPlaceholderFactory;
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
$this->paramsBuilder = $paramsBuilder ?: ObjectManager::getInstance()->get(ParamsBuilder::class);
- $this->filesystemDriver = $filesystemDriver ?: ObjectManager::getInstance()->get(FilesystemDriver::class);
}
/**
@@ -675,12 +665,7 @@ public function getDestinationSubdir()
public function isCached()
{
$path = $this->imageAsset->getPath();
- try {
- $isCached = is_array($this->loadImageInfoFromCache($path)) || $this->filesystemDriver->isExists($path);
- } catch (FileSystemException $e) {
- $isCached = false;
- }
- return $isCached;
+ return is_array($this->loadImageInfoFromCache($path)) || $this->_mediaDirectory->isExist($path);
}
/**
@@ -952,7 +937,7 @@ private function getImageSize($imagePath)
*/
private function saveImageInfoToCache(array $imageInfo, string $imagePath)
{
- $imagePath = $this->cachePrefix . $imagePath;
+ $imagePath = $this->cachePrefix . $imagePath;
$this->_cacheManager->save(
$this->serializer->serialize($imageInfo),
$imagePath,
@@ -968,7 +953,7 @@ private function saveImageInfoToCache(array $imageInfo, string $imagePath)
*/
private function loadImageInfoFromCache(string $imagePath)
{
- $imagePath = $this->cachePrefix . $imagePath;
+ $imagePath = $this->cachePrefix . $imagePath;
$cacheData = $this->_cacheManager->load($imagePath);
if (!$cacheData) {
return false;
diff --git a/app/code/Magento/Customer/etc/config.xml b/app/code/Magento/Customer/etc/config.xml
index ab2020580a2eb..22596e0b901b2 100644
--- a/app/code/Magento/Customer/etc/config.xml
+++ b/app/code/Magento/Customer/etc/config.xml
@@ -103,5 +103,12 @@
60
+
+
+
+ customer_address
+
+
+
diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Image.php b/app/code/Magento/Eav/Model/Attribute/Data/Image.php
index 24cd0f4fcf61f..d61a8b5fda5b1 100644
--- a/app/code/Magento/Eav/Model/Attribute/Data/Image.php
+++ b/app/code/Magento/Eav/Model/Attribute/Data/Image.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Eav\Model\Attribute\Data;
+use Magento\Framework\Filesystem\ExtendedDriverInterface;
+
/**
* EAV Entity Attribute Image File Data Model
*
@@ -21,24 +23,30 @@ class Image extends \Magento\Eav\Model\Attribute\Data\File
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
+ * @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _validateByRules($value)
{
$label = __($this->getAttribute()->getStoreLabel());
$rules = $this->getAttribute()->getValidateRules();
+ $localStorage = !$this->_directory->getDriver() instanceof ExtendedDriverInterface;
+ $imageProp = $localStorage
+ ? @getimagesize($value['tmp_name'])
+ : $this->_directory->getDriver()->getMetadata($value['tmp_name']);
+ $allowImageTypes = ['gif', 'jpg', 'jpeg', 'png'];
+ if (!isset($imageProp['extension']) && isset($imageProp[2])) {
+ $extensionsMap = [1 => 'gif', 2 => 'jpg', 3 => 'png'];
+ $imageProp['extension'] = $extensionsMap[$imageProp[2]] ?? null;
+ }
- $imageProp = @getimagesize($value['tmp_name']);
-
- $allowImageTypes = [1 => 'gif', 2 => 'jpg', 3 => 'png'];
-
- if (!isset($allowImageTypes[$imageProp[2]])) {
+ if (!\in_array($imageProp['extension'], $allowImageTypes, true)) {
return [__('"%1" is not a valid image format', $label)];
}
// modify image name
$extension = pathinfo($value['name'], PATHINFO_EXTENSION);
- if ($extension != $allowImageTypes[$imageProp[2]]) {
- $value['name'] = pathinfo($value['name'], PATHINFO_FILENAME) . '.' . $allowImageTypes[$imageProp[2]];
+ if ($extension !== $imageProp['extension']) {
+ $value['name'] = pathinfo($value['name'], PATHINFO_FILENAME) . '.' . $imageProp['extension'];
}
$errors = [];
@@ -49,17 +57,17 @@ protected function _validateByRules($value)
}
}
- if (!empty($rules['max_image_width'])) {
- if ($rules['max_image_width'] < $imageProp[0]) {
- $r = $rules['max_image_width'];
- $errors[] = __('"%1" width exceeds allowed value of %2 px.', $label, $r);
- }
+ $imageWidth = $imageProp['extra']['image-width'] ?? $imageProp[0];
+ if (!empty($rules['max_image_width']) && !empty($imageWidth)
+ && ($rules['max_image_width'] < $imageWidth)) {
+ $r = $rules['max_image_width'];
+ $errors[] = __('"%1" width exceeds allowed value of %2 px.', $label, $r);
}
- if (!empty($rules['max_image_height'])) {
- if ($rules['max_image_height'] < $imageProp[1]) {
- $r = $rules['max_image_height'];
- $errors[] = __('"%1" height exceeds allowed value of %2 px.', $label, $r);
- }
+ $imageHeight = $imageProp['extra']['image-height'] ?? $imageProp[1];
+ if (!empty($rules['max_image_height']) && !empty($imageHeight)
+ && ($rules['max_image_height'] < $imageHeight)) {
+ $r = $rules['max_image_height'];
+ $errors[] = __('"%1" height exceeds allowed value of %2 px.', $label, $r);
}
return $errors;
diff --git a/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php b/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php
index 87cd4cf346288..07cf6f8c733d4 100644
--- a/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php
+++ b/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php
@@ -248,6 +248,9 @@ protected function _prepareForm()
.', e.g. product_images, import_images/batch1.
'
.'For example, in case product_images, files should be placed into '
.'<Magento root directory>/'
+ .$this->imagesDirectoryProvider->getDirectoryRelativePath() . '/product_images folder.
'
+ .'
If remote storage is enabled, in case product_images, files should be placed into '
+ .'<Remote Storage>/'
.$this->imagesDirectoryProvider->getDirectoryRelativePath() . '/product_images folder.',
['i', 'br']
)
diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php
index e31f36e627a66..8c47412adc835 100644
--- a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php
+++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php
@@ -70,9 +70,9 @@ public function execute()
return $resultRedirect;
}
- $directoryWrite = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_EXPORT);
+ $directoryWrite = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
try {
- $directoryWrite->delete($directoryWrite->getAbsolutePath($fileName));
+ $directoryWrite->delete($directoryWrite->getAbsolutePath() . 'export/' . $fileName);
$this->messageManager->addSuccessMessage(__('File %1 deleted', $fileName));
} catch (ValidatorException $exception) {
$this->messageManager->addErrorMessage(
diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Download.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Download.php
index 26ee257c42ff2..8e432e395bdf4 100644
--- a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Download.php
+++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Download.php
@@ -67,12 +67,13 @@ public function execute()
return $resultRedirect;
}
try {
- $directory = $this->filesystem->getDirectoryRead(DirectoryList::VAR_EXPORT);
- if ($directory->isFile($fileName)) {
+ $path = 'export/' . $fileName;
+ $directory = $this->filesystem->getDirectoryRead(DirectoryList::VAR_IMPORT_EXPORT);
+ if ($directory->isFile($path)) {
return $this->fileFactory->create(
- $fileName,
- $directory->readFile($fileName),
- DirectoryList::VAR_EXPORT
+ $path,
+ $directory->readFile($path),
+ DirectoryList::VAR_IMPORT_EXPORT
);
}
$this->messageManager->addErrorMessage(__('%1 is not a valid file', $fileName));
diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php b/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php
index ba37cc8aacff9..9dcb2fdafb74f 100644
--- a/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php
+++ b/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php
@@ -62,7 +62,7 @@ public function execute()
$this->fileFactory->create(
$fileName,
null,
- DirectoryList::VAR_DIR,
+ DirectoryList::VAR_IMPORT_EXPORT,
'application/octet-stream',
$reportHelper->getReportSize($fileName)
);
diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Download.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Download.php
index 9918ef8908956..5ff0dd9b63da9 100644
--- a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Download.php
+++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Download.php
@@ -109,7 +109,7 @@ public function execute()
$this->fileFactory->create(
$fileName,
null,
- DirectoryList::VAR_DIR,
+ DirectoryList::VAR_IMPORT_EXPORT,
'application/octet-stream',
$fileSize
);
diff --git a/app/code/Magento/ImportExport/Helper/Report.php b/app/code/Magento/ImportExport/Helper/Report.php
index 29d1928d837d6..d5be27a569942 100644
--- a/app/code/Magento/ImportExport/Helper/Report.php
+++ b/app/code/Magento/ImportExport/Helper/Report.php
@@ -40,7 +40,7 @@ public function __construct(
\Magento\Framework\Filesystem $filesystem
) {
$this->timeZone = $timeZone;
- $this->varDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
+ $this->varDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
parent::__construct($context);
}
diff --git a/app/code/Magento/ImportExport/Model/AbstractModel.php b/app/code/Magento/ImportExport/Model/AbstractModel.php
index 87fde3fbb68a3..4010f3bfcae4c 100644
--- a/app/code/Magento/ImportExport/Model/AbstractModel.php
+++ b/app/code/Magento/ImportExport/Model/AbstractModel.php
@@ -56,7 +56,7 @@ public function __construct(
array $data = []
) {
$this->_logger = $logger;
- $this->_varDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
+ $this->_varDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
parent::__construct($data);
}
diff --git a/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php b/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php
index 8fbc91de5b211..1e292e849c9f8 100644
--- a/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php
+++ b/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php
@@ -46,7 +46,7 @@ abstract class AbstractAdapter
public function __construct(
\Magento\Framework\Filesystem $filesystem,
$destination = null,
- $destinationDirectoryCode = DirectoryList::VAR_DIR
+ $destinationDirectoryCode = DirectoryList::VAR_IMPORT_EXPORT
) {
$this->_directoryHandle = $filesystem->getDirectoryWrite($destinationDirectoryCode);
if (!$destination) {
diff --git a/app/code/Magento/ImportExport/Model/Export/Consumer.php b/app/code/Magento/ImportExport/Model/Export/Consumer.php
index 955f96fe3de2e..55ffbb9ab213d 100644
--- a/app/code/Magento/ImportExport/Model/Export/Consumer.php
+++ b/app/code/Magento/ImportExport/Model/Export/Consumer.php
@@ -70,8 +70,8 @@ public function process(ExportInfoInterface $exportInfo)
try {
$data = $this->exportManager->export($exportInfo);
$fileName = $exportInfo->getFileName();
- $directory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_EXPORT);
- $directory->writeFile($fileName, $data);
+ $directory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
+ $directory->writeFile('export/' . $fileName, $data);
$this->notifier->addMajor(
__('Your export file is ready'),
diff --git a/app/code/Magento/ImportExport/Model/Report/Csv.php b/app/code/Magento/ImportExport/Model/Report/Csv.php
index e7ddef1008444..26f36c53cb7f8 100644
--- a/app/code/Magento/ImportExport/Model/Report/Csv.php
+++ b/app/code/Magento/ImportExport/Model/Report/Csv.php
@@ -83,7 +83,7 @@ public function createReport(
}
}
- $directory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
+ $directory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
$outputFileName = $this->generateOutputFileName($originalFileName);
$directory->writeFile(Import::IMPORT_HISTORY_DIR . $outputFileName, $outputCsv->getContents());
@@ -136,7 +136,7 @@ protected function createSourceCsvModel($sourceFile)
return $this->sourceCsvFactory->create(
[
'file' => $sourceFile,
- 'directory' => $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR),
+ 'directory' => $this->filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT),
'delimiter' => $this->reportHelper->getDelimiter(),
]
);
diff --git a/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php b/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php
index 71614bafd138e..e9df0a8127315 100644
--- a/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php
+++ b/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php
@@ -85,7 +85,7 @@ public function __construct(
);
$this->fileIO = $fileIO ?: ObjectManager::getInstance()->get(File::class);
- $this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_EXPORT);
+ $this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
}
/**
@@ -97,11 +97,11 @@ public function __construct(
public function getData()
{
$emptyResponse = ['items' => [], 'totalRecords' => 0];
- if (!$this->directory->isExist($this->directory->getAbsolutePath())) {
+ if (!$this->directory->isExist($this->directory->getAbsolutePath() . 'export/')) {
return $emptyResponse;
}
- $files = $this->getExportFiles($this->directory->getAbsolutePath());
+ $files = $this->getExportFiles($this->directory->getAbsolutePath() . 'export/');
if (empty($files)) {
return $emptyResponse;
}
@@ -128,14 +128,11 @@ public function getData()
*/
private function getPathToExportFile($file): string
{
- $directory = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_EXPORT);
$delimiter = '/';
$cutPath = explode(
$delimiter,
- $directory->getAbsolutePath()
+ $this->directory->getAbsolutePath() . 'export'
);
- // remove . from dirname if file path is not absolute in the file system but just a file name
- $file['dirname'] = $file['dirname'] !== '.' ? $file['dirname'] : '';
$filePath = explode(
$delimiter,
@@ -163,6 +160,7 @@ private function getExportFiles(string $directoryPath): array
return [];
}
foreach ($files as $filePath) {
+ $filePath = $this->directory->getAbsolutePath($filePath);
if ($this->directory->isFile($filePath)) {
$fileModificationTime = $this->directory->stat($filePath)['mtime'];
$sortedFiles[$fileModificationTime] = $filePath;
diff --git a/app/code/Magento/RemoteStorage/Model/Synchronizer.php b/app/code/Magento/RemoteStorage/Model/Synchronizer.php
index 4276c7a1a2ffd..3b01e7af5ee54 100644
--- a/app/code/Magento/RemoteStorage/Model/Synchronizer.php
+++ b/app/code/Magento/RemoteStorage/Model/Synchronizer.php
@@ -8,13 +8,14 @@
namespace Magento\RemoteStorage\Model;
use Generator;
+use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Exception\ValidatorException;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Filesystem\Glob;
use Magento\RemoteStorage\Driver\DriverPool as RemoteDriverPool;
use Magento\RemoteStorage\Filesystem;
-use Magento\Framework\Filesystem\Directory\WriteInterface;
/**
* Synchronize files from local filesystem.
@@ -44,10 +45,12 @@ public function __construct(Filesystem $filesystem)
public function execute(): Generator
{
foreach ($this->filesystem->getDirectoryCodes() as $directoryCode) {
- $directory = $this->filesystem->getDirectoryWrite($directoryCode, DriverPool::FILE);
- $remoteDirectory = $this->filesystem->getDirectoryWrite($directoryCode, RemoteDriverPool::REMOTE);
+ if ($this->isSynchronizationAllowed($directoryCode)) {
+ $directory = $this->filesystem->getDirectoryWrite($directoryCode, DriverPool::FILE);
+ $remoteDirectory = $this->filesystem->getDirectoryWrite($directoryCode, RemoteDriverPool::REMOTE);
- yield from $this->copyRecursive($directory, $remoteDirectory, $directory->getAbsolutePath());
+ yield from $this->copyRecursive($directory, $remoteDirectory, $directory->getAbsolutePath());
+ }
}
}
@@ -101,4 +104,18 @@ private function copyRecursive(
yield from $this->copyRecursive($directory, $remoteDirectory, $childDirectory, $pattern, $flags);
}
}
+
+ /**
+ * Check if synchronization is allowed.
+ *
+ * @param string $directoryCode
+ * @return bool
+ * @deprecated This method should be removed when MC-39280 is fixed
+ * and import export functionality is allocated inside var/import_export directory
+ */
+ private function isSynchronizationAllowed(string $directoryCode): bool
+ {
+ // skip synchronization for import export
+ return $directoryCode !== DirectoryList::VAR_IMPORT_EXPORT;
+ }
}
diff --git a/app/code/Magento/RemoteStorage/Plugin/Image.php b/app/code/Magento/RemoteStorage/Plugin/Image.php
index 013e3fd23e168..5c40bba238651 100644
--- a/app/code/Magento/RemoteStorage/Plugin/Image.php
+++ b/app/code/Magento/RemoteStorage/Plugin/Image.php
@@ -185,7 +185,7 @@ public function __destruct()
private function copyFileToTmp(string $filePath): string
{
if ($this->fileExistsInTmp($filePath)) {
- return $filePath;
+ return $this->tmpFiles[$filePath];
}
$absolutePath = $this->remoteDirectoryWrite->getAbsolutePath($filePath);
if ($this->remoteDirectoryWrite->isFile($absolutePath)) {
@@ -223,7 +223,7 @@ private function storeTmpName(string $filePath): string
*/
private function fileExistsInTmp(string $filePath): bool
{
- return in_array($filePath, $this->tmpFiles, true);
+ return array_key_exists($filePath, $this->tmpFiles);
}
/**
diff --git a/app/code/Magento/RemoteStorage/Test/Unit/Model/SynchronizerTest.php b/app/code/Magento/RemoteStorage/Test/Unit/Model/SynchronizerTest.php
index 5c3ddb74bb0cf..4e373e7f9c77e 100644
--- a/app/code/Magento/RemoteStorage/Test/Unit/Model/SynchronizerTest.php
+++ b/app/code/Magento/RemoteStorage/Test/Unit/Model/SynchronizerTest.php
@@ -51,7 +51,7 @@ protected function setUp(): void
public function testExecute(): void
{
$this->filesystemMock->method('getDirectoryCodes')
- ->willReturn(['test']);
+ ->willReturn(['test', 'import_export']);
$localDriver = $this->createMock(DriverInterface::class);
$remoteDriver = $this->createMock(DriverInterface::class);
@@ -63,7 +63,8 @@ public function testExecute(): void
$remoteDirectory->method('getDriver')
->willReturn($remoteDriver);
- $this->filesystemMock->method('getDirectoryWrite')
+ $this->filesystemMock->expects(self::exactly(2))
+ ->method('getDirectoryWrite')
->willReturnMap([
['test', DriverPool::FILE, $localDirectory],
['test', RemoteDriverPool::REMOTE, $remoteDirectory]
diff --git a/app/code/Magento/RemoteStorage/etc/di.xml b/app/code/Magento/RemoteStorage/etc/di.xml
index 04dcc5955ac41..6ba98cdd107e8 100644
--- a/app/code/Magento/RemoteStorage/etc/di.xml
+++ b/app/code/Magento/RemoteStorage/etc/di.xml
@@ -26,7 +26,7 @@
- Magento\Framework\App\Filesystem\DirectoryList::MEDIA
- - Magento\Framework\App\Filesystem\DirectoryList::VAR_EXPORT
+ - Magento\Framework\App\Filesystem\DirectoryList::VAR_IMPORT_EXPORT
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php
index af2b72e03e9be..43bb7852e2441 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Application.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php
@@ -731,6 +731,7 @@ protected function getCustomDirs()
DirectoryList::TMP => [$path => "{$var}/tmp"],
DirectoryList::UPLOAD => [$path => "{$var}/upload"],
DirectoryList::PUB => [$path => "{$this->installDir}/pub"],
+ DirectoryList::VAR_IMPORT_EXPORT => [$path => "{$this->installDir}/var"],
];
return $customDirs;
}
diff --git a/dev/tests/integration/testsuite/Magento/Config/Block/System/Config/FormTest.php b/dev/tests/integration/testsuite/Magento/Config/Block/System/Config/FormTest.php
index aae6ae770063f..a93adeee1307d 100644
--- a/dev/tests/integration/testsuite/Magento/Config/Block/System/Config/FormTest.php
+++ b/dev/tests/integration/testsuite/Magento/Config/Block/System/Config/FormTest.php
@@ -585,6 +585,13 @@ private function setEncryptedValue($encryptedValue)
*/
protected function tearDown(): void
{
+ $reflection = new \ReflectionObject($this);
+ foreach ($reflection->getProperties() as $property) {
+ if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
+ $property->setAccessible(true);
+ $property->setValue($this, null);
+ }
+ }
$this->setEncryptedValue('{ENCRYPTED_VALUE}');
$configResourceModel = Bootstrap::getObjectManager()->get(\Magento\Config\Model\ResourceModel\Config::class);
diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DeleteTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DeleteTest.php
index 53e90ebf76f66..e6f631758eb41 100644
--- a/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DeleteTest.php
+++ b/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DeleteTest.php
@@ -51,7 +51,7 @@ protected function setUp(): void
$this->fileSystem = $this->_objectManager->get(Filesystem::class);
$this->sourceFilePath = __DIR__ . '/../../Import/_files' . DIRECTORY_SEPARATOR . $this->fileName;
//Refers to tests 'var' directory
- $this->varDirectory = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_DIR);
+ $this->varDirectory = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_IMPORT_EXPORT);
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DownloadTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DownloadTest.php
index 2128516189474..277e6af871650 100644
--- a/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DownloadTest.php
+++ b/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DownloadTest.php
@@ -105,7 +105,7 @@ public function testExecute($file): void
'Incorrect response header "content-type"'
);
$this->assertEquals(
- 'attachment; filename="' . $this->fileName . '"',
+ 'attachment; filename="export/' . $this->fileName . '"',
$contentDisposition->getFieldValue(),
'Incorrect response header "content-disposition"'
);
diff --git a/lib/internal/Magento/Framework/App/Filesystem/DirectoryList.php b/lib/internal/Magento/Framework/App/Filesystem/DirectoryList.php
index fdf524348293b..ce150b00a6665 100644
--- a/lib/internal/Magento/Framework/App/Filesystem/DirectoryList.php
+++ b/lib/internal/Magento/Framework/App/Filesystem/DirectoryList.php
@@ -63,9 +63,9 @@ class DirectoryList extends \Magento\Framework\Filesystem\DirectoryList
const VAR_EXPORT = 'var_export';
/**
- * Storage of files which were imported.
+ * Storage of files for import/export.
*/
- const VAR_IMPORT = 'var_import';
+ const VAR_IMPORT_EXPORT = 'import_export';
/**
* Temporary files
@@ -156,7 +156,8 @@ public static function getDefaultConfig()
self::CONFIG => [parent::PATH => 'app/etc'],
self::LIB_INTERNAL => [parent::PATH => 'lib/internal'],
self::VAR_DIR => [parent::PATH => 'var'],
- self::VAR_EXPORT => [parent::PATH => 'var/export', parent::URL_PATH => 'export'],
+ /** @deprecated */
+ self::VAR_EXPORT => [parent::PATH => 'var/export'],
self::CACHE => [parent::PATH => 'var/cache'],
self::LOG => [parent::PATH => 'var/log'],
self::DI => [parent::PATH => 'generated/metadata'],
@@ -175,7 +176,7 @@ public static function getDefaultConfig()
self::GENERATED => [parent::PATH => 'generated'],
self::GENERATED_CODE => [parent::PATH => Io::DEFAULT_DIRECTORY],
self::GENERATED_METADATA => [parent::PATH => 'generated/metadata'],
- self::VAR_IMPORT => [parent::PATH => 'var/import', parent::URL_PATH => 'var/import'],
+ self::VAR_IMPORT_EXPORT => [parent::PATH => 'var', parent::URL_PATH => 'import_export'],
];
return parent::getDefaultConfig() + $result;
}
diff --git a/lib/internal/Magento/Framework/File/Uploader.php b/lib/internal/Magento/Framework/File/Uploader.php
index c3246bfbf1e48..3ed8e274cfecd 100644
--- a/lib/internal/Magento/Framework/File/Uploader.php
+++ b/lib/internal/Magento/Framework/File/Uploader.php
@@ -13,6 +13,7 @@
use Magento\Framework\Filesystem\DriverInterface;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Validation\ValidationException;
+use Psr\Log\LoggerInterface;
/**
* File upload class
@@ -133,6 +134,11 @@ class Uploader
*/
private $fileMime;
+ /**
+ * @var LoggerInterface
+ */
+ private $logger;
+
/**#@+
* File upload type (multiple or single)
*/
@@ -329,24 +335,42 @@ protected function chmod($file)
* @param string $tmpPath
* @param string $destPath
* @return bool
- * @throws FileSystemException
*/
protected function _moveFile($tmpPath, $destPath)
{
$rootCode = DirectoryList::PUB;
- if (strpos($destPath, $this->getDirectoryList()->getPath($rootCode)) !== 0) {
- $rootCode = DirectoryList::ROOT;
- }
+ try {
+ if (strpos($destPath, $this->getDirectoryList()->getPath($rootCode)) !== 0) {
+ $rootCode = DirectoryList::ROOT;
+ }
- $destPath = str_replace($this->getDirectoryList()->getPath($rootCode), '', $destPath);
- $directory = $this->getTargetDirectory()->getDirectoryWrite($rootCode);
+ $destPath = str_replace($this->getDirectoryList()->getPath($rootCode), '', $destPath);
+ $directory = $this->getTargetDirectory()->getDirectoryWrite($rootCode);
- return $this->getFileDriver()->rename(
- $tmpPath,
- $directory->getAbsolutePath($destPath),
- $directory->getDriver()
- );
+ return $this->getFileDriver()->rename(
+ $tmpPath,
+ $directory->getAbsolutePath($destPath),
+ $directory->getDriver()
+ );
+ } catch (FileSystemException $exception) {
+ $this->getLogger()->critical($exception->getMessage());
+ return false;
+ }
+ }
+
+ /**
+ * Get logger instance.
+ *
+ * @deprecated
+ * @return LoggerInterface
+ */
+ private function getLogger(): LoggerInterface
+ {
+ if (!$this->logger) {
+ $this->logger = ObjectManager::getInstance()->get(LoggerInterface::class);
+ }
+ return $this->logger;
}
/**