Skip to content

Commit 84b5806

Browse files
committed
Merge remote-tracking branch 'mainline/2.3.5-develop' into borg-2.3.5
2 parents 7b0921f + f004950 commit 84b5806

File tree

286 files changed

+12499
-2759
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

286 files changed

+12499
-2759
lines changed

app/code/Magento/AuthorizenetGraphQl/Model/AuthorizenetDataProvider.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,6 @@ public function getData(array $data): array
4949
__('Required parameter "authorizenet_acceptjs" for "payment_method" is missing.')
5050
);
5151
}
52-
if (!isset($data[self::PATH_ADDITIONAL_DATA]['opaque_data_descriptor'])) {
53-
throw new GraphQlInputException(
54-
__('Required parameter "opaque_data_descriptor" for "authorizenet_acceptjs" is missing.')
55-
);
56-
}
57-
if (!isset($data[self::PATH_ADDITIONAL_DATA]['opaque_data_value'])) {
58-
throw new GraphQlInputException(
59-
__('Required parameter "opaque_data_value" for "authorizenet_acceptjs" is missing.')
60-
);
61-
}
62-
if (!isset($data[self::PATH_ADDITIONAL_DATA]['cc_last_4'])) {
63-
throw new GraphQlInputException(
64-
__('Required parameter "cc_last_4" for "authorizenet_acceptjs" is missing.')
65-
);
66-
}
6752

6853
$additionalData = $this->arrayManager->get(static::PATH_ADDITIONAL_DATA, $data);
6954
foreach ($additionalData as $key => $value) {

app/code/Magento/BraintreeGraphQl/Model/BraintreeDataProvider.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ public function getData(array $args): array
3131
__('Required parameter "braintree" for "payment_method" is missing.')
3232
);
3333
}
34-
35-
if (!isset($args[self::PATH_ADDITIONAL_DATA]['payment_method_nonce'])) {
36-
throw new GraphQlInputException(
37-
__('Required parameter "payment_method_nonce" for "braintree" is missing.')
38-
);
39-
}
40-
41-
if (!isset($args[self::PATH_ADDITIONAL_DATA]['is_active_payment_token_enabler'])) {
42-
throw new GraphQlInputException(
43-
__('Required parameter "is_active_payment_token_enabler" for "braintree" is missing.')
44-
);
45-
}
46-
4734
return $args[self::PATH_ADDITIONAL_DATA];
4835
}
4936
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\Catalog\Controller\Adminhtml\Product\Initialization;
88

9-
use DateTime;
109
use Magento\Backend\Helper\Js;
1110
use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory as CustomOptionFactory;
1211
use Magento\Catalog\Api\Data\ProductLinkInterfaceFactory as ProductLinkFactory;
@@ -15,6 +14,8 @@
1514
use Magento\Catalog\Api\ProductRepositoryInterface\Proxy as ProductRepository;
1615
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter;
1716
use Magento\Catalog\Model\Product;
17+
use Magento\Catalog\Model\Product\Authorization as ProductAuthorization;
18+
use Magento\Catalog\Model\Product\Filter\DateTime as DateTimeFilter;
1819
use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks;
1920
use Magento\Catalog\Model\Product\Link\Resolver as LinkResolver;
2021
use Magento\Catalog\Model\Product\LinkTypeProvider;
@@ -24,13 +25,13 @@
2425
use Magento\Framework\Stdlib\DateTime\Filter\Date;
2526
use Magento\Store\Model\StoreManagerInterface;
2627
use Zend_Filter_Input;
27-
use Magento\Catalog\Model\Product\Authorization as ProductAuthorization;
2828

2929
/**
3030
* Product helper
3131
*
3232
* @api
3333
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
34+
* @SuppressWarnings(PHPMD.TooManyFields)
3435
* @since 100.0.2
3536
*/
3637
class Helper
@@ -89,11 +90,6 @@ class Helper
8990
*/
9091
private $linkResolver;
9192

92-
/**
93-
* @var \Magento\Framework\Stdlib\DateTime\Filter\DateTime
94-
*/
95-
private $dateTimeFilter;
96-
9793
/**
9894
* @var LinkTypeProvider
9995
*/
@@ -114,6 +110,11 @@ class Helper
114110
*/
115111
private $localeFormat;
116112

