Skip to content

Commit 347755b

Browse files
Merge branch '2.4-develop' into 32368-qraphql-get-cart-type
2 parents ad14a28 + 1bafc57 commit 347755b

File tree

62 files changed

+1615
-543
lines changed

Some content is hidden

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

62 files changed

+1615
-543
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backend\ViewModel;
9+
10+
/**
11+
* View model interface for requirejs configuration modifier
12+
*/
13+
interface RequireJsConfigModifierInterface
14+
{
15+
/**
16+
* Modifies requirejs configuration
17+
*
18+
* @param array $config requirejs configuration
19+
* @return array
20+
*/
21+
public function modify(array $config): array;
22+
}

app/code/Magento/Backend/view/adminhtml/templates/page/js/require_js.phtml

+13-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@
55
*/
66

77
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
8+
/** @var \Magento\Backend\Block\Page\RequireJs $block */
9+
10+
$requireJsConfig = [
11+
'baseUrl' => $block->getViewFileUrl('/'),
12+
];
13+
14+
$configModifier = $block->getConfigModifier();
15+
$requireJsConfig = $configModifier instanceof \Magento\Backend\ViewModel\RequireJsConfigModifierInterface
16+
? $configModifier->modify($requireJsConfig)
17+
: $requireJsConfig;
818

919
$scriptString = '
1020
var BASE_URL = \'' . /* @noEscape */ $block->getUrl('*') . '\';
1121
var FORM_KEY = \'' . /* @noEscape */ $block->getFormKey() . '\';
12-
var require = {
13-
\'baseUrl\': \'' . /* @noEscape */ $block->getViewFileUrl('/') . '\'
14-
};';
15-
16-
echo /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false);
22+
var require = ' . /* @noEscape */ json_encode($requireJsConfig) .';';
23+
?>
24+
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>

app/code/Magento/Catalog/Controller/Product/Compare/Index.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77
namespace Magento\Catalog\Controller\Product\Compare;
88

9-
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
109
use Magento\Catalog\Api\ProductRepositoryInterface;
10+
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
1111
use Magento\Framework\Data\Form\FormKey\Validator;
1212
use Magento\Framework\View\Result\PageFactory;
1313

@@ -81,6 +81,8 @@ public function execute()
8181
$this->_catalogSession->setBeforeCompareUrl(
8282
$this->urlDecoder->decode($beforeUrl)
8383
);
84+
} else {
85+
$this->_catalogSession->unsBeforeCompareUrl();
8486
}
8587
return $this->resultPageFactory->create();
8688
}

app/code/Magento/Catalog/CustomerData/CompareProducts.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\Config\ScopeConfigInterface;
1010
use Magento\Framework\App\ObjectManager;
1111
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\UrlInterface;
1213
use Magento\Store\Model\StoreManagerInterface;
1314

1415
/**
@@ -43,25 +44,33 @@ class CompareProducts implements SectionSourceInterface
4344
*/
4445
private $storeManager;
4546

47+
/**
48+
* @var UrlInterface
49+
*/
50+
private $urlBuilder;
51+
4652
/**
4753
* @param \Magento\Catalog\Helper\Product\Compare $helper
4854
* @param \Magento\Catalog\Model\Product\Url $productUrl
4955
* @param \Magento\Catalog\Helper\Output $outputHelper
5056
* @param ScopeConfigInterface|null $scopeConfig
5157
* @param StoreManagerInterface|null $storeManager
58+
* @param UrlInterface|null $urlBuilder
5259
*/
5360
public function __construct(
5461
\Magento\Catalog\Helper\Product\Compare $helper,
5562
\Magento\Catalog\Model\Product\Url $productUrl,
5663
\Magento\Catalog\Helper\Output $outputHelper,
5764
?ScopeConfigInterface $scopeConfig = null,
58-
?StoreManagerInterface $storeManager = null
65+
?StoreManagerInterface $storeManager = null,
66+
?UrlInterface $urlBuilder = null
5967
) {
6068
$this->helper = $helper;
6169
$this->productUrl = $productUrl;
6270
$this->outputHelper = $outputHelper;
6371
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
6472
$this->storeManager = $storeManager ?? ObjectManager::getInstance()->get(StoreManagerInterface::class);
73+
$this->urlBuilder = $urlBuilder ?? ObjectManager::getInstance()->get(UrlInterface::class);
6574
}
6675

