Skip to content

Commit 7c7461a

Browse files
authored
Merge pull request #8315 from magento-l3/AC-8862
AC-8862: Config path which contains capital letters doesn't return value
2 parents bcacf65 + 492bdfa commit 7c7461a

File tree

11 files changed

+17
-270
lines changed

11 files changed

+17
-270
lines changed

app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,8 @@ public function getPlaceholderValue($path, $scope, $scopeCode = null)
102102
public function getEnvValue($placeholder)
103103
{
104104
// phpcs:disable Magento2.Security.Superglobal
105-
$environment = [];
106-
foreach ($_ENV as $key => $value) {
107-
$environment[strtolower($key)] = $value;
108-
}
109-
if ($this->placeholder->isApplicable($placeholder) && isset($environment[strtolower($placeholder)])) {
110-
return $environment[strtolower($placeholder)];
105+
if ($this->placeholder->isApplicable($placeholder) && isset($_ENV[$placeholder])) {
106+
return $_ENV[$placeholder];
111107
}
112108
// phpcs:enable
113109

app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/SettingCheckerTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ protected function setUp(): void
6969
$this->checker = new SettingChecker($this->configMock, $placeholderFactoryMock, $this->scopeCodeResolverMock);
7070
}
7171

72-
public function testGetEnvValue(): void
73-
{
74-
$_ENV = array_merge($this->env, ['SOME_PLACEHOLDER' => 0, 'another_placeholder' => 1, 'some_placeholder' => 1]);
75-
$this->placeholderMock->expects($this->any())
76-
->method('isApplicable')
77-
->willReturn(true);
78-
$this->assertSame($this->checker->getEnvValue('SOME_PLACEHOLDER'), 1);
79-
$this->assertSame($this->checker->getEnvValue('another_placeholder'), 1);
80-
}
81-
8272
/**
8373
* @param string $path
8474
* @param string $scope

app/code/Magento/Store/App/Config/Source/RuntimeConfigSource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private function getEntities($table, $keyField)
102102
);
103103

104104
foreach ($entities as $entity) {
105-
$data[strtolower($entity[$keyField])] = $entity;
105+
$data[$entity[$keyField]] = $entity;
106106
}
107107

108108
return $data;

app/code/Magento/Store/App/Config/Type/Scopes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function get($path = '')
7272
$path = $this->convertIdPathToCodePath($patchChunks);
7373
}
7474

75-
return $this->data->getData(strtolower($path));
75+
return $this->data->getData($path);
7676
}
7777

7878
/**

app/code/Magento/Store/Model/Config/Processor/Fallback.php

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
use Magento\Framework\DB\Adapter\TableNotFoundException;
1212
use Magento\Store\App\Config\Type\Scopes;
1313
use Magento\Store\Model\ResourceModel\Store;
14+
use Magento\Store\Model\ResourceModel\Store\AllStoresCollectionFactory;
1415
use Magento\Store\Model\ResourceModel\Website;
16+
use Magento\Store\Model\ResourceModel\Website\AllWebsitesCollection;
17+
use Magento\Store\Model\ResourceModel\Website\AllWebsitesCollectionFactory;
1518

1619
/**
1720
* Fallback through different scopes and merge them
@@ -111,13 +114,6 @@ private function prepareWebsitesConfig(
111114
array $websitesConfig
112115
) {
113116
$result = [];
114-
115-
foreach ($websitesConfig as $websiteCode => $webConfiguration) {
116-
if (!isset($websitesConfig[strtolower($websiteCode)])) {
117-
$websitesConfig[strtolower($websiteCode)] = $webConfiguration;
118-
unset($websitesConfig[$websiteCode]);
119-
}
120-
}
121117
foreach ((array)$this->websiteData as $website) {
122118
$code = $website['code'];
123119
$id = $website['website_id'];
@@ -143,12 +139,6 @@ private function prepareStoresConfig(
143139
) {
144140
$result = [];
145141

146-
foreach ($storesConfig as $storeCode => $storeConfiguration) {
147-
if (!isset($storesConfig[strtolower($storeCode)])) {
148-
$storesConfig[strtolower($storeCode)] = $storeConfiguration;
149-
unset($storesConfig[$storeCode]);
150-
}
151-
}
152142
foreach ((array)$this->storeData as $store) {
153143
$code = $store['code'];
154144
$id = $store['store_id'];
@@ -201,18 +191,5 @@ private function loadScopes(): void
201191
$this->storeData = [];
202192
$this->websiteData = [];
203193
}
204-
$this->normalizeStoreData();
205-
}
206-
207-
/**
208-
* Sets stores code to lower case
209-
*
210-
* @return void
211-
*/
212-
private function normalizeStoreData(): void
213-
{
214-
foreach ($this->storeData as $key => $store) {
215-
$this->storeData[$key]['code'] = strtolower($store['code']);
216-
}
217194
}
218195
}

