Skip to content

Commit

Permalink
Merge pull request #27 from magento-commerce/develop
Browse files Browse the repository at this point in the history
MCLOUD-7915: Release 1.0.10
  • Loading branch information
oshmyheliuk authored May 5, 2021
2 parents 3397d3b + c32358a commit ac81526
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 27 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "magento/magento-cloud-patches",

This comment has been minimized.

Copy link
@ihor-sviziev

ihor-sviziev May 11, 2021

@oshmyheliuk @mmansoor-magento this commit isn't available in any branch. Could you double-check it?

This comment has been minimized.

Copy link
@oshmyheliuk

oshmyheliuk May 11, 2021

Author Contributor

^ @BaDos

This comment has been minimized.

Copy link
@oshmyheliuk

oshmyheliuk May 11, 2021

Author Contributor

@ihor-sviziev Looks like the branch wasn't synced for a while with the internal repository. Will fix it shortly.

This comment has been minimized.

Copy link
@oshmyheliuk

oshmyheliuk May 11, 2021

Author Contributor

@ihor-sviziev The branch was synced, now you can see that commit is available in 1.0 branch.
Thanks for paying attention.

This comment has been minimized.

Copy link
@ihor-sviziev

ihor-sviziev May 12, 2021

@oshmyheliuk what about the develop branch?

This comment has been minimized.

Copy link
@oshmyheliuk

oshmyheliuk May 12, 2021

Author Contributor

Develop branch was synced before. There was an issue with 1.0 but now it should be fine.

