Skip to content

Commit 8b1d1c3

Browse files
authored
Merge branch '2.4-develop' into Arrows_Delivery_07022024
2 parents 4ed2b79 + c8f87c2 commit 8b1d1c3

File tree

6 files changed

+153
-32
lines changed

6 files changed

+153
-32
lines changed

app/code/Magento/Backend/view/adminhtml/web/js/media-uploader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ define([
7575
byteConvert(currentFile.size);
7676

7777
// check if file is allowed to upload and resize
78-
allowedResize = $.inArray(currentFile.extension, allowedExt) !== -1;
78+
allowedResize = $.inArray(currentFile.extension?.toLowerCase(), allowedExt) !== -1;
7979

8080
if (!allowedResize) {
8181
fileUploader.aggregateError(currentFile.name,

app/code/Magento/GraphQlCache/Controller/Plugin/GraphQl.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ public function beforeDispatch(
9898
): void {
9999
try {
100100
$this->requestProcessor->validateRequest($request);
101+
/** @var \Magento\Framework\App\Request\Http $request */
102+
$this->requestProcessor->processHeaders($request);
103+
$this->request = $request;
101104
} catch (\Exception $error) {
102105
$this->logger->critical($error->getMessage());
103106
}
104-
/** @var \Magento\Framework\App\Request\Http $request */
105-
$this->requestProcessor->processHeaders($request);
106-
$this->request = $request;
107107
}
108108

109109
/**

app/code/Magento/Ui/view/base/web/js/grid/masonry.js

+28-20
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ define([
100100
}
101101
this.imageMargin = parseInt(this.imageMargin, 10);
102102
this.container = $('[data-id="' + this.containerId + '"]')[0];
103-
104103
this.setLayoutStyles();
105104
this.setEventListener();
106105

@@ -129,38 +128,47 @@ define([
129128
/**
130129
* Set layout styles inside the container
131130
*/
132-
setLayoutStyles: function () {
133-
var containerWidth = parseInt(this.container.clientWidth, 10),
131+
setLayoutStyles: function (callback) {
132+
var containerWidth, rowImages, ratio, rowHeight, calcHeight, isLastRow, rowNumber;
133+
134+
if (typeof this.container != 'undefined') {
135+
containerWidth = parseInt(this.container.clientWidth, 10),
134136
rowImages = [],
135137
ratio = 0,
136138
rowHeight = 0,
137139
calcHeight = 0,
138140
isLastRow = false,
139141
rowNumber = 1;
140142

141-
this.setMinRatio();
143+
this.setMinRatio();
142144

143-
this.rows().forEach(function (image, index) {
144-
ratio += parseFloat((image.width / image.height).toFixed(2));
145-
rowImages.push(image);
145+
this.rows().forEach(function (image, index) {
146+
ratio += parseFloat((image.width / image.height).toFixed(2));
147+
rowImages.push(image);
146148

147-
if (ratio < this.minRatio && index + 1 !== this.rows().length) {
148-
// Row has more space for images and the image is not the last one - proceed to the next iteration
149-
return;
150-
}
149+
if (ratio < this.minRatio && index + 1 !== this.rows().length) {
150+
/**
151+
* Row has more space for images and the image is not the last one -
152+
* Proceed to the next iteration
153+
*/
154+
return;
155+
}
151156

152-
ratio = Math.max(ratio, this.minRatio);
153-
calcHeight = (containerWidth - this.imageMargin * rowImages.length) / ratio;
154-
rowHeight = calcHeight < this.maxImageHeight ? calcHeight : this.maxImageHeight;
155-
isLastRow = index + 1 === this.rows().length;
157+
ratio = Math.max(ratio, this.minRatio);
158+
calcHeight = (containerWidth - this.imageMargin * rowImages.length) / ratio;
159+
rowHeight = calcHeight < this.maxImageHeight ? calcHeight : this.maxImageHeight;
160+
isLastRow = index + 1 === this.rows().length;
156161

157-
this.assignImagesToRow(rowImages, rowNumber, rowHeight, isLastRow);
162+
this.assignImagesToRow(rowImages, rowNumber, rowHeight, isLastRow);
158163

159-
rowImages = [];
160-
ratio = 0;
161-
rowNumber++;
164+
rowImages = [];
165+
ratio = 0;
166+
rowNumber++;
162167

163-
}.bind(this));
168+
}.bind(this));
169+
} else {
170+
setTimeout(callback, 0);
171+
}
164172
},
165173

166174
/**

dev/tests/api-functional/testsuite/Magento/GraphQl/GraphQlCache/GraphQlTest.php

+113
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,96 @@
88
namespace Magento\GraphQl\GraphQlCache;
99

1010
use Magento\Customer\Test\Fixture\Customer;
11+
use Magento\Framework\Registry;
1112
use Magento\TestFramework\Fixture\DataFixture;
1213
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1314
use Magento\TestFramework\TestCase\GraphQlAbstract;
15+
use Magento\Framework\App\FrontControllerInterface;
16+
use Magento\Framework\App\Request\Http;
17+
use Magento\Framework\App\Response\Http as ResponseHttp;
18+
use Magento\GraphQl\Controller\HttpRequestProcessor;
19+
use Magento\GraphQlCache\Controller\Plugin\GraphQl;
20+
use Magento\GraphQlCache\Model\CacheableQuery;
21+
use Magento\GraphQlCache\Model\CacheId\CacheIdCalculator;
22+
use Magento\PageCache\Model\Config;
23+
use PHPUnit\Framework\MockObject\MockObject;
24+
use Psr\Log\LoggerInterface;
1425

1526
class GraphQlTest extends GraphQlAbstract
1627
{
28+
/**
29+
* @var GraphQl
30+
*/
31+
private $graphql;
32+
33+
/**
34+
* @var CacheableQuery|MockObject
35+
*/
36+
private $cacheableQueryMock;
37+
38+
/**
39+
* @var Config|MockObject
40+
*/
41+
private $configMock;
42+
43+
/**
44+
* @var HttpRequestProcessor|MockObject
45+
*/
46+
private $requestProcessorMock;
47+
48+
/**
49+
* @var CacheIdCalculator|MockObject
50+
*/
51+
private $cacheIdCalculatorMock;
52+
53+
/**
54+
* @var LoggerInterface|MockObject
55+
*/
56+
private $loggerMock;
57+
58+
/**
59+
* @var FrontControllerInterface|MockObject
60+
*/
61+
private $subjectMock;
62+
63+
/**
64+
* @var Http|MockObject
65+
*/
66+
private $requestMock;
67+
68+
/**
69+
* @var Registry
70+
*/
71+
private $registryMock;
72+
73+
protected function setUp(): void
74+
{
75+
$this->cacheableQueryMock = $this->createMock(CacheableQuery::class);
76+
$this->cacheIdCalculatorMock = $this->createMock(CacheIdCalculator::class);
77+
$this->configMock = $this->createMock(Config::class);
78+
$this->loggerMock = $this->getMockBuilder(LoggerInterface::class)
79+
->onlyMethods(['critical'])
80+
->disableOriginalConstructor()
81+
->getMockForAbstractClass();
82+
$this->requestProcessorMock = $this->getMockBuilder(HttpRequestProcessor::class)
83+
->onlyMethods(['validateRequest','processHeaders'])
84+
->disableOriginalConstructor()
85+
->getMockForAbstractClass();
86+
$this->registryMock = $this->createMock(Registry::class);
87+
$this->subjectMock = $this->createMock(FrontControllerInterface::class);
88+
$this->requestMock = $this
89+
->getMockBuilder(Http::class)
90+
->disableOriginalConstructor()
91+
->getMockForAbstractClass();
92+
$this->graphql = new GraphQl(
93+
$this->cacheableQueryMock,
94+
$this->cacheIdCalculatorMock,
95+
$this->configMock,
96+
$this->loggerMock,
97+
$this->requestProcessorMock,
98+
$this->registryMock
99+
);
100+
}
17101
#[
18102
DataFixture(Customer::class, as: 'customer'),
19103
]
@@ -40,4 +124,33 @@ public function testMutation(): void
40124
$tokenResponse['headers']['Cache-Control']
41125
);
42126
}
127+
128+
public function testBeforeDispatch(): void
129+
{
130+
$this->requestProcessorMock
131+
->expects($this->once())
132+
->method('validateRequest');
133+
$this->requestProcessorMock
134+
->expects($this->once())
135+
->method('processHeaders');
136+
$this->loggerMock
137+
->expects($this->never())
138+
->method('critical');
139+
$this->assertNull($this->graphql->beforeDispatch($this->subjectMock, $this->requestMock));
140+
}
141+
142+
public function testBeforeDispatchForException(): void
143+
{
144+
$this->requestProcessorMock
145+
->expects($this->once())
146+
->method('validateRequest')
147+
->willThrowException(new \Exception('Invalid Headers'));
148+
$this->requestProcessorMock
149+
->expects($this->never())
150+
->method('processHeaders');
151+
$this->loggerMock
152+
->expects($this->once())
153+
->method('critical');
154+
$this->assertNull($this->graphql->beforeDispatch($this->subjectMock, $this->requestMock));
155+
}
43156
}

dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency()
219219
$productNameInFixtureStore = 'Product\'s Name in Fixture Store';
220220
$product->setName($productNameInFixtureStore)->setStoreId($storeId)->save();
221221

222+
// test cached response store + currency header with non existing currency, and no valid response, no cache
223+
$headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'SOMECURRENCY'];
224+
$this->expectExceptionMessage(
225+
'GraphQL response contains errors: Please correct the target currency'
226+
);
227+
$this->graphQlQuery($query, [], '', $headerMap);
228+
222229
// test store header only, query is cached at this point in EUR
223230
$headerMap = ['Store' => $storeCodeFromFixture];
224231
$response = $this->graphQlQuery($query, [], '', $headerMap);
@@ -302,12 +309,5 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency()
302309
$response['products']['items'][0]['price']['minimalPrice']['amount']['currency'],
303310
'Currency code USD in fixture store default is unexpected'
304311
);
305-
306-
// test cached response store + currency header with non existing currency, and no valid response, no cache
307-
$headerMap = ['Store' => $storeCodeFromFixture, 'Content-Currency' => 'SOMECURRENCY'];
308-
$this->expectExceptionMessage(
309-
'GraphQL response contains errors: Please correct the target currency'
310-
);
311-
$this->graphQlQuery($query, [], '', $headerMap);
312312
}
313313
}

lib/internal/Magento/Framework/Logger/LoggerProxy.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class LoggerProxy implements LoggerInterface, NoninterceptableInterface, ResetAf
2323
* @var ObjectManagerInterface
2424
* phpcs:disable Magento2.Commenting.ClassPropertyPHPDocFormatting
2525
*/
26-
private readonly ObjectManagerInterface $objectManager;
26+
private ObjectManagerInterface $objectManager;
2727

2828
/**
2929
* @var LoggerInterface|null

0 commit comments

Comments
 (0)