diff --git a/vendor/magento/module-async-config/Model/AsyncConfigPublisher.php b/vendor/magento/module-async-config/Model/AsyncConfigPublisher.php index 9647c29b8800b..4935b82cdde8c 100644 --- a/vendor/magento/module-async-config/Model/AsyncConfigPublisher.php +++ b/vendor/magento/module-async-config/Model/AsyncConfigPublisher.php @@ -7,14 +7,16 @@ namespace Magento\AsyncConfig\Model; +use Magento\AsyncConfig\Api\AsyncConfigPublisherInterface; use Magento\AsyncConfig\Api\Data\AsyncConfigMessageInterfaceFactory; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Filesystem\Io\File; use Magento\Framework\MessageQueue\PublisherInterface; use Magento\Framework\Serialize\Serializer\Json; +use Magento\Framework\Filesystem\DirectoryList as FilesystemDirectoryList; -class AsyncConfigPublisher implements \Magento\AsyncConfig\Api\AsyncConfigPublisherInterface +class AsyncConfigPublisher implements AsyncConfigPublisherInterface { /** * @var PublisherInterface @@ -32,7 +34,7 @@ class AsyncConfigPublisher implements \Magento\AsyncConfig\Api\AsyncConfigPublis private $serializer; /** - * @var \Magento\Framework\Filesystem\DirectoryList + * @var FilesystemDirectoryList */ private $dir; @@ -46,14 +48,14 @@ class AsyncConfigPublisher implements \Magento\AsyncConfig\Api\AsyncConfigPublis * @param AsyncConfigMessageInterfaceFactory $asyncConfigFactory * @param PublisherInterface $publisher * @param Json $json - * @param \Magento\Framework\Filesystem\DirectoryList $dir + * @param FilesystemDirectoryList $dir * @param File $file */ public function __construct( AsyncConfigMessageInterfaceFactory $asyncConfigFactory, PublisherInterface $publisher, Json $json, - \Magento\Framework\Filesystem\DirectoryList $dir, + FilesystemDirectoryList $dir, File $file ) { $this->asyncConfigFactory = $asyncConfigFactory; @@ -100,7 +102,10 @@ private function saveImages(array &$configData) private function changeImagePath(array &$fields) { foreach ($fields as &$data) { - if (!empty($data['value']['tmp_name'])) { + if (!isset($data['value']) || !is_array($data['value'])) { + continue; + } + if (!empty($data['value']['tmp_name']) && is_uploaded_file($data['value']['tmp_name'])) { $newPath = $this->dir->getPath(DirectoryList::MEDIA) . '/' . // phpcs:ignore Magento2.Functions.DiscouragedFunction @@ -110,6 +116,8 @@ private function changeImagePath(array &$fields) $newPath ); $data['value']['tmp_name'] = $newPath; + } elseif (array_key_exists('tmp_name', $data['value'])) { + unset($data['value']['tmp_name']); } } }