Skip to content

Commit 8478bdb

Browse files
author
Yevhen Miroshnychenko
authored
Merge pull request #2178 from magento-thunder/MAGETWO-72760
Fixed issues: - MAGETWO-72760: 2.2.0-RC21: Omitting --base_url breaks site (not getting host:port from "Host" header correctly)
2 parents 8c4ba3c + 89d919d commit 8478bdb

File tree

6 files changed

+32
-22
lines changed

6 files changed

+32
-22
lines changed

app/code/Magento/Config/App/Config/Type/System.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function get($path = '')
141141
$pathParts = explode('/', $path);
142142
if (count($pathParts) === 1 && $pathParts[0] !== 'default') {
143143
if (!isset($this->data[$pathParts[0]])) {
144-
$data = $this->reader->read();
144+
$data = $this->readData();
145145
$this->data = array_replace_recursive($data, $this->data);
146146
}
147147
return $this->data[$pathParts[0]];
@@ -171,7 +171,7 @@ private function loadAllData()
171171
{
172172
$cachedData = $this->cache->load($this->configType);
173173
if ($cachedData === false) {
174-
$data = $this->reader->read();
174+
$data = $this->readData();
175175
} else {
176176
$data = $this->serializer->unserialize($cachedData);
177177
}
@@ -188,7 +188,7 @@ private function loadDefaultScopeData($scopeType)
188188
{
189189
$cachedData = $this->cache->load($this->configType . '_' . $scopeType);
190190
if ($cachedData === false) {
191-
$data = $this->reader->read();
191+
$data = $this->readData();
192192
$this->cacheData($data);
193193
} else {
194194
$data = [$scopeType => $this->serializer->unserialize($cachedData)];
@@ -216,7 +216,7 @@ private function loadScopeData($scopeType, $scopeId)
216216
if (is_array($this->availableDataScopes) && !isset($this->availableDataScopes[$scopeType][$scopeId])) {
217217
return [$scopeType => [$scopeId => []]];
218218
}
219-
$data = $this->reader->read();
219+
$data = $this->readData();
220220
$this->cacheData($data);
221221
} else {
222222
$data = [$scopeType => [$scopeId => $this->serializer->unserialize($cachedData)]];
@@ -282,6 +282,21 @@ private function getDataByPathParts($data, $pathParts)
282282
return $data;
283283
}
284284

285+
/**
286+
* The freshly read data.
287+
*
288+
* @return array
289+
*/
290+
private function readData(): array
291+
{
292+
$this->data = $this->reader->read();
293+
$this->data = $this->postProcessor->process(
294+
$this->data
295+
);
296+
297+
return $this->data;
298+
}
299+
285300
/**
286301
* Clean cache and global variables cache
287302
*

app/code/Magento/Config/App/Config/Type/System/Reader.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@ class Reader
2727
*/
2828
private $preProcessor;
2929

30-
/**
31-
* @var \Magento\Framework\App\Config\Spi\PostProcessorInterface
32-
*/
33-
private $postProcessor;
34-
3530
/**
3631
* Reader constructor.
3732
* @param \Magento\Framework\App\Config\ConfigSourceInterface $source
3833
* @param \Magento\Store\Model\Config\Processor\Fallback $fallback
3934
* @param \Magento\Framework\App\Config\Spi\PreProcessorInterface $preProcessor
4035
* @param \Magento\Framework\App\Config\Spi\PostProcessorInterface $postProcessor
36+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4137
*/
4238
public function __construct(
4339
\Magento\Framework\App\Config\ConfigSourceInterface $source,
@@ -48,7 +44,6 @@ public function __construct(
4844
$this->source = $source;
4945
$this->fallback = $fallback;
5046
$this->preProcessor = $preProcessor;
51-
$this->postProcessor = $postProcessor;
5247
}
5348

5449
/**
@@ -60,11 +55,9 @@ public function __construct(
6055
*/
6156
public function read()
6257
{
63-
return $this->postProcessor->process(
64-
$this->fallback->process(
65-
$this->preProcessor->process(
66-
$this->source->get()
67-
)
58+
return $this->fallback->process(
59+
$this->preProcessor->process(
60+
$this->source->get()
6861
)
6962
);
7063
}

app/code/Magento/Config/Test/Unit/App/Config/Type/System/ReaderTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ public function testGetCachedWithLoadDefaultScopeData()
8484
->method('process')
8585
->with($data)
8686
->willReturn($data);
87-
$this->postProcessor->expects($this->once())
88-
->method('process')
89-
->with($data)
90-
->willReturn($data);
9187
$this->assertEquals($data, $this->model->read());
9288
}
9389
}

app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,12 @@ public function testGetNotCached()
170170
$this->reader->expects($this->once())
171171
->method('read')
172172
->willReturn($data);
173+
$this->postProcessor->expects($this->once())
174+
->method('process')
175+
->with($data)
176+
->willReturn($data);
173177

174178
$this->assertEquals($url, $this->configType->get($path));
179+
$this->assertEquals($url, $this->configType->get($path));
175180
}
176181
}

app/code/Magento/Store/Model/Config/Placeholder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ protected function _processPlaceholders($value, $data)
9191
if ($url) {
9292
$value = str_replace('{{' . $placeholder . '}}', $url, $value);
9393
} elseif (strpos($value, $this->urlPlaceholder) !== false) {
94-
// localhost is replaced for cli requests, for http requests method getDistroBaseUrl is used
95-
$value = str_replace($this->urlPlaceholder, 'http://localhost/', $value);
94+
$distroBaseUrl = $this->request->getDistroBaseUrl();
95+
96+
$value = str_replace($this->urlPlaceholder, $distroBaseUrl, $value);
9697
}
9798

9899
if (null !== $this->_getPlaceholder($value)) {

app/code/Magento/Store/Test/Unit/Model/Config/PlaceholderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function setUp()
2323
{
2424
$this->_requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class);
2525
$this->_requestMock->expects(
26-
$this->any()
26+
$this->once()
2727
)->method(
2828
'getDistroBaseUrl'
2929
)->will(

0 commit comments

Comments
 (0)