Skip to content

Commit f547c35

Browse files
committed
Merge remote-tracking branch 'falcon/MAGETWO-56675' into MAGETWO-60931
2 parents c8ca9fa + 7d324d9 commit f547c35

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

lib/internal/Magento/Framework/Interception/PluginList/PluginList.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,27 +276,26 @@ protected function _loadScopedData()
276276
$data = $this->_cache->load($cacheId);
277277
if ($data) {
278278
list($this->_data, $this->_inherited, $this->_processed) = unserialize($data);
279-
foreach ($this->_scopePriorityScheme as $scope) {
280-
$this->_loadedScopes[$scope] = true;
279+
foreach ($this->_scopePriorityScheme as $scopeCode) {
280+
$this->_loadedScopes[$scopeCode] = true;
281281
}
282282
} else {
283283
$virtualTypes = [];
284284
foreach ($this->_scopePriorityScheme as $scopeCode) {
285285
if (false == isset($this->_loadedScopes[$scopeCode])) {
286286
$data = $this->_reader->read($scopeCode);
287287
unset($data['preferences']);
288-
if (!count($data)) {
289-
continue;
290-
}
291-
$this->_inherited = [];
292-
$this->_processed = [];
293-
$this->merge($data);
294-
$this->_loadedScopes[$scopeCode] = true;
295-
foreach ($data as $class => $config) {
296-
if (isset($config['type'])) {
297-
$virtualTypes[] = $class;
288+
if (count($data) > 0) {
289+
$this->_inherited = [];
290+
$this->_processed = [];
291+
$this->merge($data);
292+
foreach ($data as $class => $config) {
293+
if (isset($config['type'])) {
294+
$virtualTypes[] = $class;
295+
}
298296
}
299297
}
298+
$this->_loadedScopes[$scopeCode] = true;
300299
}
301300
if ($this->isCurrentScope($scopeCode)) {
302301
break;

lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,33 @@ public function testLoadScopedDataCached()
256256

257257
$this->assertEquals(null, $this->_model->getNext('Type', 'method'));
258258
}
259+
260+
/**
261+
* @covers \Magento\Framework\Interception\PluginList\PluginList::getNext
262+
* @covers \Magento\Framework\Interception\PluginList\PluginList::_loadScopedData
263+
*/
264+
public function testLoadScopeDataWithEmptyData()
265+
{
266+
$this->_objectManagerMock->expects($this->any())
267+
->method('get')
268+
->will($this->returnArgument(0));
269+
$this->_configScopeMock->expects($this->any())
270+
->method('getCurrentScope')
271+
->will($this->returnValue('emptyscope'));
272+
273+
$this->assertEquals(
274+
[4 => ['simple_plugin']],
275+
$this->_model->getNext(
276+
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class,
277+
'getName'
278+
)
279+
);
280+
$this->assertEquals(
281+
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Simple::class,
282+
$this->_model->getPlugin(
283+
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class,
284+
'simple_plugin'
285+
)
286+
);
287+
}
259288
}

lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,11 @@
7777
],
7878
]
7979
]
80+
],
81+
[
82+
'emptyscope',
83+
[
84+
85+
]
8086
]
8187
];

0 commit comments

Comments
 (0)