app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -68,73 +68,12 @@ public function testGet()
6868
->getMock();
6969
$selectMock->expects($this->any())->method('from')->willReturnSelf();
7070
$this->connection->expects($this->any())->method('select')->willReturn($selectMock);
71-
$this->connection->expects($this->exactly(3))->method('fetchAll')
72-
->willReturnOnConsecutiveCalls(
73-
[
74-
'WebsiteCode' => [
75-
'website_id' => '3',
76-
'code' => 'WebsiteCode',
77-
'name' => 'website',
78-
'sort_order' => '0',
79-
'default_group_id' => '4',
80-
'is_default' => '0'
81-
]
82-
],
83-
[
84-
0 => [
85-
'group_id' => '4',
86-
'website_id' => '3',
87-
'name' => 'store',
88-
'root_category_id' => '2',
89-
'default_store_id' => '11',
90-
'code' => 'second_website'
91-
]
92-
],
93-
[
94-
'SecondWebsite' => [
95-
'store_id' => '11',
96-
'code' => 'SECOND_WEBSITE',
97-
'website_id' => '3',
98-
'group_id' => '4',
99-
'name' => 'second',
100-
'sort_order' => '0',
101-
'is_active' => '1'
102-
]
103-
]
104-
);
71+
$this->connection->expects($this->any())->method('fetchAll')->willReturn([]);
10572
$this->assertEquals(
10673
[
107-
'websites' => [
108-
'websitecode' => [
109-
'website_id' => '3',
110-
'code' => 'WebsiteCode',
111-
'name' => 'website',
112-
'sort_order' => '0',
113-
'default_group_id' => '4',
114-
'is_default' => '0'
115-
]
116-
],
117-
'groups' => [
118-
4 => [
119-
'group_id' => '4',
120-
'website_id' => '3',
121-
'name' => 'store',
122-
'root_category_id' => '2',
123-
'default_store_id' => '11',
124-
'code' => 'second_website'
125-
]
126-
],
127-
'stores' => [
128-
'second_website' => [
129-
'store_id' => '11',
130-
'code' => 'SECOND_WEBSITE',
131-
'website_id' => '3',
132-
'group_id' => '4',
133-
'name' => 'second',
134-
'sort_order' => '0',
135-
'is_active' => '1'
136-
]
137-
],
74+
'websites' => [],
75+
'groups' => [],
76+
'stores' => [],
13877
],
13978
$this->configSource->get()
14079
);

app/code/Magento/Store/Test/Unit/Model/Config/Processor/FallbackTest.php

Lines changed: 0 additions & 154 deletions
This file was deleted.

lib/internal/Magento/Framework/App/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
/**
3+
*
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
@@ -125,7 +126,6 @@ public function clean()
125126
*/
126127
public function get($configType, $path = '', $default = null)
127128
{
128-
$path = strtolower($path);
129129
$result = null;
130130
if (isset($this->types[$configType])) {
131131
$result = $this->types[$configType]->get($path);

lib/internal/Magento/Framework/App/Config/ScopeCodeResolver.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ public function resolve($scopeType, $scopeCode)
5959
$scopeCode = $resolverScopeCode;
6060
}
6161

62-
$this->resolvedScopeCodes[$scopeType][$scopeCode] =
63-
is_null($resolverScopeCode) ? null : strtolower($resolverScopeCode);
62+
$this->resolvedScopeCodes[$scopeType][$scopeCode] = $resolverScopeCode;
6463

65-
return $this->resolvedScopeCodes[$scopeType][$scopeCode];
64+
return $resolverScopeCode;
6665
}
6766

6867
/**

lib/internal/Magento/Framework/App/Test/Unit/Config/ScopeCodeResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ public function testResolve()
6767
$this->scope->expects($this->once())
6868
->method('getCode')
6969
->willReturn($scopeCode);
70-
$this->assertEquals(strtolower($scopeCode), $this->scopeCodeResolver->resolve($scopeType, $scopeId));
70+
$this->assertEquals($scopeCode, $this->scopeCodeResolver->resolve($scopeType, $scopeId));
7171
}
7272
}

lib/internal/Magento/Framework/App/Test/Unit/ConfigTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testGetValue($scope, $scopeCode = null)
7171
}
7272
$this->configType->expects($this->once())
7373
->method('get')
74-
->with($scope =='store' ? 'stores/path' : 'websites/mywebsite/path')
74+
->with($scope =='store' ? 'stores/path' : 'websites/myWebsite/path')
7575
->willReturn(true);
7676

7777
$this->assertTrue($this->appConfig->getValue($path, $scope, $scopeCode ?: $this->scope));
@@ -84,7 +84,7 @@ public function getValueDataProvider()
8484
{
8585
return [
8686
['store', 1],
87-
['website']
87+
['website'],
8888
];
8989
}
9090
}

0 commit comments

Comments
 (0)