Skip to content

Commit 3a89dfa

Browse files
author
Gabriel da Gama
authored
Merge branch '2.4-develop' into 30870_payflow_delayed_capture
2 parents c00fad6 + d3f202a commit 3a89dfa

File tree

18 files changed

+797
-50
lines changed

18 files changed

+797
-50
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class BatchSizeCalculator
4343
private const DEPLOYMENT_CONFIG_INDEXER_BATCHES = 'indexer/batch_size/';
4444

4545
/**
46-
* BatchSizeCalculator constructor.
4746
* @param array $batchRowsCount
4847
* @param array $estimators
4948
* @param array $batchSizeAdjusters
49+
* @param DeploymentConfig|null $deploymentConfig
5050
*/
5151
public function __construct(
5252
array $batchRowsCount,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminProductFormAdvancedPricingAddTierPriceActionGroup" extends="AdminProductFormAdvancedPricingAddTierPriceActionGroup">
12+
<annotations>
13+
<description>Check tier price on Advanced Pricing dialog on the Admin Product creation/edit page.</description>
14+
</annotations>
15+
<remove keyForRemoval="selectWebsite"/>
16+
<remove keyForRemoval="selectCustomerGroup"/>
17+
<remove keyForRemoval="fillQuantity"/>
18+
<remove keyForRemoval="selectPriceType"/>
19+
<remove keyForRemoval="fillPriceAmount"/>
20+
<remove keyForRemoval="waitCustomerGroupFilterAppears"/>
21+
<remove keyForRemoval="selectCustomerGroupValue"/>
22+
<executeJS function="return window.getComputedStyle(document.querySelector(&quot;{$priceAmountSelector}&quot;)).getPropertyValue('min-width')" after="waitPriceAmountFieldAppers" stepKey="priceMinWidth"/>
23+
<assertEquals after="priceMinWidth" stepKey="assertWebsiteAmounts">
24+
<actualResult type="string">$priceMinWidth</actualResult>
25+
<expectedResult type="string">60px</expectedResult>
26+
</assertEquals>
27+
<click selector="{{AdminProductFormAdvancedPricingSection.customerGroupPriceDeleteButton}}" after="assertWebsiteAmounts" stepKey="clickCustomerGroupPriceDeleteButton"/>
28+
</actionGroup>
29+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/AdminApplyTierPriceToProductWithPercentageDiscountTest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<actionGroup ref="ResetProductGridToDefaultViewActionGroup" stepKey="resetGridToDefaultKeywordSearch"/>
3333
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
3434
</after>
35-
35+
3636
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="loginAsAdmin"/>
3737
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
3838
<argument name="product" value="$$createSimpleProduct$$"/>
@@ -41,6 +41,10 @@
4141
<argument name="product" value="$$createSimpleProduct$$"/>
4242
</actionGroup>
4343

44+
<actionGroup ref="AdminProductFormOpenAdvancedPricingDialogActionGroup" stepKey="clickOnAdvancedPricingButtonForAssert"/>
45+
<actionGroup ref="AssertAdminProductFormAdvancedPricingAddTierPriceActionGroup" stepKey="assertProductTierPriceInput"/>
46+
<actionGroup ref="AdminProductFormDoneAdvancedPricingDialogActionGroup" stepKey="doneButtonAfterAssert"/>
47+
4448
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="scrollToTopOfPage"/>
4549
<actionGroup ref="AdminProductFormOpenAdvancedPricingDialogActionGroup" stepKey="clickOnAdvancedPricingButton"/>
4650
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCustomerGroupPriceAddButton"/>

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class Fulltext implements
111111
* @param array $data
112112
* @param ProcessManager|null $processManager
113113
* @param int|null $batchSize
114-
* @param DeploymentConfig $deploymentConfig
114+
* @param DeploymentConfig|null $deploymentConfig
115115
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
116116
*/
117117
public function __construct(
@@ -182,7 +182,7 @@ public function executeByDimensions(array $dimensions, \Traversable $entityIds =
182182
$i = 0;
183183

184184
$this->batchSize = $this->deploymentConfig->get(
185-
self::DEPLOYMENT_CONFIG_INDEXER_BATCHES . self::INDEXER_ID
185+
self::DEPLOYMENT_CONFIG_INDEXER_BATCHES . self::INDEXER_ID . '/partial_reindex'
186186
) ?? $this->batchSize;
187187

188188
foreach ($entityIds as $entityId) {

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Catalog\Api\Data\ProductInterface;
99
use Magento\CatalogSearch\Model\Indexer\Fulltext;
10+
use Magento\Framework\App\DeploymentConfig;
1011
use Magento\Framework\App\ObjectManager;
1112
use Magento\Framework\App\ResourceConnection;
1213

@@ -199,6 +200,19 @@ class Full
199200
private $batchSize;
200201

201202
/**
203+
* @var DeploymentConfig|null
204+
*/
205+
private $deploymentConfig;
206+
207+
/**
208+
* Deployment config path
209+
*
210+
* @var string
211+
*/
212+
private const DEPLOYMENT_CONFIG_INDEXER_BATCHES = 'indexer/batch_size/';
213+
214+
/**
215+
* Full constructor.
202216
* @param ResourceConnection $resource
203217
* @param \Magento\Catalog\Model\Product\Type $catalogProductType
204218
* @param \Magento\Eav\Model\Config $eavConfig
@@ -216,10 +230,12 @@ class Full
216230
* @param \Magento\CatalogSearch\Model\ResourceModel\Fulltext $fulltextResource
217231
* @param \Magento\Framework\Search\Request\DimensionFactory $dimensionFactory
218232
* @param \Magento\Framework\Indexer\ConfigInterface $indexerConfig
219-
* @param mixed $indexIteratorFactory
233+
* @param null $indexIteratorFactory
220234
* @param \Magento\Framework\EntityManager\MetadataPool|null $metadataPool
221235
* @param DataProvider|null $dataProvider
222236
* @param int $batchSize
237+
* @param DeploymentConfig|null $deploymentConfig
238+
*
223239
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
224240
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
225241
*/
@@ -244,7 +260,8 @@ public function __construct(
244260
$indexIteratorFactory = null,
245261
\Magento\Framework\EntityManager\MetadataPool $metadataPool = null,
246262
DataProvider $dataProvider = null,
247-
$batchSize = 500
263+
$batchSize = 500,
264+
?DeploymentConfig $deploymentConfig = null
248265
) {
249266
$this->resource = $resource;
250267
$this->connection = $resource->getConnection();
@@ -268,6 +285,7 @@ public function __construct(
268285
->get(\Magento\Framework\EntityManager\MetadataPool::class);
269286
$this->dataProvider = $dataProvider ?: ObjectManager::getInstance()->get(DataProvider::class);
270287
$this->batchSize = $batchSize;
288+
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->get(DeploymentConfig::class);
271289
}
272290

273291
/**
@@ -360,6 +378,9 @@ public function rebuildStoreIndex($storeId, $productIds = null)
360378
];
361379

362380
$lastProductId = 0;
381+
$this->batchSize = $this->deploymentConfig->get(
382+
self::DEPLOYMENT_CONFIG_INDEXER_BATCHES . Fulltext::INDEXER_ID . '/mysql_get'
383+
) ?? $this->batchSize;
363384
$products = $this->dataProvider
364385
->getSearchableProducts($storeId, $staticFields, $productIds, $lastProductId, $this->batchSize);
365386
while (count($products) > 0) {

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerFiltersSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
<element name="viewDropdown" type="button" selector=".admin__data-grid-action-bookmarks button.admin__action-dropdown"/>
2020
<element name="viewBookmark" type="button" selector="//div[contains(@class, 'admin__data-grid-action-bookmarks')]/ul/li/div/a[text() = '{{label}}']" parameterized="true" timeout="30"/>
2121
<element name="countryOptions" type="button" selector=".admin__data-grid-filters select[name=billing_country_id] option"/>
22+
<element name="websiteOptions" type="button" selector=".admin__data-grid-filters select[name=website_id] option"/>
2223
</section>
2324
</sections>

app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
</column>
190190
<column name="website_id" class="Magento\Customer\Ui\Component\Listing\Column\Websites" component="Magento_Ui/js/grid/columns/select" sortOrder="110">
191191
<settings>
192+
<options class="Magento\Store\Model\ResourceModel\Website\Collection"/>
192193
<filter>select</filter>
193194
<editor>
194195
<editorType>select</editorType>

app/code/Magento/Elasticsearch/Model/Indexer/IndexerHandler.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
*/
66
namespace Magento\Elasticsearch\Model\Indexer;
77

8+
use Magento\CatalogSearch\Model\Indexer\Fulltext;
89
use Magento\Elasticsearch\Model\Adapter\Elasticsearch as ElasticsearchAdapter;
910
use Magento\Elasticsearch\Model\Adapter\Index\IndexNameResolver;
11+
use Magento\Framework\App\DeploymentConfig;
12+
use Magento\Framework\App\ObjectManager;
1013
use Magento\Framework\App\ScopeResolverInterface;
1114
use Magento\Framework\Indexer\IndexStructureInterface;
1215
use Magento\Framework\Indexer\SaveHandler\Batch;
@@ -59,13 +62,27 @@ class IndexerHandler implements IndexerInterface
5962
private $scopeResolver;
6063

6164
/**
65+
* @var DeploymentConfig|null
66+
*/
67+
private $deploymentConfig;
68+
69+
/**
70+
* Deployment config path
71+
*
72+
* @var string
73+
*/
74+
private const DEPLOYMENT_CONFIG_INDEXER_BATCHES = 'indexer/batch_size/';
75+
76+
/**
77+
* IndexerHandler constructor.
6278
* @param IndexStructureInterface $indexStructure
6379
* @param ElasticsearchAdapter $adapter
6480
* @param IndexNameResolver $indexNameResolver
6581
* @param Batch $batch
6682
* @param ScopeResolverInterface $scopeResolver
6783
* @param array $data
6884
* @param int $batchSize
85+
* @param DeploymentConfig|null $deploymentConfig
6986
*/
7087
public function __construct(
7188
IndexStructureInterface $indexStructure,
@@ -74,7 +91,8 @@ public function __construct(
7491
Batch $batch,
7592
ScopeResolverInterface $scopeResolver,
7693
array $data = [],
77-
$batchSize = self::DEFAULT_BATCH_SIZE
94+
$batchSize = self::DEFAULT_BATCH_SIZE,
95+
?DeploymentConfig $deploymentConfig = null
7896
) {
7997
$this->indexStructure = $indexStructure;
8098
$this->adapter = $adapter;
@@ -83,6 +101,7 @@ public function __construct(
83101
$this->data = $data;
84102
$this->batchSize = $batchSize;
85103
$this->scopeResolver = $scopeResolver;
104+
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->get(DeploymentConfig::class);
86105
}
87106

88107
/**
@@ -92,6 +111,11 @@ public function saveIndex($dimensions, \Traversable $documents)
92111
{
93112
$dimension = current($dimensions);
94113
$scopeId = $this->scopeResolver->getScope($dimension->getValue())->getId();
114+
115+
$this->batchSize = $this->deploymentConfig->get(
116+
self::DEPLOYMENT_CONFIG_INDEXER_BATCHES . Fulltext::INDEXER_ID . '/elastic_save'
117+
) ?? $this->batchSize;
118+
95119
foreach ($this->batch->getItems($documents, $this->batchSize) as $documentsBatch) {
96120
$docs = $this->adapter->prepareDocsPerStore($documentsBatch, $scopeId);
97121
$this->adapter->addDocs($docs, $scopeId, $this->getIndexerId());

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,25 @@ public function validate(HttpRequestInterface $request) : void
3131
/** @var Http $request */
3232
if (false === $request->isPost()) {
3333
$query = $request->getParam('query', '');
34-
$operationType = null;
35-
$queryAst = \GraphQL\Language\Parser::parse(new \GraphQL\Language\Source($query ?: '', 'GraphQL'));
36-
\GraphQL\Language\Visitor::visit(
37-
$queryAst,
38-
[
39-
'leave' => [
40-
NodeKind::OPERATION_DEFINITION => function (Node $node) use (&$operationType) {
41-
$operationType = $node->operation;
42-
}
34+
if (!empty($query)) {
35+
$operationType = null;
36+
$queryAst = \GraphQL\Language\Parser::parse(new \GraphQL\Language\Source($query ?: '', 'GraphQL'));
37+
\GraphQL\Language\Visitor::visit(
38+
$queryAst,
39+
[
40+
'leave' => [
41+
NodeKind::OPERATION_DEFINITION => function (Node $node) use (&$operationType) {
42+
$operationType = $node->operation;
43+
}
44+
]
4345
]
44-
]
45-
);
46-
47-
if (strtolower($operationType) === 'mutation') {
48-
throw new GraphQlInputException(
49-
new \Magento\Framework\Phrase('Mutation requests allowed only for POST requests')
5046
);
47+
48+
if (strtolower($operationType) === 'mutation') {
49+
throw new GraphQlInputException(
50+
new \Magento\Framework\Phrase('Mutation requests allowed only for POST requests')
51+
);
52+
}
5153
}
5254
}
5355
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GraphQl\Test\Unit\Controller\HttpRequestValidator;
9+
10+
use Magento\Framework\App\HttpRequestInterface;
11+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
12+
use Magento\GraphQl\Controller\HttpRequestValidator\HttpVerbValidator;
13+
use PHPUnit\Framework\MockObject\MockObject;
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* Test HttpVerbValidator
18+
*/
19+
class HttpVerbValidatorTest extends TestCase
20+
{
21+
/**
22+
* @var HttpVerbValidator|MockObject
23+
*/
24+
private $httpVerbValidator;
25+
26+
/**
27+
* @var HttpRequestInterface|MockObject
28+
*/
29+
private $requestMock;
30+
31+
/**
32+
* @inheritDoc
33+
*/
34+
protected function setup(): void
35+
{
36+
$objectManager = new ObjectManager($this);
37+
$this->requestMock = $this->getMockBuilder(HttpRequestInterface::class)
38+
->disableOriginalConstructor()
39+
->onlyMethods(
40+
[
41+
'isPost',
42+
]
43+
)->addMethods(
44+
[
45+
'getParam',
46+
]
47+
)
48+
->getMockForAbstractClass();
49+
50+
$this->httpVerbValidator = $objectManager->getObject(
51+
HttpVerbValidator::class
52+
);
53+
}
54+
55+
/**
56+
* Test for validate method
57+
*
58+
* @param string $query
59+
* @param bool $needException
60+
* @dataProvider validateDataProvider
61+
*/
62+
public function testValidate(string $query, bool $needException): void
63+
{
64+
$this->requestMock
65+
->expects($this->once())
66+
->method('isPost')
67+
->willReturn(false);
68+
69+
$this->requestMock
70+
->method('getParam')
71+
->with('query', '')
72+
->willReturn($query);
73+
74+
if ($needException) {
75+
$this->expectExceptionMessage('Syntax Error: Unexpected <EOF>');
76+
}
77+
78+
$this->httpVerbValidator->validate($this->requestMock);
79+
}
80+
81+
/**
82+
* @return array
83+
*/
84+
public function validateDataProvider(): array
85+
{
86+
return [
87+
[
88+
'query' => '',
89+
'needException' => false,
90+
],
91+
[
92+
'query' => ' ',
93+
'needException' => true
94+
],
95+
];
96+
}
97+
}

0 commit comments

Comments
 (0)