Skip to content

Commit e9c505e

Browse files
Merge branch 'application-server' of github.com:magento-performance/magento2ce into ACPT-1544
2 parents 29ccc86 + 6701fc9 commit e9c505e

File tree

23 files changed

+1057
-359
lines changed

23 files changed

+1057
-359
lines changed

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ private function getStoreIdByCode(string $storeCode): int
780780
if (!isset($this->storeCodeToId[$storeCode])) {
781781
/** @var $store Store */
782782
foreach ($this->storeManager->getStores() as $store) {
783-
$this->storeCodeToId[$store->getCode()] = $store->getId();
783+
$this->storeCodeToId[$store->getCode()] = (int)$store->getId();
784784
}
785785
}
786786

app/code/Magento/Customer/Model/ResourceModel/Customer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function __construct(
112112
$this->storeManager = $storeManager;
113113
$this->encryptor = $encryptor ?? ObjectManager::getInstance()
114114
->get(EncryptorInterface::class);
115+
$this->getEntityIdField();
115116
}
116117

117118
/**

app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ class Table extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource im
4242
/**
4343
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory
4444
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory
45+
* @param StoreManagerInterface|null $storeManager
4546
* @codeCoverageIgnore
4647
*/
4748
public function __construct(
4849
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory,
49-
\Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory
50+
\Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory,
51+
StoreManagerInterface $storeManager = null
5052
) {
5153
$this->_attrOptionCollectionFactory = $attrOptionCollectionFactory;
5254
$this->_attrOptionFactory = $attrOptionFactory;
55+
$this->storeManager = $storeManager ?? ObjectManager::getInstance()->get(StoreManagerInterface::class);
5356
}
5457

5558
/**
@@ -63,7 +66,7 @@ public function getAllOptions($withEmpty = true, $defaultValues = false)
6366
{
6467
$storeId = $this->getAttribute()->getStoreId();
6568
if ($storeId === null) {
66-
$storeId = $this->getStoreManager()->getStore()->getId();
69+
$storeId = $this->storeManager->getStore()->getId();
6770
}
6871
if (!is_array($this->_options)) {
6972
$this->_options = [];
@@ -93,21 +96,6 @@ public function getAllOptions($withEmpty = true, $defaultValues = false)
9396
return $options;
9497
}
9598

96-
/**
97-
* Get StoreManager dependency
98-
*
99-
* @return StoreManagerInterface
100-
* @deprecated 100.1.6
101-
* @see we don't recommend this approach anymore
102-
*/
103-
private function getStoreManager()
104-
{
105-
if ($this->storeManager === null) {
106-
$this->storeManager = ObjectManager::getInstance()->get(StoreManagerInterface::class);
107-
}
108-
return $this->storeManager;
109-
}
110-
11199
/**
112100
* Retrieve Option values array by ids
113101
*

app/code/Magento/Eav/etc/di.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,10 @@
221221
<argument name="cache" xsi:type="object">configured_eav_cache</argument>
222222
</arguments>
223223
</type>
224+
225+
<type name="Magento\Eav\Model\Entity\Attribute\Source\Table">
226+
<arguments>
227+
<argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManagerInterface\Proxy</argument>
228+
</arguments>
229+
</type>
224230
</config>

app/code/Magento/Theme/Model/Theme/ThemeProvider.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,20 @@ class ThemeProvider implements \Magento\Framework\View\Design\Theme\ThemeProvide
5757
* @param \Magento\Theme\Model\ThemeFactory $themeFactory
5858
* @param \Magento\Framework\App\CacheInterface $cache
5959
* @param Json $serializer
60+
* @param DeploymentConfig|null $deploymentConfig
6061
*/
6162
public function __construct(
6263
\Magento\Theme\Model\ResourceModel\Theme\CollectionFactory $collectionFactory,
6364
\Magento\Theme\Model\ThemeFactory $themeFactory,
6465
\Magento\Framework\App\CacheInterface $cache,
65-
Json $serializer = null
66+
Json $serializer = null,
67+
DeploymentConfig $deploymentConfig = null
6668
) {
6769
$this->collectionFactory = $collectionFactory;
6870
$this->themeFactory = $themeFactory;
6971
$this->cache = $cache;
7072
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
73+
$this->deploymentConfig = $deploymentConfig ?? ObjectManager::getInstance()->get(DeploymentConfig::class);
7174
}
7275