6776
/**
@@ -73,7 +82,7 @@ public function getSectionData()
7382
return [
7483
'count' => $count,
7584
'countCaption' => $count == 1 ? __('1 item') : __('%1 items', $count),
76-
'listUrl' => $this->helper->getListUrl(),
85+
'listUrl' => $this->urlBuilder->getUrl('catalog/product_compare/index'),
7786
'items' => $count ? $this->getItems() : [],
7887
'websiteId' => $this->storeManager->getWebsite()->getId()
7988
];

app/code/Magento/Catalog/Test/Unit/CustomerData/CompareProductsTest.php

+23-10
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717
use Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection;
1818
use Magento\Framework\App\Config\ScopeConfigInterface;
1919
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
20+
use Magento\Framework\UrlInterface;
21+
use Magento\Store\Model\StoreManagerInterface;
2022
use Magento\Store\Model\Website;
2123
use PHPUnit\Framework\MockObject\MockObject;
2224
use PHPUnit\Framework\TestCase;
23-
use Magento\Store\Model\StoreManagerInterface;
2425

26+
/**
27+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
28+
*/
2529
class CompareProductsTest extends TestCase
2630
{
2731
/**
@@ -64,6 +68,11 @@ class CompareProductsTest extends TestCase
6468
*/
6569
private $websiteMock;
6670

71+
/**
72+
* @var UrlInterface|MockObject
73+
*/
74+
private $urlBuilder;
75+
6776
/**
6877
* @var array
6978
*/
@@ -88,6 +97,9 @@ protected function setUp(): void
8897
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
8998
->disableOriginalConstructor()
9099
->getMockForAbstractClass();
100+
$this->urlBuilder = $this->getMockBuilder(UrlInterface::class)
101+
->disableOriginalConstructor()
102+
->getMock();
91103

92104
$this->storeManagerMock = $this->getMockBuilder(
93105
StoreManagerInterface::class
@@ -97,7 +109,7 @@ protected function setUp(): void
97109
$this->websiteMock = $this->getMockBuilder(
98110
Website::class
99111
)->onlyMethods(
100-
['getId',]
112+
['getId']
101113
)->disableOriginalConstructor()
102114
->getMock();
103115

@@ -110,8 +122,8 @@ protected function setUp(): void
110122
'productUrl' => $this->productUrlMock,
111123
'outputHelper' => $this->outputHelperMock,
112124
'scopeConfig' => $this->scopeConfigMock,
113-
'storeManager' => $this->storeManagerMock
114-
125+
'storeManager' => $this->storeManagerMock,
126+
'urlBuilder' => $this->urlBuilder
115127
]
116128
);
117129
}
@@ -219,9 +231,10 @@ public function testGetSectionData()
219231
->method('getItemCollection')
220232
->willReturn($itemCollectionMock);
221233

