diff --git a/app/code/Magento/Store/App/Config/Type/Scopes.php b/app/code/Magento/Store/App/Config/Type/Scopes.php index dbe939aac1be44a08f6d8b68f2e353fd3e44356f..1c9ac59442163945f6aab2739807afdd74be7673 100644 --- a/app/code/Magento/Store/App/Config/Type/Scopes.php +++ b/app/code/Magento/Store/App/Config/Type/Scopes.php @@ -7,13 +7,7 @@ namespace Magento\Store\App\Config\Type; use Magento\Framework\App\Config\ConfigTypeInterface; use Magento\Framework\App\Config\ConfigSourceInterface; -use Magento\Framework\Cache\FrontendInterface; use Magento\Framework\DataObject; -use Magento\Framework\Serialize\Serializer\Serialize; -use Magento\Framework\Serialize\SerializerInterface; -use Magento\Store\Model\Group; -use Magento\Store\Model\Store; -use Magento\Store\Model\Website; /** * Merge and hold scopes data from different sources @@ -34,38 +28,14 @@ class Scopes implements ConfigTypeInterface */ private $data; - /** - * @var FrontendInterface - */ - private $cache; - - /** - * @var int - */ - private $cachingNestedLevel; - - /** - * @var Serialize - */ - private $serializer; - /** * System constructor. * @param ConfigSourceInterface $source - * @param FrontendInterface $cache - * @param int $cachingNestedLevel - * @param SerializerInterface $serializer */ public function __construct( - ConfigSourceInterface $source, - FrontendInterface $cache, - Serialize $serializer, - $cachingNestedLevel = 1 + ConfigSourceInterface $source ) { $this->source = $source; - $this->cache = $cache; - $this->cachingNestedLevel = $cachingNestedLevel; - $this->serializer = $serializer; } /** @@ -74,18 +44,7 @@ class Scopes implements ConfigTypeInterface public function get($path = '') { if (!$this->data) { - /** @var DataObject $data */ - $data = $this->cache->load(self::CONFIG_TYPE); - if (!$data) { - $this->data = new DataObject($this->source->get()); - $this->cache->save( - $this->serializer->serialize($this->data->getData()), - self::CONFIG_TYPE, - [Group::CACHE_TAG, Store::CACHE_TAG, Website::CACHE_TAG] - ); - } else { - $this->data = new DataObject($this->serializer->unserialize($data)); - } + $this->data = new DataObject($this->source->get()); } return $this->data->getData($path); @@ -99,9 +58,5 @@ class Scopes implements ConfigTypeInterface public function clean() { $this->data = null; - $this->cache->clean( - \Zend_Cache::CLEANING_MODE_MATCHING_TAG, - [Group::CACHE_TAG, Store::CACHE_TAG, Website::CACHE_TAG] - ); } } diff --git a/app/code/Magento/Store/Test/Unit/App/Config/Type/ScopesTest.php b/app/code/Magento/Store/Test/Unit/App/Config/Type/ScopesTest.php deleted file mode 100644 index 94efcc7db8cc7b37fe7ed514c7345d5b27335bea..0000000000000000000000000000000000000000 --- a/app/code/Magento/Store/Test/Unit/App/Config/Type/ScopesTest.php +++ /dev/null @@ -1,108 +0,0 @@ -<?php -/** - * Copyright © 2016 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Store\Test\Unit\App\Config\Type; - -use Magento\Framework\App\Config\ConfigSourceInterface; -use Magento\Framework\Cache\FrontendInterface; -use Magento\Framework\DataObject; -use Magento\Framework\Serialize\Serializer\Serialize; -use Magento\Store\App\Config\Type\Scopes; -use Magento\Store\Model\Group; -use Magento\Store\Model\Store; -use Magento\Store\Model\Website; - -class ScopesTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $source; - - /** - * @var FrontendInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $cache; - - /** - * @var Scopes - */ - private $configType; - - /** - * @var Serialize | \PHPUnit_Framework_MockObject_MockObject - */ - private $serializer; - - public function setUp() - { - $this->source = $this->getMockBuilder(ConfigSourceInterface::class) - ->getMockForAbstractClass(); - $this->cache = $this->getMockBuilder(FrontendInterface::class) - ->getMockForAbstractClass(); - $this->serializer = $this->getMockBuilder(Serialize::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configType = new Scopes($this->source, $this->cache, $this->serializer); - } - - /** - * @param bool $isCached - * @dataProvider getDataProvider - */ - public function testGet($isCached) - { - $storeCode = 'myStore'; - $storeData = [ - 'name' => 'My store' - ]; - $data = [ - 'stores' => [ - $storeCode => $storeData - ] - ]; - $this->cache->expects($this->once()) - ->method('load') - ->with(Scopes::CONFIG_TYPE) - ->willReturn($isCached ? serialize($data) : false); - - if ($isCached) { - $this->serializer->expects($this->once()) - ->method('unserialize') - ->willReturn($data); - } - - if (!$isCached) { - $this->serializer->expects($this->once()) - ->method('serialize') - ->willReturn(serialize($data)); - $this->source->expects($this->once()) - ->method('get') - ->with('') - ->willReturn($data); - $this->cache->expects($this->once()) - ->method('save') - ->with( - serialize($data), - Scopes::CONFIG_TYPE, - [Group::CACHE_TAG, Store::CACHE_TAG, Website::CACHE_TAG] - ); - } - - $this->assertEquals($storeData, $this->configType->get('stores/' . $storeCode)); - } - - /** - * @return array - */ - public function getDataProvider() - { - return [ - [true], - [false] - ]; - } -} diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index 774eed7042009c4febaca869f7e71652aff521f4..7307493cefb4cca65eb81eacaec265e9a381f6f1 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -332,7 +332,6 @@ <type name="Magento\Store\App\Config\Type\Scopes"> <arguments> <argument name="source" xsi:type="object">scopesConfigSourceAggregatedProxy</argument> - <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> </arguments> </type> <virtualType name="scopesConfigSourceAggregatedProxy" type="Magento\Framework\App\Config\ConfigSourceAggregated\Proxy">