113+
/**
114+
* @var DateTimeFilter
115+
*/
116+
private $dateTimeFilter;
117+
117118
/**
118119
* Constructor
119120
*
@@ -130,6 +131,7 @@ class Helper
130131
* @param AttributeFilter|null $attributeFilter
131132
* @param FormatInterface|null $localeFormat
132133
* @param ProductAuthorization|null $productAuthorization
134+
* @param DateTimeFilter|null $dateTimeFilter
133135
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
134136
*/
135137
public function __construct(
@@ -145,7 +147,8 @@ public function __construct(
145147
LinkTypeProvider $linkTypeProvider = null,
146148
AttributeFilter $attributeFilter = null,
147149
FormatInterface $localeFormat = null,
148-
?ProductAuthorization $productAuthorization = null
150+
?ProductAuthorization $productAuthorization = null,
151+
?DateTimeFilter $dateTimeFilter = null
149152
) {
150153
$this->request = $request;
151154
$this->storeManager = $storeManager;
@@ -162,6 +165,7 @@ public function __construct(
162165
$this->attributeFilter = $attributeFilter ?: $objectManager->get(AttributeFilter::class);
163166
$this->localeFormat = $localeFormat ?: $objectManager->get(FormatInterface::class);
164167
$this->productAuthorization = $productAuthorization ?? $objectManager->get(ProductAuthorization::class);
168+
$this->dateTimeFilter = $dateTimeFilter ?? $objectManager->get(DateTimeFilter::class);
165169
}
166170

167171
/**
@@ -185,7 +189,6 @@ public function initializeFromData(Product $product, array $productData)
185189
}
186190

187191
$productData = $this->normalize($productData);
188-
$productData = $this->convertSpecialFromDateStringToObject($productData);
189192

190193
if (!empty($productData['is_downloadable'])) {
191194
$productData['product_has_weight'] = 0;
@@ -209,7 +212,7 @@ public function initializeFromData(Product $product, array $productData)
209212
foreach ($attributes as $attrKey => $attribute) {
210213
if ($attribute->getBackend()->getType() == 'datetime') {
211214
if (array_key_exists($attrKey, $productData) && $productData[$attrKey] != '') {
212-
$dateFieldFilters[$attrKey] = $this->getDateTimeFilter();
215+
$dateFieldFilters[$attrKey] = $this->dateTimeFilter;
213216
}
214217
}
215218
}
@@ -408,22 +411,6 @@ private function getLinkResolver()
408411
return $this->linkResolver;
409412
}
410413

411-
/**
412-
* Get DateTimeFilter instance
413-
*
414-
* @return \Magento\Framework\Stdlib\DateTime\Filter\DateTime
415-
* @deprecated 101.0.0
416-
*/
417-
private function getDateTimeFilter()
418-
{
419-
if ($this->dateTimeFilter === null) {
420-
$this->dateTimeFilter = ObjectManager::getInstance()
421-
->get(\Magento\Framework\Stdlib\DateTime\Filter\DateTime::class);
422-
}
423-
424-
return $this->dateTimeFilter;
425-
}
426-
427414
/**
428415
* Remove ids of non selected websites from $websiteIds array and return filtered data
429416
*
@@ -497,20 +484,4 @@ function ($valueData) {
497484

498485
return $product->setOptions($customOptions);
499486
}
500-
501-
/**
502-
* Convert string date presentation into object
503-
*
504-
* @param array $productData
505-
* @return array
506-
*/
507-
private function convertSpecialFromDateStringToObject($productData)
508-
{
509-
if (isset($productData['special_from_date']) && $productData['special_from_date'] != '') {
510-
$productData['special_from_date'] = $this->getDateTimeFilter()->filter($productData['special_from_date']);
511-
$productData['special_from_date'] = new DateTime($productData['special_from_date']);
512-
}
513-
514-
return $productData;
515-
}
516487
}

app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
*/
66
namespace Magento\Catalog\Model\Category\Attribute\Backend;
77

8+
use Magento\Catalog\Model\ImageUploader;
89
use Magento\Framework\App\Filesystem\DirectoryList;
10+
use Magento\Framework\App\ObjectManager;
911
use Magento\Framework\File\Uploader;
12+
use Magento\Store\Api\Data\StoreInterface;
13+
use Magento\Store\Model\StoreManagerInterface;
1014

1115
/**
1216
* Catalog category image attribute backend model
@@ -45,7 +49,7 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
4549
protected $_logger;
4650

4751
/**
48-
* @var \Magento\Catalog\Model\ImageUploader
52+
* @var ImageUploader
4953
*/
5054
private $imageUploader;
5155

@@ -54,19 +58,32 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
5458
*/
5559
private $additionalData = '_additional_data_';
5660

61+
/**
62+
* @var StoreManagerInterface
63+
*/
64+
private $storeManager;
65+
5766
/**
5867
* @param \Psr\Log\LoggerInterface $logger
5968
* @param \Magento\Framework\Filesystem $filesystem
6069
* @param \Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory
70+
* @param StoreManagerInterface $storeManager
71+
* @param ImageUploader $imageUploader
6172
*/
6273
public function __construct(
6374
\Psr\Log\LoggerInterface $logger,
6475
\Magento\Framework\Filesystem $filesystem,
65-
\Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory
76+
\Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory,
77+
StoreManagerInterface $storeManager = null,
78+
ImageUploader $imageUploader = null
6679
) {
6780
$this->_filesystem = $filesystem;
6881
$this->_fileUploaderFactory = $fileUploaderFactory;
6982
$this->_logger = $logger;
83+
$this->storeManager = $storeManager ??
84+
ObjectManager::getInstance()->get(StoreManagerInterface::class);
85+
$this->imageUploader = $imageUploader ??
86+
ObjectManager::getInstance()->get(ImageUploader::class);
7087
}
7188

7289
/**
@@ -91,16 +108,17 @@ private function getUploadedImageName($value)
91108
*
92109
* @param string $imageName
93110
* @return string
111+
* @throws \Magento\Framework\Exception\FileSystemException
94112
*/
95113
private function checkUniqueImageName(string $imageName): string
96114
{
97-
$imageUploader = $this->getImageUploader();
98115
$mediaDirectory = $this->_filesystem->getDirectoryWrite(DirectoryList::MEDIA);
99116
$imageAbsolutePath = $mediaDirectory->getAbsolutePath(
100-
$imageUploader->getBasePath() . DIRECTORY_SEPARATOR . $imageName
117+
$this->imageUploader->getBasePath() . DIRECTORY_SEPARATOR . $imageName
101118
);
102119

103-
$imageName = Uploader::getNewFilename($imageAbsolutePath);
120+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
121+
$imageName = call_user_func([Uploader::class, 'getNewFilename'], $imageAbsolutePath);
104122

105123
return $imageName;
106124
}
@@ -112,14 +130,26 @@ private function checkUniqueImageName(string $imageName): string
112130
*
113131
* @param \Magento\Framework\DataObject $object
114132
* @return $this
133+
* @throws \Magento\Framework\Exception\FileSystemException
115134
* @since 101.0.8
116135
*/
117136
public function beforeSave($object)
118137
{
119138
$attributeName = $this->getAttribute()->getName();
120139
$value = $object->getData($attributeName);
121140

122-
if ($this->fileResidesOutsideCategoryDir($value)) {
141+
if ($this->isTmpFileAvailable($value) && $imageName = $this->getUploadedImageName($value)) {
142+
try {
143+
/** @var StoreInterface $store */
144+
$store = $this->storeManager->getStore();
145+
$baseMediaDir = $store->getBaseMediaDir();
146+
$newImgRelativePath = $this->imageUploader->moveFileFromTmp($imageName, true);
147+
$value[0]['url'] = '/' . $baseMediaDir . '/' . $newImgRelativePath;
148+
$value[0]['name'] = $value[0]['url'];
149+
} catch (\Exception $e) {
150+
$this->_logger->critical($e);
151+
}
152+
} elseif ($this->fileResidesOutsideCategoryDir($value)) {
123153
// use relative path for image attribute so we know it's outside of category dir when we fetch it
124154
// phpcs:ignore Magento2.Functions.DiscouragedFunction
125155
$value[0]['url'] = parse_url($value[0]['url'], PHP_URL_PATH);
@@ -139,23 +169,6 @@ public function beforeSave($object)
139169
return parent::beforeSave($object);
140170
}
141171

142-
/**
143-
* Get Instance of Category Image Uploader.
144-
*
145-
* @return \Magento\Catalog\Model\ImageUploader
146-
*
147-
* @deprecated 101.0.0
148-
*/
149-
private function getImageUploader()
150-
{
151-
if ($this->imageUploader === null) {
152-
$this->imageUploader = \Magento\Framework\App\ObjectManager::getInstance()
153-
->get(\Magento\Catalog\CategoryImageUpload::class);
154-
}
155-
156-
return $this->imageUploader;
157-
}
158-
159172
/**
160173
* Check if temporary file is available for new image upload.
161174
*
@@ -194,19 +207,10 @@ private function fileResidesOutsideCategoryDir($value)
194207
*
195208
* @param \Magento\Framework\DataObject $object
196209
* @return \Magento\Catalog\Model\Category\Attribute\Backend\Image
210+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
197211
*/
198212
public function afterSave($object)
199213
{
200-
$value = $object->getData($this->additionalData . $this->getAttribute()->getName());
201-
202-
if ($this->isTmpFileAvailable($value) && $imageName = $this->getUploadedImageName($value)) {
203-
try {
204-
$this->getImageUploader()->moveFileFromTmp($imageName);
205-
} catch (\Exception $e) {
206-
$this->_logger->critical($e);
207-
}
208-
}
209-
210214
return $this;
211215
}
212216
}

app/code/Magento/Catalog/Model/ImageUploader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ public function getFilePath($path, $imageName)
191191
* Checking file for moving and move it
192192
*
193193
* @param string $imageName
194-
*
194+
* @param bool $returnRelativePath
195195
* @return string
196196
*
197197
* @throws \Magento\Framework\Exception\LocalizedException
198198
*/
199-
public function moveFileFromTmp($imageName)
199+
public function moveFileFromTmp($imageName, $returnRelativePath = false)
200200
{
201201
$baseTmpPath = $this->getBaseTmpPath();
202202
$basePath = $this->getBasePath();
@@ -226,7 +226,7 @@ public function moveFileFromTmp($imageName)
226226
);
227227
}
228228

229-
return $imageName;
229+
return $returnRelativePath ? $baseImagePath : $imageName;
230230
}
231231

232232
/**

0 commit comments

Comments
 (0)