7376
/**
@@ -79,7 +82,7 @@ public function getThemeByFullPath($fullPath)
7982
return $this->themes[$fullPath];
8083
}
8184

82-
if (! $this->getDeploymentConfig()->isDbAvailable()) {
85+
if (! $this->deploymentConfig->isDbAvailable()) {
8386
return $this->getThemeList()->getThemeByFullPath($fullPath);
8487
}
8588

@@ -179,18 +182,4 @@ private function getThemeList()
179182
}
180183
return $this->themeList;
181184
}
182-
183-
/**
184-
* Get deployment config
185-
*
186-
* @deprecated 100.1.3
187-
* @return DeploymentConfig
188-
*/
189-
private function getDeploymentConfig()
190-
{
191-
if ($this->deploymentConfig === null) {
192-
$this->deploymentConfig = ObjectManager::getInstance()->get(DeploymentConfig::class);
193-
}
194-
return $this->deploymentConfig;
195-
}
196185
}

app/code/Magento/Theme/Test/Unit/Model/Theme/ThemeProviderTest.php

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Framework\App\Area;
1111
use Magento\Framework\App\CacheInterface;
1212
use Magento\Framework\App\DeploymentConfig;
13-
use Magento\Framework\ObjectManagerInterface;
1413
use Magento\Framework\Serialize\Serializer\Json;
1514
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1615
use Magento\Framework\View\Design\ThemeInterface;
@@ -31,21 +30,24 @@ class ThemeProviderTest extends TestCase
3130
/** Theme ID used by tests */
3231
const THEME_ID = 755;
3332

34-
/** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */
33+
/** @var ObjectManagerHelper */
3534
private $objectManager;
3635

37-
/** @var \Magento\Theme\Model\ResourceModel\Theme\CollectionFactory|MockObject */
36+
/** @var \Magento\Theme\Model\ResourceModel\Theme\CollectionFactory&MockObject */
3837
private $collectionFactory;
3938

40-
/** @var \Magento\Theme\Model\ThemeFactory|MockObject */
39+
/** @var \Magento\Theme\Model\ThemeFactory&MockObject */
4140
private $themeFactory;
4241

43-
/** @var CacheInterface|MockObject */
42+
/** @var CacheInterface&MockObject */
4443
private $cache;
4544

46-
/** @var Json|MockObject */
45+
/** @var Json&MockObject */
4746
private $serializer;
4847

48+
/** @var DeploymentConfig&MockObject */
49+
private DeploymentConfig $deploymentConfig;
50+
4951
/** @var ThemeProvider|MockObject */
5052
private $themeProvider;
5153

