Skip to content

Commit 951bcb3

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-70971' into MAGETWO-70971
2 parents 5018f86 + 2003a5c commit 951bcb3

File tree

10 files changed

+68
-30
lines changed

10 files changed

+68
-30
lines changed

app/code/Magento/Bundle/etc/db_schema.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545
<constraint xsi:type="foreign" name="CAT_PRD_BNDL_OPT_VAL_OPT_ID_CAT_PRD_BNDL_OPT_OPT_ID"
4646
table="catalog_product_bundle_option_value" column="option_id"
4747
referenceTable="catalog_product_bundle_option" referenceColumn="option_id" onDelete="CASCADE"/>
48-
<constraint xsi:type="unique" name="CATALOG_PRODUCT_BUNDLE_OPTION_VALUE_OPTION_ID_STORE_ID">
49-
<column name="option_id"/>
50-
<column name="store_id"/>
51-
</constraint>
5248
<constraint xsi:type="unique" name="CAT_PRD_BNDL_OPT_VAL_OPT_ID_PARENT_PRD_ID_STORE_ID">
5349
<column name="option_id"/>
5450
<column name="parent_product_id"/>

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(

lib/internal/Magento/Framework/Module/Dir/Reader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ public function getComposerJsonFiles()
105105
*/
106106
private function getFilesIterator($filename, $subDir = '')
107107
{
108-
#if (!isset($this->fileIterators[$subDir][$filename])) {
108+
if (!isset($this->fileIterators[$subDir][$filename])) {
109109
$this->fileIterators[$subDir][$filename] = $this->fileIteratorFactory->create(
110110
$this->getFiles($filename, $subDir)
111111
);
112-
#}
112+
}
113113
return $this->fileIterators[$subDir][$filename];
114114
}
115115

lib/internal/Magento/Framework/Setup/Patch/PatchApplier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use Magento\Framework\Module\ModuleResource;
1111
use Magento\Framework\ObjectManagerInterface;
1212
use Magento\Framework\Phrase;
13-
use Magento\Framework\Setup\ModuleDataSetupInterface;
1413
use Magento\Framework\Setup\Exception;
14+
use Magento\Framework\Setup\ModuleDataSetupInterface;
1515

1616
/**
1717
* Apply patches per specific module

setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,21 @@ public function __construct(\Magento\Setup\Module\Di\Compiler\Log\Log $log)
3030
*/
3131
public function collectEntities(array $files)
3232
{
33+
$virtualTypes = [];
3334
$output = [];
35+
$factoriesOutput = [];
3436
foreach ($files as $file) {
3537
$dom = new \DOMDocument();
3638
$dom->load($file);
3739
$xpath = new \DOMXPath($dom);
3840
$xpath->registerNamespace("php", "http://php.net/xpath");
3941
$xpath->registerPhpFunctions('preg_match');
42+
$virtualTypeQuery = "//virtualType/@name";
43+
44+
foreach ($xpath->query($virtualTypeQuery) as $virtualNode) {
45+
$virtualTypes[] = $virtualNode->nodeValue;
46+
}
47+
4048
$regex = '/^(.*)\\\(.*)Proxy$/';
4149
$query = "/config/preference[ php:functionString('preg_match', '{$regex}', @type) > 0]/@type | " .
4250
"//argument[@xsi:type='object' and php:functionString('preg_match', '{$regex}', text()) > 0] |" .
@@ -46,9 +54,33 @@ public function collectEntities(array $files)
4654
foreach ($xpath->query($query) as $node) {
4755
$output[] = $node->nodeValue;
4856
}
57+
58+
$factoriesOutput = array_merge($factoriesOutput, $this->scanFactories($xpath));
4959
}
60+
5061
$output = array_unique($output);
51-
return $this->_filterEntities($output);
62+
$factoriesOutput = array_unique($factoriesOutput);
63+
$factoriesOutput = array_diff($factoriesOutput, $virtualTypes);
64+
return array_merge($this->_filterEntities($output), $factoriesOutput);
65+
}
66+
67+
/**
68+
* Scan factories from all di.xml and retrieve non virtual one
69+
*
70+
* @param \DOMXPath $domXpath
71+
* @return array
72+
*/
73+
private function scanFactories(\DOMXPath $domXpath)
74+
{
75+
$output = [];
76+
$regex = '/^(.*)Factory$/';
77+
$query = "//argument[@xsi:type='object' and php:functionString('preg_match', '{$regex}', text()) > 0] |" .
78+
"//item[@xsi:type='object' and php:functionString('preg_match', '{$regex}', text()) > 0]";
79+
foreach ($domXpath->query($query) as $node) {
80+
$output[] = $node->nodeValue;
81+
}
82+
83+
return $output;
5284
}
5385

5486
/**

0 commit comments

Comments
 (0)