Skip to content

Commit 0574ac2

Browse files
authored
Merge pull request #8882 from magento-gl/spartans_pr_15042024
[Spartans] Bugfixes Delivery
2 parents 4745100 + f20e1d6 commit 0574ac2

File tree

22 files changed

+453
-29
lines changed

22 files changed

+453
-29
lines changed

app/code/Magento/Elasticsearch/etc/esconfig.xsd

+14-7
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@
1111
<xs:element name="config" type="configType" />
1212
<xs:complexType name="configType" mixed="true">
1313
<xs:choice maxOccurs="unbounded" minOccurs="1">
14-
<xs:element name="stemmer" type="mixedDataType" />
15-
<xs:element name="stopwords_file" type="mixedDataType" />
14+
<xs:element name="stemmer" type="stemmerDataType" />
15+
<xs:element name="stopwords_file" type="stopwordsDataType" />
1616
</xs:choice>
1717
</xs:complexType>
18-
<xs:complexType name="mixedDataType">
19-
<xs:choice maxOccurs="unbounded" minOccurs="1">
20-
<xs:element type="xs:string" name="default" minOccurs="1" maxOccurs="1" />
21-
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
22-
</xs:choice>
18+
<xs:complexType name="stemmerDataType">
19+
<xs:sequence>
20+
<xs:element type="xs:string" name="type" minOccurs="1" maxOccurs="1"/>
21+
<xs:element type="xs:string" name="default" minOccurs="1" maxOccurs="1"/>
22+
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
23+
</xs:sequence>
24+
</xs:complexType>
25+
<xs:complexType name="stopwordsDataType">
26+
<xs:sequence>
27+
<xs:element type="xs:string" name="default" minOccurs="1" maxOccurs="1"/>
28+
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
29+
</xs:sequence>
2330
</xs:complexType>
2431
</xs:schema>

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ public function dispatch(RequestInterface $request): ResponseInterface
187187
$result = [];
188188

