Skip to content

Commit 625c38f

Browse files
ACPT-1929: Fixing race conditions in ACPT-1493
1 parent af2e988 commit 625c38f

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

lib/internal/Magento/Framework/ObjectManager/Resetter/Resetter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,18 @@ class Resetter implements ResetterInterface
3737
private array $reflectionCache = [];
3838

3939
/**
40-
* @param ComponentRegistrarInterface $componentRegistrar
40+
* @param ComponentRegistrarInterface|null $componentRegistrar
4141
* @param array $classList
4242
* @return void
4343
* @phpcs:disable Magento2.Functions.DiscouragedFunction
4444
*/
4545
public function __construct(
46-
private ComponentRegistrarInterface $componentRegistrar,
46+
private ?ComponentRegistrarInterface $componentRegistrar = null,
4747
private array $classList = [],
4848
) {
49+
if (null === $componentRegistrar) {
50+
$componentRegistrar = new ComponentRegistrar();
51+
}
4952
foreach ($this->getPaths() as $resetPath) {
5053
if (!\file_exists($resetPath)) {
5154
continue;

lib/internal/Magento/Framework/ObjectManager/Resetter/ResetterFactory.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Magento\Framework\ObjectManager\Resetter;
99

10-
use Magento\Framework\ObjectManagerInterface;
11-
1210
/**
1311
* Factory that creates Resetter based on environment variable.
1412
*/
@@ -19,21 +17,15 @@ class ResetterFactory
1917
*/
2018
private static string $resetterClassName = Resetter::class;
2119

22-
/**
23-
* @param ObjectManagerInterface $objectManager
24-
*/
25-
public function __construct(private ObjectManagerInterface $objectManager)
26-
{
27-
}
28-
2920
/**
3021
* Create resseter instance
3122
*
3223
* @return ResetterInterface
24+
* @phpcs:disable Magento2.Functions.StaticFunction
3325
*/
34-
public function create() : ResetterInterface
26+
public static function create() : ResetterInterface
3527
{
36-
return $this->objectManager->create(static::$resetterClassName);
28+
return new static::$resetterClassName;
3729
}
3830

3931
/**

lib/internal/Magento/Framework/TestFramework/ApplicationStateComparator/Resetter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class Resetter extends OriginalResetter
3434
/**
3535
* Constructor
3636
*
37-
* @param ComponentRegistrarInterface $componentRegistrar
37+
* @param ComponentRegistrarInterface|null $componentRegistrar
3838
* @param array $classList
3939
* @return void
4040
*/
41-
public function __construct(ComponentRegistrarInterface $componentRegistrar, array $classList = [])
41+
public function __construct(?ComponentRegistrarInterface $componentRegistrar = null, array $classList = [])
4242
{
4343
$this->collectedWeakMap = new WeakMap;
4444
$this->skipListAndFilterList = new SkipListAndFilterList;

0 commit comments

Comments
 (0)