Skip to content

Commit fc8c2d3

Browse files
committed
fix for #37957 issue (Image uploader does not work inside dynamic rows)
1 parent 528ed74 commit fc8c2d3

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ protected function _moveFile($tmpPath, $destPath)
383383
/**
384384
* Get logger instance.
385385
*
386-
* @deprecated
387386
* @return LoggerInterface
387+
* @deprecated
388388
*/
389389
private function getLogger(): LoggerInterface
390390
{
@@ -673,7 +673,7 @@ private function _getMimeType()
673673
* @param string|array $fileId
674674
* @return void
675675
* @throws \DomainException
676-
* @throws \InvalidArgumentException
676+
* @throws \InvalidArgumentException|FileSystemException
677677
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
678678
*/
679679
private function _setUploadFileId($fileId)
@@ -688,7 +688,7 @@ private function _setUploadFileId($fileId)
688688
}
689689

690690
$fileId = $fileId !== null ? $fileId : '';
691-
preg_match("/^(.*?)\[(.*?)\]$/", $fileId, $file);
691+
preg_match("/^(.*?)(\[.+])$/", $fileId, $file);
692692

693693
if (is_array($file) && count($file) > 0 && !empty($file[0]) && !empty($file[1])) {
694694
array_shift($file);
@@ -698,7 +698,14 @@ private function _setUploadFileId($fileId)
698698
$tmpVar = [];
699699

700700
foreach ($fileAttributes as $attributeName => $attributeValue) {
701-
$tmpVar[$attributeName] = $attributeValue[$file[1]];
701+
$keys = explode('][', trim($file[1], '[]'));
702+
foreach ($keys as $key) {
703+
$key = trim($key, '[]');
704+
if (isset($attributeValue[$key])) {
705+
$attributeValue = $attributeValue[$key];
706+
}
707+
}
708+
$tmpVar[$attributeName] = $attributeValue;
702709
}
703710

704711
$fileAttributes = $tmpVar;
@@ -864,8 +871,8 @@ public static function getDispersionPath($fileName)
864871
/**
865872
* Get driver for file
866873
*
867-
* @deprecated
868874
* @return DriverInterface
875+
* @deprecated
869876
*/
870877
private function getFileDriver(): DriverInterface
871878
{

0 commit comments

Comments
 (0)