222-
$this->helperMock->expects($this->once())
223-
->method('getListUrl')
234+
$this->urlBuilder->expects($this->once())
235+
->method('getUrl')
224236
->willReturn('http://list.url');
237+
225238
$this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($this->websiteMock);
226239
$this->websiteMock->expects($this->any())->method('getId')->willReturn(1);
227240
$this->assertEquals(
@@ -269,8 +282,8 @@ public function testGetSectionDataNoItems()
269282
$this->helperMock->expects($this->never())
270283
->method('getItemCollection');
271284

272-
$this->helperMock->expects($this->once())
273-
->method('getListUrl')
285+
$this->urlBuilder->expects($this->once())
286+
->method('getUrl')
274287
->willReturn('http://list.url');
275288

276289
$this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($this->websiteMock);
@@ -314,8 +327,8 @@ public function testGetSectionDataSingleItem()
314327
->method('getItemCollection')
315328
->willReturn($itemCollectionMock);
316329

317-
$this->helperMock->expects($this->once())
318-
->method('getListUrl')
330+
$this->urlBuilder->expects($this->once())
331+
->method('getUrl')
319332
->willReturn('http://list.url');
320333

321334
$this->assertEquals(

app/code/Magento/Catalog/view/frontend/layout/default.xml

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<referenceContainer name="after.body.start">
6666
<block class="Magento\Framework\View\Element\Js\Components" name="head.components" as="components" template="Magento_Catalog::js/components.phtml"/>
6767
</referenceContainer>
68+
<block class="Magento\Framework\View\Element\Template" name="head.critical" as="head.critical" template="Magento_Theme::html/container.phtml"/>
6869
<block class="Magento\Framework\View\Element\Template" name="head.additional" as="head.additional" template="Magento_Theme::html/container.phtml"/>
6970
</body>
7071
</page>

app/code/Magento/Catalog/view/frontend/web/js/product/storage/storage-service.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ define([
117117
/**
118118
* Subscribers list
119119
*/
120-
subsctibers = {};
120+
subscribers = {};
121121

122122
(function () {
123123
/**
@@ -189,12 +189,12 @@ define([
189189
* @return void
190190
*/
191191
processSubscribers: function (initialized, config) {
192-
if (subsctibers[config.namespace]) {
193-
_.each(subsctibers[config.namespace], function (callback) {
192+
if (subscribers[config.namespace]) {
193+
_.each(subscribers[config.namespace], function (callback) {
194194
callback(initialized);
195195
});
196196

197-
delete subsctibers[config.namespace];
197+
delete subscribers[config.namespace];
198198
}
199199
},
200200

@@ -209,9 +209,9 @@ define([
209209
if (storages[namespace]) {
210210
callback(storages[namespace]);
211211
} else {
212-
subsctibers[namespace] ?
213-
subsctibers[namespace].push(callback) :
214-
subsctibers[namespace] = [callback];
212+
subscribers[namespace] ?
213+
subscribers[namespace].push(callback) :
214+
subscribers[namespace] = [callback];
215215
}
216216
},
217217

app/code/Magento/Checkout/view/adminhtml/email/failed_payment.html

+12-10
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,45 @@ <h1>{{trans "Payment Transaction Failed"}}</h1>
2323

2424
<ul>
2525
<li>
26-
<strong>{{trans "Reason"}}</strong><br />
26+
<strong>{{trans "Reason"}}</strong><br>
2727
{{var reason}}
2828
</li>
2929
<li>
30-
<strong>{{trans "Checkout Type"}}</strong><br />
30+
<strong>{{trans "Checkout Type"}}</strong><br>
3131
{{var checkoutType}}
3232
</li>
3333
<li>
34-
<strong>{{trans "Customer:"}}</strong><br />
34+
<strong>{{trans "Customer:"}}</strong><br>
3535
<a href="mailto:{{var customerEmail}}">{{var customer}}</a> &lt;{{var customerEmail}}&gt;
3636
</li>
3737
<li>
38-
<strong>{{trans "Items"}}</strong><br />
38+
<strong>{{trans "Items"}}</strong><br>
3939
{{var items|raw}}
4040
</li>
4141
<li>
42-
<strong>{{trans "Total:"}}</strong><br />
42+
<strong>{{trans "Total:"}}</strong><br>
4343
{{var total}}
4444
</li>
4545
<li>
46-
<strong>{{trans "Billing Address:"}}</strong><br />
46+
<strong>{{trans "Billing Address:"}}</strong><br>
4747
{{var billingAddressHtml|raw}}
4848
</li>
49+
{{depend shippingMethod}}
4950
<li>
50-
<strong>{{trans "Shipping Address:"}}</strong><br />
51+
<strong>{{trans "Shipping Address:"}}</strong><br>
5152
{{var shippingAddressHtml|raw}}
5253
</li>
5354
<li>
54-
<strong>{{trans "Shipping Method:"}}</strong><br />
55+
<strong>{{trans "Shipping Method:"}}</strong><br>
5556
{{var shippingMethod}}
5657
</li>
58+
{{/depend}}
5759
<li>
58-
<strong>{{trans "Payment Method:"}}</strong><br />
60+
<strong>{{trans "Payment Method:"}}</strong><br>
5961
{{var paymentMethod}}
6062
</li>
6163
<li>
62-
<strong>{{trans "Date & Time:"}}</strong><br />
64+
<strong>{{trans "Date & Time:"}}</strong><br>
6365
{{var dateAndTime}}
6466
</li>
6567
</ul>

app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,17 @@ define([
193193
*/
194194
validateFields: function () {
195195
var addressFlat = addressConverter.formDataProviderToFlatData(
196-
this.collectObservedData(),
197-
'shippingAddress'
196+
this.collectObservedData(),
197+
'shippingAddress'
198198
),
199199
address;
200200

201201
if (this.validateAddressData(addressFlat)) {
202202
addressFlat = uiRegistry.get('checkoutProvider').shippingAddress;
203203
address = addressConverter.formAddressDataToQuoteAddress(addressFlat);
204204
selectShippingAddress(address);
205+
} else {
206+
shippingService.isLoading(false);
205207
}
206208
},
207209

app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php

+21-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\App\Config\ScopeConfigInterface;
1313
use Magento\Framework\App\Filesystem\DirectoryList;
1414
use Magento\Framework\App\ObjectManager;
15+
use Magento\Framework\Data\Collection;
1516
use Magento\Framework\Exception\LocalizedException;
1617

1718
/**
@@ -289,6 +290,7 @@ protected function createSubDirectories($path)
289290
*
290291
* @return array
291292
* @deprecated
293+
* @see isDirectoryAllowed
292294
*/
293295
protected function getConditionsForExcludeDirs()
294296
{
@@ -317,6 +319,7 @@ protected function getConditionsForExcludeDirs()
317319
* @param array $conditions
318320
* @return \Magento\Framework\Data\Collection\Filesystem
319321
* @deprecated
322+
* @see \Magento\Framework\Data\Collection\Filesystem::setDirsFilter
320323
*/
321324
protected function removeItemFromCollection($collection, $conditions)
322325
{
@@ -415,7 +418,7 @@ public function getFilesCollection($path, $type = null)
415418
$mimeType = $itemStats['mimetype'] ?? $this->mime->getMimeType($item->getFilename());
416419
$item->setMimeType($mimeType);
417420

418-
if ($this->isImage($item->getBasename())) {
421+
if ($this->isImageValid($item)) {
419422
$thumbUrl = $this->getThumbnailUrl($item->getFilename(), true);
420423
// generate thumbnail "on the fly" if it does not exists
421424
if (!$thumbUrl) {
@@ -435,6 +438,12 @@ public function getFilesCollection($path, $type = null)
435438
$this->logger->notice(sprintf("GetImageSize caused error: %s", $e->getMessage()));
436439
}
437440
} else {
441+
$this->logger->warning(
442+
sprintf(
443+
"The image %s is invalid and cannot be displayed in the gallery.",
444+
$item->getBasename()
445+
)
446+
);
438447
$thumbUrl = $this->_assetRepo->getUrl(self::THUMB_PLACEHOLDER_PATH_SUFFIX);
439448
}
440449

@@ -1058,4 +1067,15 @@ private function getAllowedDirMask(string $path)
10581067

10591068
return '/^(' . implode('|', array_unique(array_column($allowedDirs, $subfolderLevel - 1))) . ')$/';
10601069
}
1070+
1071+
/**
1072+
* Checks if the file is an image and has a size greater than 0 to validate it can be processes in the gallery.
1073+
*
1074+
* @param Collection $item
1075+
* @return bool
1076+
*/
1077+
private function isImageValid($item)
1078+
{
1079+
return $this->isImage($item->getBasename()) && $item->getSize() > 0;
1080+
}
10611081
}

0 commit comments

Comments
 (0)