"description": "Provides critical fixes for Magento 2 Enterprise Edition",
"type": "magento2-component",
"version": "1.0.9",
"version": "1.0.10",
"license": "OSL-3.0",
"require": {
"php": "^7.0",
"ext-json": "*",
"composer/composer": "@stable",
"composer/semver": "^1.5",
"composer/semver": "^1.5||^2.0||^3.0",
"symfony/config": "^3.3||^4.4||^5.1",
"symfony/console": "^2.6||^4.0||^5.1",
"symfony/dependency-injection": "^3.3||^4.3||^5.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,64 @@
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
index 86f4fd48e9..a6061fca6f 100644
--- a/vendor/magento/module-shared-catalog/Model/SearchAdapter/Aggregation/Builder/DataProvider.php
+++ b/vendor/magento/module-shared-catalog/Model/SearchAdapter/Aggregation/Builder/DataProvider.php
@@ -103,18 +103,16 @@ public function __construct(
@@ -7,6 +7,8 @@ declare(strict_types=1);

namespace Magento\SharedCatalog\Model\SearchAdapter\Aggregation\Builder;

+use Magento\Catalog\Model\Layer;
+use Magento\Catalog\Model\Layer\Resolver;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
use Magento\CatalogInventory\Model\Configuration;
@@ -14,6 +16,7 @@ use Magento\CatalogInventory\Model\Stock;
use Magento\Customer\Model\Session;
use Magento\Eav\Model\Config as EavConfig;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\App\ScopeResolverInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;
@@ -70,6 +73,11 @@ class DataProvider
*/
private $productItem;

+ /**
+ * @var Layer
+ */
+ private $searchLayer;
+
/**
* @param ResourceConnection $resource
* @param Session $session
@@ -78,6 +86,7 @@ class DataProvider
* @param EavConfig $eavConfig
* @param ProductResource $product
* @param ProductItemResource $productItem
+ * @param Resolver|null $layerResolver
*/
public function __construct(
ResourceConnection $resource,
@@ -86,7 +95,8 @@ class DataProvider
ScopeConfigInterface $scopeConfig,
EavConfig $eavConfig,
ProductResource $product,
- ProductItemResource $productItem
+ ProductItemResource $productItem,
+ ?Resolver $layerResolver = null
) {
$this->resource = $resource;
$this->connection = $resource->getConnection();
@@ -96,6 +106,8 @@ class DataProvider
$this->eavConfig = $eavConfig;
$this->product = $product;
$this->productItem = $productItem;
+ $layerResolver = $layerResolver ?? ObjectManager::getInstance()->get(Resolver::class);
+ $this->searchLayer = $layerResolver->get();
}

/**
@@ -103,18 +115,16 @@ class DataProvider
*
* @param BucketInterface $bucket
* @param array $dimensions
Expand All @@ -20,9 +77,9 @@ diff -Nuar a/vendor/magento/module-shared-catalog/Model/SearchAdapter/Aggregatio
- $select = $this->getSelect($bucket, $dimensions, $documentIds);
+ $select = $this->getSelect($bucket, $dimensions);
$query = $this->connection->query($select);

while ($row = $query->fetch()) {
@@ -134,11 +132,10 @@ public function getAggregation(
@@ -134,15 +144,15 @@ class DataProvider
*
* @param BucketInterface $bucket
* @param array $dimensions
Expand All @@ -35,24 +92,39 @@ diff -Nuar a/vendor/magento/module-shared-catalog/Model/SearchAdapter/Aggregatio
{
$attribute = $this->eavConfig->getAttribute(Product::ENTITY, $bucket->getField());
$currentScope = $this->scopeResolver->getScope($dimensions['scope']->getValue());
@@ -161,7 +158,6 @@ private function getSelect(BucketInterface $bucket, array $dimensions, array $do
$customerGroupId = $this->session->getCustomerGroupId();
+ $categoryId = $this->searchLayer->getCurrentCategory()->getId();

$eavIndexTable = $this->resource->getTableName(
'catalog_product_index_eav' . ($attribute->getBackendType() === 'decimal' ? '_decimal' : '')
@@ -160,11 +170,14 @@ class DataProvider
['shared_catalog_item' => $this->productItem->getMainTable()],
'source_entity.sku = shared_catalog_item.sku',
[]
+ )->joinInner(
+ ['catalog_category_product' => $this->resource->getTableName('catalog_category_product')],
+ 'eav.entity_id = catalog_category_product.product_id',
+ []
)
- ->where('eav.entity_id IN (?)', $documentIds)
->where('eav.attribute_id = ?', $attribute->getId())
->where('eav.store_id = ? ', $currentScope->getId())
->where('source_entity.type_id <> ?', 'configurable')
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
- ->where('source_entity.type_id <> ?', 'configurable')
+ ->where('catalog_category_product.category_id = ?', $categoryId)
->where('shared_catalog_item.customer_group_id = ?', $customerGroupId);

$this->addStockFilterToSelect($subSelect);
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
index fdc811dbeb..28b1cd4ee4 100644
--- 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
@@ -65,8 +65,7 @@ public function afterBuild(
@@ -65,8 +65,7 @@ class UpdateTermBucketBuilderPlugin
$shouldAggregate = ($bucket->getField() !== 'category_ids');

if ($sharedCatalogIsEnabled && $shouldAggregate) {
- $documentIds = array_column($queryResult['hits']['hits'], '_id');
- $values = $this->dataProvider->getAggregation($bucket, $dimensions, $documentIds);
+ $values = $this->dataProvider->getAggregation($bucket, $dimensions);
}

return $values;
2 changes: 2 additions & 0 deletions src/Command/Apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public function execute(InputInterface $input, OutputInterface $output)
try {
$this->applyOptional->run($input, $output);
} catch (RuntimeException $e) {
$output->writeln($this->magentoVersion->get());
$output->writeln('<error>' . $e->getMessage() . '</error>');

$this->logger->info($this->magentoVersion->get());
$this->logger->error($e->getMessage());

Expand Down
1 change: 1 addition & 0 deletions src/Command/Ece/Apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$this->applyOptional->run($input, $output);
$this->applyLocal->run($input, $output);
} catch (RuntimeException $e) {
$output->writeln($this->magentoVersion->get());
$output->writeln('<error>' . $e->getMessage() . '</error>');
$this->logger->info($this->magentoVersion->get());
$this->logger->error($e->getMessage());
Expand Down
1 change: 1 addition & 0 deletions src/Command/Ece/Revert.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function execute(InputInterface $input, OutputInterface $output)
try {
$this->revert->run($input, $output);
} catch (RuntimeException $e) {
$output->writeln($this->magentoVersion->get());
$output->writeln('<error>' . $e->getMessage() . '</error>');
$this->logger->info($this->magentoVersion->get());
$this->logger->error($e->getMessage());
Expand Down
32 changes: 20 additions & 12 deletions src/Command/Process/Action/ProcessDeprecatedAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use Magento\CloudPatches\App\RuntimeException;
use Magento\CloudPatches\Command\Process\Renderer;
use Magento\CloudPatches\Patch\Data\AggregatedPatch;
use Magento\CloudPatches\Patch\Data\AggregatedPatchInterface;
use Magento\CloudPatches\Patch\Pool\OptionalPool;
use Magento\CloudPatches\Patch\Aggregator;
Expand Down Expand Up @@ -93,6 +92,13 @@ public function execute(InputInterface $input, OutputInterface $output, array $p
throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
}

$patches = array_filter(
$patches,
function ($patch) {
return !$this->statusPool->isApplied($patch->getId());
}
);

foreach ($patches as $patch) {
$this->processDeprecation($patch, $output, $input);
$this->processReplacement($patch, $output, $input);
Expand Down Expand Up @@ -144,21 +150,23 @@ function ($patchId) {
}
);

if ($requireRevertAndReplace) {
$ids = implode(' ', $requireRevertAndReplace);
$warning = sprintf('%s should be reverted and replaced with %s', $ids, $patch->getId());
$output->writeln('<info>' . $warning . '</info>');
$this->logger->warning($warning);
if (empty($requireRevertAndReplace)) {
return;
}

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

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

$this->revert->execute($input, $output, $requireRevertAndReplace);
throw new RuntimeException($errorMessage);
}

$this->revert->execute($input, $output, $requireRevertAndReplace);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Process/ApplyLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function run(InputInterface $input, OutputInterface $output)
$this->printInfo($output, $message);
array_push($appliedPatches, $patch);
} catch (ApplierException $exception) {
$this->printError($output, 'Error: patch can\'t be applied');
$this->printError($output, 'Error: patch ' . $patch->getPath() . ' can\'t be applied');
$messages = $this->rollbackProcessor->process($appliedPatches);
$output->writeln($messages);
$errorMessage = sprintf(
Expand Down
1 change: 1 addition & 0 deletions src/Command/Revert.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public function execute(InputInterface $input, OutputInterface $output)
try {
$this->revert->run($input, $output);
} catch (RuntimeException $e) {
$output->writeln($this->magentoVersion->get());
$output->writeln('<error>' . $e->getMessage() . '</error>');
$this->logger->info($this->magentoVersion->get());
$this->logger->error($e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion src/Patch/Conflict/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function process(
array $appliedPatches,
string $exceptionMessage
) {
$errorMessage = 'Error: patch can\'t be applied';
$errorMessage = 'Error: patch ' . $patch->getId() . ' can\'t be applied';
$this->logger->error($errorMessage);
$output->writeln('<error>' . $errorMessage . '</error>');

Expand Down
3 changes: 3 additions & 0 deletions src/Test/Functional/Acceptance/Acceptance73Cest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ protected function patchesDataProvider(): array
['templateVersion' => '2.3.4', 'magentoVersion' => '2.3.4-p2'],
['templateVersion' => '2.3.5', 'magentoVersion' => '2.3.5'],
['templateVersion' => '2.3.5', 'magentoVersion' => '2.3.5-p1'],
['templateVersion' => '2.3.5', 'magentoVersion' => '2.3.5-p2'],
['templateVersion' => '2.3.6', 'magentoVersion' => '2.3.6'],
['templateVersion' => '2.3.6', 'magentoVersion' => '2.3.6-p1'],
['templateVersion' => '2.3.6', 'magentoVersion' => '2.3.7'],
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0'],
];
}
Expand Down
5 changes: 4 additions & 1 deletion src/Test/Functional/Acceptance/AcceptanceCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ protected function patchesDataProvider(): array
return [
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0'],
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0-p1'],
['templateVersion' => '2.4.1'],
['templateVersion' => '2.4.1', 'magentoVersion' => '2.4.1'],
['templateVersion' => '2.4.1', 'magentoVersion' => '2.4.1-p1'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2-p1'],
['templateVersion' => 'master'],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,40 @@ public function testProcessReplacementSuccessful()
$this->action->execute($inputMock, $outputMock, $patchFilter);
}

/**
* Tests successful skipping of replacement check when patch is already applied.
*/
public function testSkippingReplacementProcessForAppliedPatch()
{
$patch1 = $this->createPatch('MC-11111', false);
$this->statusPool->method('isApplied')
->willReturnMap([
['MC-11111', true]
]);
$patchFilter = [$patch1->getId()];

/** @var InputInterface|MockObject $inputMock */
$inputMock = $this->getMockForAbstractClass(InputInterface::class);
/** @var OutputInterface|MockObject $outputMock */
$outputMock = $this->getMockForAbstractClass(OutputInterface::class);

$patchMock = $this->getMockForAbstractClass(PatchInterface::class);

$this->optionalPool->expects($this->once())
->method('getList')
->withConsecutive([$patchFilter])
->willReturn([$patchMock]);

$this->aggregator->expects($this->once())
->method('aggregate')
->willReturn([$patch1]);

$this->renderer->expects($this->never())
->method('printQuestion');

$this->action->execute($inputMock, $outputMock, $patchFilter);
}

/**
* Tests a case when user rejected to revert deprecated patches before applying a new one.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Unit/Patch/Conflict/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function testProcess()
$outputMock->expects($this->exactly(2))
->method('writeln')
->withConsecutive(
[$this->stringContains('Error: patch can\'t be applied')],
[$this->stringContains('Error: patch ' . $failedPatch->getId() . ' can\'t be applied')],
[$rollbackMessages]
);

Expand Down

0 comments on commit ac81526

Please sign in to comment.