Skip to content

Commit 652e119

Browse files
Merge branch '2.4-develop' into 04-29-24-Tier4-Bugfix-Delivery
2 parents d15e826 + 4d520b5 commit 652e119

File tree

5 files changed

+101
-6
lines changed

5 files changed

+101
-6
lines changed

app/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,4 +2006,5 @@
20062006
<preference for="Magento\Framework\Filter\Input\PurifierInterface" type="Magento\Framework\Filter\Input\Purifier"/>
20072007
<preference for="Magento\Framework\App\PageCache\IdentifierInterface" type="Magento\Framework\App\PageCache\Identifier"/>
20082008
<preference for="Magento\Framework\App\State\ReloadProcessorInterface" type="Magento\Framework\App\State\ReloadProcessorComposite" />
2009+
<preference for="Magento\Framework\Indexer\Config\Converter\SortingAdjustmentInterface" type="Magento\Framework\Indexer\Config\Converter\SortingAdjustment" />
20092010
</config>

lib/internal/Magento/Framework/Indexer/Config/Converter.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,23 @@
88
use Magento\Framework\Config\ConverterInterface;
99
use Magento\Framework\Exception\ConfigurationMismatchException;
1010
use Magento\Framework\Phrase;
11+
use Magento\Framework\Indexer\Config\Converter\SortingAdjustmentInterface;
1112

1213
class Converter implements ConverterInterface
1314
{
15+
/**
16+
* @var SortingAdjustmentInterface
17+
*/
18+
private SortingAdjustmentInterface $sortingAdjustment;
19+
20+
/**
21+
* @param SortingAdjustmentInterface $sortingAdjustment
22+
*/
23+
public function __construct(SortingAdjustmentInterface $sortingAdjustment)
24+
{
25+
$this->sortingAdjustment = $sortingAdjustment;
26+
}
27+
1428
/**
1529
* Convert dom node tree to array
1630
*
@@ -47,8 +61,7 @@ public function convert($source)
4761
$output[$indexerId] = $data;
4862
}
4963
$output = $this->sortByDependencies($output);
50-
51-
return $output;
64+
return $this->sortingAdjustment->adjust($output);
5265
}
5366

5467
/**
@@ -239,6 +252,7 @@ protected function convertField(\DOMElement $node, $data)
239252
* @param \DOMNode $node
240253
* @return string
241254
* @deprecated 101.0.0
255+
* @see not used anymore
242256
*/
243257
protected function getTranslatedNodeValue(\DOMNode $node)
244258
{
@@ -334,6 +348,7 @@ private function expandDependencies(array $list, string $indexerId, array $accum
334348
{
335349
$accumulated[] = $indexerId;
336350
$result = $list[$indexerId]['dependencies'] ?? [];
351+
$addedResult = [];
337352
foreach ($result as $relatedIndexerId) {
338353
if (in_array($relatedIndexerId, $accumulated)) {
339354
throw new ConfigurationMismatchException(
@@ -359,8 +374,9 @@ private function expandDependencies(array $list, string $indexerId, array $accum
359374
);
360375
}
361376
$relatedResult = $this->expandDependencies($list, $relatedIndexerId, $accumulated);
362-
$result = array_unique(array_merge($result, $relatedResult));
377+
$addedResult[] = $relatedResult;
363378
}
364-
return $result;
379+
$result = array_merge($result, ...$addedResult);
380+
return array_unique($result);
365381
}
366382
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/************************************************************************
3+
*
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* ************************************************************************
16+
*/
17+
declare(strict_types=1);
18+
19+
namespace Magento\Framework\Indexer\Config\Converter;
20+
21+
class SortingAdjustment implements SortingAdjustmentInterface
22+
{
23+
/**
24+
* @inheritDoc
25+
*/
26+
public function adjust(array $indexersList): array
27+
{
28+
return $indexersList;
29+
}
30+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/************************************************************************
3+
*
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* ************************************************************************
16+
*/
17+
declare(strict_types=1);
18+
19+
namespace Magento\Framework\Indexer\Config\Converter;
20+
21+
/**
22+
* Interface for managing sort order of indexers
23+
*
24+
* Make sense for the full reindex when you need to adjust order od indexers execution
25+
*/
26+
interface SortingAdjustmentInterface
27+
{
28+
/**
29+
* Make adjustments in the indexers list
30+
*
31+
* @param array $indexersList
32+
* @return array
33+
*/
34+
public function adjust(array $indexersList) : array;
35+
}

lib/internal/Magento/Framework/Indexer/Test/Unit/Config/ConverterTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,32 @@
99

1010
use Magento\Framework\Exception\ConfigurationMismatchException;
1111
use Magento\Framework\Indexer\Config\Converter;
12+
use Magento\Framework\Indexer\Config\Converter\SortingAdjustmentInterface;
1213
use PHPUnit\Framework\MockObject\MockObject;
1314
use PHPUnit\Framework\TestCase;
1415

1516
class ConverterTest extends TestCase
1617
{
1718
/**
18-
* @var Converter|MockObject
19+
* @var Converter
1920
*/
2021
protected $_model;
2122

23+
/**
24+
* @var SortingAdjustmentInterface|MockObject
25+
*/
26+
private $sortingAdjustment;
27+
2228
protected function setUp(): void
2329
{
24-
$this->_model = new Converter();
30+
$this->sortingAdjustment = $this->getMockBuilder(SortingAdjustmentInterface::class)
31+
->getMockForAbstractClass();
32+
$this->sortingAdjustment->method("adjust")->will(
33+
$this->returnCallback(function ($arg) {
34+
return $arg;
35+
})
36+
);
37+
$this->_model = new Converter($this->sortingAdjustment);
2538
}
2639

2740
public function testConvert()

0 commit comments

Comments
 (0)