189189
$schema = null;
190+
$query = $data['query'] ?? '';
190191
try {
191192
/** @var Http $request */
192193
$this->requestProcessor->validateRequest($request);
193-
$query = $data['query'] ?? '';
194194
$parsedQuery = $this->queryParser->parse($query);
195195
$data['parsedQuery'] = $parsedQuery;
196196

@@ -216,7 +216,7 @@ public function dispatch(RequestInterface $request): ResponseInterface
216216
$jsonResult->renderResult($this->httpResponse);
217217

218218
// log information about the query, unless it is an introspection query
219-
if (!isset($data['query']) || strpos($data['query'], 'IntrospectionQuery') === false) {
219+
if (strpos($query, 'IntrospectionQuery') === false) {
220220
$queryInformation = $this->logDataHelper->getLogData($request, $data, $schema, $this->httpResponse);
221221
$this->loggerPool->execute($queryInformation);
222222
}

app/code/Magento/GraphQl/etc/di.xml

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<item name="graphql_type" xsi:type="object">Magento\Framework\GraphQl\Config\Element\TypeFactory</item>
3636
<item name="graphql_input" xsi:type="object">Magento\Framework\GraphQl\Config\Element\InputFactory</item>
3737
<item name="graphql_enum" xsi:type="object">Magento\Framework\GraphQl\Config\Element\EnumFactory</item>
38+
<item name="graphql_scalar" xsi:type="object">Magento\Framework\GraphQl\Config\Element\ScalarFactory</item>
3839
</argument>
3940
</arguments>
4041
</type>
@@ -69,6 +70,7 @@
6970
<item name="Magento\Framework\GraphQl\Config\Element\InterfaceType" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Output\OutputInterfaceObject</item>
7071
<item name="Magento\Framework\GraphQl\Config\Element\UnionType" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Output\OutputUnionObject</item>
7172
<item name="Magento\Framework\GraphQl\Config\Element\Enum" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Enum\Enum</item>
73+
<item name="Magento\Framework\GraphQl\Config\Element\Scalar" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Scalar\Scalar</item>
7274
</argument>
7375
</arguments>
7476
</type>
@@ -95,6 +97,7 @@
9597
<item name="object_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\ObjectType</item>
9698
<item name="input_object_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\InputObjectType</item>
9799
<item name="interface_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\InterfaceType</item>
100+
<item name="scalar_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\ScalarType</item>
98101
</argument>
99102
</arguments>
100103
</type>

app/code/Magento/GraphQl/etc/schema.graphqls

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ directive @typeResolver(class: String="") on UNION
4141

4242
directive @cache(cacheIdentity: String="" cacheable: Boolean=true) on QUERY
4343

44+
directive @implementation(class: String="") on SCALAR
45+
| OBJECT
46+
4447
type Query {
4548
}
4649

app/code/Magento/ImportExport/Controller/Adminhtml/Import/Validate.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ private function processValidationResult($validationResult, $resultBlock)
8383

8484
if ($import->getProcessedRowsCount()) {
8585
if ($validationResult) {
86-
$this->addMessageForValidResult($resultBlock);
86+
$totalError = $errorAggregator->getErrorsCount();
87+
$totalRows = $import->getProcessedRowsCount();
88+
$this->addMessageForValidResult($resultBlock, $totalError, $totalRows);
8789
} else {
8890
$resultBlock->addError(
8991
__('Data validation failed. Please fix the following errors and upload the file again.')
@@ -154,12 +156,14 @@ private function addMessageToSkipErrors(Result $resultBlock)
154156
* 2. Add message for case when imported data was checked and result is valid, but import is not allowed.
155157
*
156158
* @param Result $resultBlock
159+
* @param Import $totalError
160+
* @param Import $totalRows
157161
* @return void
158162
* @throws \Magento\Framework\Exception\LocalizedException
159163
*/
160-
private function addMessageForValidResult(Result $resultBlock)
164+
private function addMessageForValidResult(Result $resultBlock, $totalError, $totalRows)
161165
{
162-
if ($this->getImport()->isImportAllowed()) {
166+
if ($this->getImport()->isImportAllowed() && $totalRows > $totalError) {
163167
$resultBlock->addSuccess(__('File is valid! To start import process press "Import" button'), true);
164168
} else {
165169
$resultBlock->addError(__('The file is valid, but we can\'t import it for some reason.'));

app/code/Magento/ImportExport/Plugin/DeferCacheCleaningUntilImportIsComplete.php

+32-2
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,45 @@
77

88
namespace Magento\ImportExport\Plugin;
99

10+
use Magento\Framework\App\Cache\TypeListInterface;
11+
use Magento\Framework\App\RequestInterface;
1012
use Magento\Framework\Indexer\DeferredCacheCleanerInterface;
1113
use Magento\ImportExport\Model\Import;
1214

1315
class DeferCacheCleaningUntilImportIsComplete
1416
{
17+
private const BEHAVIOR_ADD_UPDATE = 'add_update';
18+
private const ENTITY_CUSTOMER = 'customer';
19+
private const CACHE_TYPE_GRAPHQL_QUERY_RESOLVER_RESULT = 'graphql_query_resolver_result';
20+
1521
/**
1622
* @var DeferredCacheCleanerInterface
1723
*/
1824
private $cacheCleaner;
1925

26+
/**
27+
* @var TypeListInterface
28+
*/
29+
private $cacheTypeList;
30+
31+
/**
32+
* @var RequestInterface
33+
*/
34+
private $request;
35+
2036
/**
2137
* @param DeferredCacheCleanerInterface $cacheCleaner
38+
* @param TypeListInterface $cacheTypeList
39+
* @param RequestInterface $request
2240
*/
23-
public function __construct(DeferredCacheCleanerInterface $cacheCleaner)
24-
{
41+
public function __construct(
42+
DeferredCacheCleanerInterface $cacheCleaner,
43+
TypeListInterface $cacheTypeList,
44+
RequestInterface $request
45+
) {
2546
$this->cacheCleaner = $cacheCleaner;
47+
$this->cacheTypeList = $cacheTypeList;
48+
$this->request = $request;
2649
}
2750

2851
/**
@@ -47,6 +70,13 @@ public function beforeImportSource(Import $subject): void
4770
*/
4871
public function afterImportSource(Import $subject, bool $result): bool
4972
{
73+
$behavior = $this->request->getParam('behavior');
74+
$entity = $this->request->getParam('entity');
75+
76+
if ($behavior === self::BEHAVIOR_ADD_UPDATE &&
77+
$entity === self::ENTITY_CUSTOMER) {
78+
$this->cacheTypeList->cleanType(self::CACHE_TYPE_GRAPHQL_QUERY_RESOLVER_RESULT);
79+
}
5080
$this->cacheCleaner->flush();
5181
return $result;
5282
}

app/code/Magento/ImportExport/Test/Unit/Plugin/DeferCacheCleaningUntilImportIsCompleteTest.php

+24-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\ImportExport\Test\Unit\Plugin;
99

10+
use Magento\Framework\App\Cache\TypeListInterface;
11+
use Magento\Framework\App\RequestInterface;
1012
use Magento\Framework\Indexer\DeferredCacheCleanerInterface;
1113
use Magento\ImportExport\Model\Import;
1214
use Magento\ImportExport\Plugin\DeferCacheCleaningUntilImportIsComplete;
@@ -25,14 +27,30 @@ class DeferCacheCleaningUntilImportIsCompleteTest extends TestCase
2527
*/
2628
private $cacheCleaner;
2729

30+
/**
31+
* @var TypeListInterface|MockObject
32+
*/
33+
private $cacheTypeList;
34+
35+
/**
36+
* @var RequestInterface|MockObject
37+
*/
38+
private $request;
39+
2840
/**
2941
* @inheritdoc
3042
*/
3143
protected function setUp(): void
3244
{
3345
parent::setUp();
3446
$this->cacheCleaner = $this->getMockForAbstractClass(DeferredCacheCleanerInterface::class);
35-
$this->plugin = new DeferCacheCleaningUntilImportIsComplete($this->cacheCleaner);
47+
$this->cacheTypeList = $this->getMockForAbstractClass(TypeListInterface::class);
48+
$this->request = $this->createMock(RequestInterface::class);
49+
$this->plugin = new DeferCacheCleaningUntilImportIsComplete(
50+
$this->cacheCleaner,
51+
$this->cacheTypeList,
52+
$this->request
53+
);
3654
}
3755

3856
/**
@@ -52,6 +70,11 @@ public function testAfterMethod()
5270
{
5371
$this->cacheCleaner->expects($this->once())->method('flush');
5472
$subject = $this->createMock(Import::class);
73+
// Assuming 'behavior' and 'entity' are the parameter names
74+
$this->request->expects($this->any())->method('getParam')->willReturnMap([
75+
['behavior', null, 'add_update'],
76+
['entity', null, 'customer'],
77+
]);
5578
$result = $this->plugin->afterImportSource($subject, true);
5679
$this->assertTrue($result);
5780
}

app/code/Magento/ProductAlert/etc/crontab.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
99
<group id="default">
10-
<job name="catalog_product_alert" instance="Magento\ProductAlert\Model\Observer" method="process">
10+
<job name="product_alert" instance="Magento\ProductAlert\Model\Observer" method="process">
1111
<config_path>crontab/default/jobs/catalog_product_alert/schedule/cron_expr</config_path>
1212
</job>
1313
</group>

app/code/Magento/SalesRule/Model/Validator.php

+1
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ public function processShippingAmount(Address $address)
532532
$address->setBaseShippingDiscountAmount($this->priceCurrency->roundPrice($baseDiscountAmount));
533533
$appliedRuleIds[$rule->getRuleId()] = $rule->getRuleId();
534534

535+
$this->rulesApplier->maintainAddressCouponCode($address, $rule, $this->getCouponCode());
535536
$this->rulesApplier->addDiscountDescription(
536537
$address,
537538
$rule,

dev/tests/integration/testsuite/Magento/CatalogInventory/Model/StockItemSave/OnProductUpdate/ByProductModel/ByQuantityAndStockStatusTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function setUp(): void
4444
* model (deprecated)
4545
*
4646
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
47-
* @magentoDbIsolation disabled
47+
* @magentoDbIsolation enabled
4848
*/
4949
public function testSaveBySetQuantityAndStockStatus()
5050
{
@@ -61,7 +61,7 @@ public function testSaveBySetQuantityAndStockStatus()
6161
* via product model (deprecated)
6262
*
6363
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
64-
* @magentoDbIsolation disabled
64+
* @magentoDbIsolation enabled
6565
*/
6666
public function testSaveBySetData()
6767
{

dev/tests/integration/testsuite/Magento/CatalogInventory/Model/StockItemSave/OnProductUpdate/ByProductModel/ByStockDataTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function setUp(): void
4444
* model (deprecated)
4545
*
4646
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
47-
* @magentoDbIsolation disabled
47+
* @magentoDbIsolation enabled
4848
*/
4949
public function testSaveBySetStockData()
5050
{
@@ -61,7 +61,7 @@ public function testSaveBySetStockData()
6161
* via product model (deprecated)
6262
*
6363
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
64-
* @magentoDbIsolation disabled
64+
* @magentoDbIsolation enabled
6565
*/
6666
public function testSaveBySetData()
6767
{

dev/tests/integration/testsuite/Magento/CatalogInventory/Model/StockItemSave/OnProductUpdate/ByProductModel/ByStockItemTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testSave()
7676
* product model (deprecated)
7777
*
7878
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
79-
* @magentoDbIsolation disabled
79+
* @magentoDbIsolation enabled
8080
*/
8181
public function testSaveManuallyCreatedStockItem()
8282
{
@@ -97,7 +97,7 @@ public function testSaveManuallyCreatedStockItem()
9797
* product repository (deprecated)
9898
*
9999
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
100-
* @magentoDbIsolation disabled
100+
* @magentoDbIsolation enabled
101101
*/
102102
public function testSaveManuallyUpdatedStockItem()
103103
{
@@ -116,7 +116,7 @@ public function testSaveManuallyUpdatedStockItem()
116116

117117
/**
118118
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
119-
* @magentoDbIsolation disabled
119+
* @magentoDbIsolation enabled
120120
*/
121121
public function testAutomaticIsInStockUpdate(): void
122122
{

dev/tests/integration/testsuite/Magento/CatalogInventory/Model/StockItemSave/OnProductUpdate/ByProductRepository/ByQuantityAndStockStatusTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function setUp(): void
4444
* repository
4545
*
4646
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
47-
* @magentoDbIsolation disabled
47+
* @magentoDbIsolation enabled
4848
*/
4949
public function testSaveBySetQuantityAndStockStatus()
5050
{
@@ -61,7 +61,7 @@ public function testSaveBySetQuantityAndStockStatus()
6161
* via product repository
6262
*
6363
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
64-
* @magentoDbIsolation disabled
64+
* @magentoDbIsolation enabled
6565
*/
6666
public function testSaveBySetData()
6767
{

dev/tests/integration/testsuite/Magento/Cron/Observer/ProcessCronQueueObserverTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testDispatchScheduled()
3636
\Magento\Cron\Model\ResourceModel\Schedule\Collection::class
3737
);
3838
$collection->addFieldToFilter('status', \Magento\Cron\Model\Schedule::STATUS_PENDING);
39-
$collection->addFieldToFilter('job_code', 'catalog_product_alert');
39+
$collection->addFieldToFilter('job_code', 'product_alert');
4040
$this->assertGreaterThan(0, $collection->count(), 'Cron has failed to schedule tasks for itself for future.');
4141
}
4242

0 commit comments

Comments
 (0)