Skip to content

Commit ac81526

Browse files
authored
Merge pull request #27 from magento-commerce/develop
MCLOUD-7915: Release 1.0.10
2 parents 3397d3b + c32358a commit ac81526

13 files changed

+152
-27
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"name": "magento/magento-cloud-patches",
33
"description": "Provides critical fixes for Magento 2 Enterprise Edition",
44
"type": "magento2-component",
5-
"version": "1.0.9",
5+
"version": "1.0.10",
66
"license": "OSL-3.0",
77
"require": {
88
"php": "^7.0",
99
"ext-json": "*",
1010
"composer/composer": "@stable",
11-
"composer/semver": "^1.5",
11+
"composer/semver": "^1.5||^2.0||^3.0",
1212
"symfony/config": "^3.3||^4.4||^5.1",
1313
"symfony/console": "^2.6||^4.0||^5.1",
1414
"symfony/dependency-injection": "^3.3||^4.3||^5.1",

patches/MCLOUD-6923__layered_navigation_filter_is_present_only_when_product_is_present_on_the_listing_page_with_enabled_shared_catalog__2.3.5.patch

+81-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,64 @@
11
diff -Nuar a/vendor/magento/module-shared-catalog/Model/SearchAdapter/Aggregation/Builder/DataProvider.php b/vendor/magento/module-shared-catalog/Model/SearchAdapter/Aggregation/Builder/DataProvider.php
2+
index 86f4fd48e9..a6061fca6f 100644
23
--- a/vendor/magento/module-shared-catalog/Model/SearchAdapter/Aggregation/Builder/DataProvider.php
34
+++ b/vendor/magento/module-shared-catalog/Model/SearchAdapter/Aggregation/Builder/DataProvider.php
4-
@@ -103,18 +103,16 @@ public function __construct(
5+
@@ -7,6 +7,8 @@ declare(strict_types=1);
6+
7+
namespace Magento\SharedCatalog\Model\SearchAdapter\Aggregation\Builder;
8+
9+
+use Magento\Catalog\Model\Layer;
10+
+use Magento\Catalog\Model\Layer\Resolver;
11+
use Magento\Catalog\Model\Product;
12+
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
13+
use Magento\CatalogInventory\Model\Configuration;
14+
@@ -14,6 +16,7 @@ use Magento\CatalogInventory\Model\Stock;
15+
use Magento\Customer\Model\Session;
16+
use Magento\Eav\Model\Config as EavConfig;
17+
use Magento\Framework\App\Config\ScopeConfigInterface;
18+
+use Magento\Framework\App\ObjectManager;
19+
use Magento\Framework\App\ResourceConnection;
20+
use Magento\Framework\App\ScopeResolverInterface;
21+
use Magento\Framework\DB\Adapter\AdapterInterface;
22+
@@ -70,6 +73,11 @@ class DataProvider
23+
*/
24+
private $productItem;
25+
26+
+ /**
27+
+ * @var Layer
28+
+ */
29+
+ private $searchLayer;
30+
+
31+
/**
32+
* @param ResourceConnection $resource
33+
* @param Session $session
34+
@@ -78,6 +86,7 @@ class DataProvider
35+
* @param EavConfig $eavConfig
36+
* @param ProductResource $product
37+
* @param ProductItemResource $productItem
38+
+ * @param Resolver|null $layerResolver
39+
*/
40+
public function __construct(
41+
ResourceConnection $resource,
42+
@@ -86,7 +95,8 @@ class DataProvider
43+
ScopeConfigInterface $scopeConfig,
44+
EavConfig $eavConfig,
45+
ProductResource $product,
46+
- ProductItemResource $productItem
47+
+ ProductItemResource $productItem,
48+
+ ?Resolver $layerResolver = null
49+
) {
50+
$this->resource = $resource;
51+
$this->connection = $resource->getConnection();
52+
@@ -96,6 +106,8 @@ class DataProvider
53+
$this->eavConfig = $eavConfig;
54+
$this->product = $product;
55+
$this->productItem = $productItem;
56+
+ $layerResolver = $layerResolver ?? ObjectManager::getInstance()->get(Resolver::class);
57+
+ $this->searchLayer = $layerResolver->get();
58+
}
59+
60+
/**
61+
@@ -103,18 +115,16 @@ class DataProvider
562
*
663
* @param BucketInterface $bucket
764
* @param array $dimensions
@@ -20,9 +77,9 @@ diff -Nuar a/vendor/magento/module-shared-catalog/Model/SearchAdapter/Aggregatio
2077
- $select = $this->getSelect($bucket, $dimensions, $documentIds);
2178
+ $select = $this->getSelect($bucket, $dimensions);
2279
$query = $this->connection->query($select);
23-
80+
2481
while ($row = $query->fetch()) {
25-
@@ -134,11 +132,10 @@ public function getAggregation(
82+
@@ -134,15 +144,15 @@ class DataProvider
2683
*
2784
* @param BucketInterface $bucket
2885
* @param array $dimensions
@@ -35,24 +92,39 @@ diff -Nuar a/vendor/magento/module-shared-catalog/Model/SearchAdapter/Aggregatio
3592
{
3693
$attribute = $this->eavConfig->getAttribute(Product::ENTITY, $bucket->getField());
3794
$currentScope = $this->scopeResolver->getScope($dimensions['scope']->getValue());
38-
@@ -161,7 +158,6 @@ private function getSelect(BucketInterface $bucket, array $dimensions, array $do
95+
$customerGroupId = $this->session->getCustomerGroupId();
96+
+ $categoryId = $this->searchLayer->getCurrentCategory()->getId();
97+
98+
$eavIndexTable = $this->resource->getTableName(
99+
'catalog_product_index_eav' . ($attribute->getBackendType() === 'decimal' ? '_decimal' : '')
100+
@@ -160,11 +170,14 @@ class DataProvider
101+
['shared_catalog_item' => $this->productItem->getMainTable()],
39102
'source_entity.sku = shared_catalog_item.sku',
40103
[]
104+
+ )->joinInner(
105+
+ ['catalog_category_product' => $this->resource->getTableName('catalog_category_product')],
106+
+ 'eav.entity_id = catalog_category_product.product_id',
107+
+ []
41108
)
42109
- ->where('eav.entity_id IN (?)', $documentIds)
43110
->where('eav.attribute_id = ?', $attribute->getId())
44111
->where('eav.store_id = ? ', $currentScope->getId())
45-
->where('source_entity.type_id <> ?', 'configurable')
46-
diff -Nuar a/vendor/magento/module-shared-catalog/Plugin/Elasticsearch/SearchAdapter/Aggregation/Builder/UpdateTermBucketBuilderPlugin.php b/vendor/magento/module-shared-catalog/Plugin/Elasticsearch/SearchAdapter/Aggregation/Builder/UpdateTermBucketBuilderPlugin.php
112+
- ->where('source_entity.type_id <> ?', 'configurable')
113+
+ ->where('catalog_category_product.category_id = ?', $categoryId)
114+
->where('shared_catalog_item.customer_group_id = ?', $customerGroupId);
115+
116+
$this->addStockFilterToSelect($subSelect);
117+
diff --git a/vendor/magento/module-shared-catalog/Plugin/Elasticsearch/SearchAdapter/Aggregation/Builder/UpdateTermBucketBuilderPlugin.php b/vendor/magento/module-shared-catalog/Plugin/Elasticsearch/SearchAdapter/Aggregation/Builder/UpdateTermBucketBuilderPlugin.php
118+
index fdc811dbeb..28b1cd4ee4 100644
47119
--- a/vendor/magento/module-shared-catalog/Plugin/Elasticsearch/SearchAdapter/Aggregation/Builder/UpdateTermBucketBuilderPlugin.php
48120
+++ b/vendor/magento/module-shared-catalog/Plugin/Elasticsearch/SearchAdapter/Aggregation/Builder/UpdateTermBucketBuilderPlugin.php
49-
@@ -65,8 +65,7 @@ public function afterBuild(
121+
@@ -65,8 +65,7 @@ class UpdateTermBucketBuilderPlugin
50122
$shouldAggregate = ($bucket->getField() !== 'category_ids');
51-
123+
52124
if ($sharedCatalogIsEnabled && $shouldAggregate) {
53125
- $documentIds = array_column($queryResult['hits']['hits'], '_id');
54126
- $values = $this->dataProvider->getAggregation($bucket, $dimensions, $documentIds);
55127
+ $values = $this->dataProvider->getAggregation($bucket, $dimensions);
56128
}
57-
129+
58130
return $values;

src/Command/Apply.php

+2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ public function execute(InputInterface $input, OutputInterface $output)
8888
try {
8989
$this->applyOptional->run($input, $output);
9090
} catch (RuntimeException $e) {
91+
$output->writeln($this->magentoVersion->get());
9192
$output->writeln('<error>' . $e->getMessage() . '</error>');
93+
9294
$this->logger->info($this->magentoVersion->get());
9395
$this->logger->error($e->getMessage());
9496

src/Command/Ece/Apply.php

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function execute(InputInterface $input, OutputInterface $output)
9898
$this->applyOptional->run($input, $output);
9999
$this->applyLocal->run($input, $output);
100100
} catch (RuntimeException $e) {
101+
$output->writeln($this->magentoVersion->get());
101102
$output->writeln('<error>' . $e->getMessage() . '</error>');
102103
$this->logger->info($this->magentoVersion->get());
103104
$this->logger->error($e->getMessage());

src/Command/Ece/Revert.php

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function execute(InputInterface $input, OutputInterface $output)
7878
try {
7979
$this->revert->run($input, $output);
8080
} catch (RuntimeException $e) {
81+
$output->writeln($this->magentoVersion->get());
8182
$output->writeln('<error>' . $e->getMessage() . '</error>');
8283
$this->logger->info($this->magentoVersion->get());
8384
$this->logger->error($e->getMessage());

src/Command/Process/Action/ProcessDeprecatedAction.php

+20-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
use Magento\CloudPatches\App\RuntimeException;
1111
use Magento\CloudPatches\Command\Process\Renderer;
12-
use Magento\CloudPatches\Patch\Data\AggregatedPatch;
1312
use Magento\CloudPatches\Patch\Data\AggregatedPatchInterface;
1413
use Magento\CloudPatches\Patch\Pool\OptionalPool;
1514
use Magento\CloudPatches\Patch\Aggregator;
@@ -93,6 +92,13 @@ public function execute(InputInterface $input, OutputInterface $output, array $p
9392
throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
9493
}
9594

95+
$patches = array_filter(
96+
$patches,
97+
function ($patch) {
98+
return !$this->statusPool->isApplied($patch->getId());
99+
}
100+
);
101+
96102
foreach ($patches as $patch) {
97103
$this->processDeprecation($patch, $output, $input);
98104
$this->processReplacement($patch, $output, $input);
@@ -144,21 +150,23 @@ function ($patchId) {
144150
}
145151
);
146152

147-
if ($requireRevertAndReplace) {
148-
$ids = implode(' ', $requireRevertAndReplace);
149-
$warning = sprintf('%s should be reverted and replaced with %s', $ids, $patch->getId());
150-
$output->writeln('<info>' . $warning . '</info>');
151-
$this->logger->warning($warning);
153+
if (empty($requireRevertAndReplace)) {
154+
return;
155+
}
152156

153-
$question = 'Do you want to proceed with reverting?';
154-
if (!$this->renderer->printQuestion($input, $output, $question)) {
155-
$errorMessage = sprintf('%s can\'t be applied without reverting %s', $patch->getId(), $ids);
157+
$ids = implode(' ', $requireRevertAndReplace);
158+
$warning = sprintf('%s should be reverted and replaced with %s', $ids, $patch->getId());
159+
$output->writeln('<info>' . $warning . '</info>');
160+
$this->logger->warning($warning);
156161

157-
throw new RuntimeException($errorMessage);
158-
}
162+
$question = 'Do you want to proceed with reverting?';
163+
if (!$this->renderer->printQuestion($input, $output, $question)) {
164+
$errorMessage = sprintf('%s can\'t be applied without reverting %s', $patch->getId(), $ids);
159165

160-
$this->revert->execute($input, $output, $requireRevertAndReplace);
166+
throw new RuntimeException($errorMessage);
161167
}
168+
169+
$this->revert->execute($input, $output, $requireRevertAndReplace);
162170
}
163171

164172
/**

src/Command/Process/ApplyLocal.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function run(InputInterface $input, OutputInterface $output)
8989
$this->printInfo($output, $message);
9090
array_push($appliedPatches, $patch);
9191
} catch (ApplierException $exception) {
92-
$this->printError($output, 'Error: patch can\'t be applied');
92+
$this->printError($output, 'Error: patch ' . $patch->getPath() . ' can\'t be applied');
9393
$messages = $this->rollbackProcessor->process($appliedPatches);
9494
$output->writeln($messages);
9595
$errorMessage = sprintf(

src/Command/Revert.php

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function execute(InputInterface $input, OutputInterface $output)
101101
try {
102102
$this->revert->run($input, $output);
103103
} catch (RuntimeException $e) {
104+
$output->writeln($this->magentoVersion->get());
104105
$output->writeln('<error>' . $e->getMessage() . '</error>');
105106
$this->logger->info($this->magentoVersion->get());
106107
$this->logger->error($e->getMessage());

src/Patch/Conflict/Processor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function process(
7373
array $appliedPatches,
7474
string $exceptionMessage
7575
) {
76-
$errorMessage = 'Error: patch can\'t be applied';
76+
$errorMessage = 'Error: patch ' . $patch->getId() . ' can\'t be applied';
7777
$this->logger->error($errorMessage);
7878
$output->writeln('<error>' . $errorMessage . '</error>');
7979

src/Test/Functional/Acceptance/Acceptance73Cest.php

+3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ protected function patchesDataProvider(): array
2424
['templateVersion' => '2.3.4', 'magentoVersion' => '2.3.4-p2'],
2525
['templateVersion' => '2.3.5', 'magentoVersion' => '2.3.5'],
2626
['templateVersion' => '2.3.5', 'magentoVersion' => '2.3.5-p1'],
27+
['templateVersion' => '2.3.5', 'magentoVersion' => '2.3.5-p2'],
2728
['templateVersion' => '2.3.6', 'magentoVersion' => '2.3.6'],
29+
['templateVersion' => '2.3.6', 'magentoVersion' => '2.3.6-p1'],
30+
['templateVersion' => '2.3.6', 'magentoVersion' => '2.3.7'],
2831
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0'],
2932
];
3033
}

src/Test/Functional/Acceptance/AcceptanceCest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ protected function patchesDataProvider(): array
5151
return [
5252
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0'],
5353
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0-p1'],
54-
['templateVersion' => '2.4.1'],
54+
['templateVersion' => '2.4.1', 'magentoVersion' => '2.4.1'],
55+
['templateVersion' => '2.4.1', 'magentoVersion' => '2.4.1-p1'],
56+
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2'],
57+
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2-p1'],
5558
['templateVersion' => 'master'],
5659
];
5760
}

src/Test/Unit/Command/Process/Action/ProcessDeprecatedActionTest.php

+34
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,40 @@ public function testProcessReplacementSuccessful()
208208
$this->action->execute($inputMock, $outputMock, $patchFilter);
209209
}
210210

211+
/**
212+
* Tests successful skipping of replacement check when patch is already applied.
213+
*/
214+
public function testSkippingReplacementProcessForAppliedPatch()
215+
{
216+
$patch1 = $this->createPatch('MC-11111', false);
217+
$this->statusPool->method('isApplied')
218+
->willReturnMap([
219+
['MC-11111', true]
220+
]);
221+
$patchFilter = [$patch1->getId()];
222+
223+
/** @var InputInterface|MockObject $inputMock */
224+
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
225+
/** @var OutputInterface|MockObject $outputMock */
226+
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);
227+
228+
$patchMock = $this->getMockForAbstractClass(PatchInterface::class);
229+
230+
$this->optionalPool->expects($this->once())
231+
->method('getList')
232+
->withConsecutive([$patchFilter])
233+
->willReturn([$patchMock]);
234+
235+
$this->aggregator->expects($this->once())
236+
->method('aggregate')
237+
->willReturn([$patch1]);
238+
239+
$this->renderer->expects($this->never())
240+
->method('printQuestion');
241+
242+
$this->action->execute($inputMock, $outputMock, $patchFilter);
243+
}
244+
211245
/**
212246
* Tests a case when user rejected to revert deprecated patches before applying a new one.
213247
*/

src/Test/Unit/Patch/Conflict/ProcessorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testProcess()
9292
$outputMock->expects($this->exactly(2))
9393
->method('writeln')
9494
->withConsecutive(
95-
[$this->stringContains('Error: patch can\'t be applied')],
95+
[$this->stringContains('Error: patch ' . $failedPatch->getId() . ' can\'t be applied')],
9696
[$rollbackMessages]
9797
);
9898

0 commit comments

Comments
 (0)