@@ -64,13 +66,17 @@ protected function setUp(): void
6466
->disableOriginalConstructor()
6567
->getMockForAbstractClass();
6668
$this->serializer = $this->createMock(Json::class);
69+
$this->deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
70+
->disableOriginalConstructor()
71+
->getMock();
6772
$this->themeProvider = $this->objectManager->getObject(
6873
ThemeProvider::class,
6974
[
7075
'collectionFactory' => $this->collectionFactory,
7176
'themeFactory' => $this->themeFactory,
7277
'cache' => $this->cache,
73-
'serializer' => $this->serializer
78+
'serializer' => $this->serializer,
79+
'deploymentConfig' => $this->deploymentConfig,
7480
]
7581
);
7682
$this->theme = $this->createMock(Theme::class);
@@ -85,7 +91,6 @@ public function testGetByFullPath()
8591
$this->theme->expects($this->exactly(2))
8692
->method('toArray')
8793
->willReturn($themeArray);
88-
8994
$collectionMock = $this->createMock(Collection::class);
9095
$collectionMock->expects($this->once())
9196
->method('getThemeByFullPath')
@@ -98,22 +103,9 @@ public function testGetByFullPath()
98103
->method('serialize')
99104
->with($themeArray)
100105
->willReturn('serialized theme');
101-
102-
$deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
103-
->disableOriginalConstructor()
104-
->getMock();
105-
$deploymentConfig->expects($this->once())
106+
$this->deploymentConfig->expects($this->once())
106107
->method('isDbAvailable')
107108
->willReturn(true);
108-
109-
$objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
110-
$objectManagerMock->expects($this->any())
111-
->method('get')
112-
->willReturnMap([
113-
[DeploymentConfig::class, $deploymentConfig],
114-
]);
115-
\Magento\Framework\App\ObjectManager::setInstance($objectManagerMock);
116-
117109
$this->assertSame(
118110
$this->theme,
119111
$this->themeProvider->getThemeByFullPath(self::THEME_PATH),
@@ -128,21 +120,9 @@ public function testGetByFullPath()
128120

129121
public function testGetByFullPathWithCache()
130122
{
131-
$deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
132-
->disableOriginalConstructor()
133-
->getMock();
134-
$deploymentConfig->expects($this->once())
123+
$this->deploymentConfig->expects($this->once())
135124
->method('isDbAvailable')
136125
->willReturn(true);
137-
138-
$objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
139-
$objectManagerMock->expects($this->any())
140-
->method('get')
141-
->willReturnMap([
142-
[DeploymentConfig::class, $deploymentConfig],
143-
]);
144-
\Magento\Framework\App\ObjectManager::setInstance($objectManagerMock);
145-
146126
$serializedTheme = '{"theme_data":"theme_data"}';
147127
$themeArray = ['theme_data' => 'theme_data'];
148128
$this->theme->expects($this->once())
@@ -152,17 +132,14 @@ public function testGetByFullPathWithCache()
152132
$this->themeFactory->expects($this->once())
153133
->method('create')
154134
->willReturn($this->theme);
155-
156135
$this->serializer->expects($this->once())
157136
->method('unserialize')
158137
->with($serializedTheme)
159138
->willReturn($themeArray);
160-
161139
$this->cache->expects($this->once())
162140
->method('load')
163141
->with('theme' . self::THEME_PATH)
164142
->willReturn($serializedTheme);
165-
166143
$this->assertSame(
167144
$this->theme,
168145
$this->themeProvider->getThemeByFullPath(self::THEME_PATH),

app/code/Magento/Theme/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@
312312
<type name="Magento\Theme\Model\Theme\ThemeProvider">
313313
<arguments>
314314
<argument name="cache" xsi:type="object">configured_design_cache</argument>
315+
<argument name="deploymentConfig" xsi:type="object">Magento\Framework\App\DeploymentConfig\Proxy</argument>
315316
</arguments>
316317
</type>
317318
<type name="Magento\Theme\Model\Theme\StoreThemesResolver">

dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private function clearMappedTableNames()
7777
$reflection = new \ReflectionClass($resourceConnection);
7878
$dataProperty = $reflection->getProperty('mappedTableNames');
7979
$dataProperty->setAccessible(true);
80-
$dataProperty->setValue($resourceConnection, null);
80+
$dataProperty->setValue($resourceConnection, []);
8181
}
8282
}
8383

dev/tests/integration/testsuite/Magento/Framework/ObjectManager/ResetAfterRequestTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Framework\ObjectManager;
79

810
use Magento\Framework\App\Utility\Classes;
@@ -11,6 +13,7 @@
1113
use Magento\Framework\ObjectManagerInterface;
1214
use Magento\GraphQl\App\State\Collector;
1315
use Magento\GraphQl\App\State\Comparator;
16+
use Magento\GraphQl\App\State\CompareType;
1417

1518
/**
1619
* Test that verifies that resetState method for classes cause the state to be the same as it was initially constructed
@@ -27,7 +30,7 @@ class ResetAfterRequestTest extends \PHPUnit\Framework\TestCase
2730
private ?Collector $collector;
2831

2932
/**
30-
* @return void
33+
* @inheritDoc
3134
*/
3235
protected function setUp(): void
3336
{
@@ -42,6 +45,8 @@ protected function setUp(): void
4245
*
4346
* @return array
4447
* @magentoAppIsolation enabled
48+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
49+
* @SuppressWarnings(PHPMD.NPathComplexity)
4550
*/
4651
public function resetAfterRequestClassDataProvider()
4752
{
@@ -107,6 +112,8 @@ public function resetAfterRequestClassDataProvider()
107112
* @dataProvider resetAfterRequestClassDataProvider
108113
* @magentoAppArea graphql
109114
* @magentoDbIsolation disabled
115+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
116+
* @SuppressWarnings(PHPMD.NPathComplexity)
110117
*/
111118
public function testResetAfterRequestClasses(string $className)
112119
{
@@ -151,9 +158,9 @@ public function testResetAfterRequestClasses(string $className)
151158
}
152159
try {
153160
/** @var ResetAfterRequestInterface $object */
154-
$beforeProperties = $this->collector->getPropertiesFromObject($object, true);
161+
$beforeProperties = $this->collector->getPropertiesFromObject($object, CompareType::CompareBetweenRequests);
155162
$object->_resetState();
156-
$afterProperties = $this->collector->getPropertiesFromObject($object, true);
163+
$afterProperties = $this->collector->getPropertiesFromObject($object, CompareType::CompareBetweenRequests);
157164
$differences = [];
158165
foreach ($afterProperties as $propertyName => $propertyValue) {
159166
if ($propertyValue instanceof ObjectManagerInterface) {

0 commit comments

Comments
 (0)