diff --git a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php index ecfb67320cb0d58decdf67de64d2058814f1eaf8..bae8f7c118c08b298bdc17b86db65181af075c3a 100644 --- a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php +++ b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php @@ -276,8 +276,8 @@ class PluginList extends Scoped implements InterceptionPluginList $data = $this->_cache->load($cacheId); if ($data) { list($this->_data, $this->_inherited, $this->_processed) = unserialize($data); - foreach ($this->_scopePriorityScheme as $scope) { - $this->_loadedScopes[$scope] = true; + foreach ($this->_scopePriorityScheme as $scopeCode) { + $this->_loadedScopes[$scopeCode] = true; } } else { $virtualTypes = []; @@ -285,18 +285,17 @@ class PluginList extends Scoped implements InterceptionPluginList if (false == isset($this->_loadedScopes[$scopeCode])) { $data = $this->_reader->read($scopeCode); unset($data['preferences']); - if (!count($data)) { - continue; - } - $this->_inherited = []; - $this->_processed = []; - $this->merge($data); - $this->_loadedScopes[$scopeCode] = true; - foreach ($data as $class => $config) { - if (isset($config['type'])) { - $virtualTypes[] = $class; + if (count($data) > 0) { + $this->_inherited = []; + $this->_processed = []; + $this->merge($data); + foreach ($data as $class => $config) { + if (isset($config['type'])) { + $virtualTypes[] = $class; + } } } + $this->_loadedScopes[$scopeCode] = true; } if ($this->isCurrentScope($scopeCode)) { break; diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php index b3fe011a0a490727c0682f1863aa731622753264..ac1e510f28b226a9c6386a35ca31192b7900cdc4 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php @@ -256,4 +256,33 @@ class PluginListTest extends \PHPUnit_Framework_TestCase $this->assertEquals(null, $this->_model->getNext('Type', 'method')); } + + /** + * @covers \Magento\Framework\Interception\PluginList\PluginList::getNext + * @covers \Magento\Framework\Interception\PluginList\PluginList::_loadScopedData + */ + public function testLoadScopeDataWithEmptyData() + { + $this->_objectManagerMock->expects($this->any()) + ->method('get') + ->will($this->returnArgument(0)); + $this->_configScopeMock->expects($this->any()) + ->method('getCurrentScope') + ->will($this->returnValue('emptyscope')); + + $this->assertEquals( + [4 => ['simple_plugin']], + $this->_model->getNext( + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, + 'getName' + ) + ); + $this->assertEquals( + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Simple::class, + $this->_model->getPlugin( + \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, + 'simple_plugin' + ) + ); + } } diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php b/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php index 87bbe0d35dd2561799cd5d2024347c8fb48c2b73..37c5316171fde594cacc8d3e3976c6d6aab95cde 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/_files/reader_mock_map.php @@ -77,5 +77,11 @@ return [ ], ] ] + ], + [ + 'emptyscope', + [ + + ] ] ];