diff --git a/app/code/Magento/Authorization/Model/ResourceModel/Rules.php b/app/code/Magento/Authorization/Model/ResourceModel/Rules.php index 8820e102f1180..cccad99cef954 100644 --- a/app/code/Magento/Authorization/Model/ResourceModel/Rules.php +++ b/app/code/Magento/Authorization/Model/ResourceModel/Rules.php @@ -21,15 +21,6 @@ class Rules extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $_rootResource; - /** - * Acl object cache - * - * @var \Magento\Framework\Acl\CacheInterface - * @deprecated since 2.2 due to native serialization elimination. - * Use data cache \Magento\Framework\Acl\Data\CacheInterface instead. - */ - protected $_aclCache; - /** * @var \Magento\Framework\Acl\Builder */ @@ -50,7 +41,6 @@ class Rules extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb * @param \Magento\Framework\Acl\Builder $aclBuilder * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Acl\RootResource $rootResource - * @param \Magento\Framework\Acl\CacheInterface $aclCache * @param string $connectionName * @param \Magento\Framework\Acl\Data\CacheInterface $aclDataCache */ @@ -59,14 +49,12 @@ public function __construct( \Magento\Framework\Acl\Builder $aclBuilder, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Acl\RootResource $rootResource, - \Magento\Framework\Acl\CacheInterface $aclCache, $connectionName = null, \Magento\Framework\Acl\Data\CacheInterface $aclDataCache = null ) { $this->_aclBuilder = $aclBuilder; parent::__construct($context, $connectionName); $this->_rootResource = $rootResource; - $this->_aclCache = $aclCache; $this->_logger = $logger; $this->aclDataCache = $aclDataCache ?: ObjectManager::getInstance()->get( \Magento\Framework\Acl\Data\CacheInterface::class diff --git a/app/code/Magento/Authorization/Test/Unit/Model/ResourceModel/RulesTest.php b/app/code/Magento/Authorization/Test/Unit/Model/ResourceModel/RulesTest.php index ac30fe452c926..9687f0a24f7ce 100644 --- a/app/code/Magento/Authorization/Test/Unit/Model/ResourceModel/RulesTest.php +++ b/app/code/Magento/Authorization/Test/Unit/Model/ResourceModel/RulesTest.php @@ -46,11 +46,6 @@ class RulesTest extends \PHPUnit_Framework_TestCase */ private $rootResourceMock; - /** - * @var \Magento\Framework\Acl\CacheInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $aclCacheMock; - /** * @var \Magento\Framework\Acl\Data\CacheInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -117,11 +112,6 @@ protected function setUp() ->setMethods([]) ->getMock(); - $this->aclCacheMock = $this->getMockBuilder(\Magento\Framework\Acl\CacheInterface::class) - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); - $this->aclDataCacheMock = $this->getMockBuilder(\Magento\Framework\Acl\Data\CacheInterface::class) ->disableOriginalConstructor() ->setMethods([]) @@ -145,7 +135,6 @@ protected function setUp() $this->aclBuilderMock, $this->loggerMock, $this->rootResourceMock, - $this->aclCacheMock, 'connection', $this->aclDataCacheMock ); diff --git a/app/code/Magento/Authorization/etc/di.xml b/app/code/Magento/Authorization/etc/di.xml index 9370e14d81a35..6ed33ce68696e 100644 --- a/app/code/Magento/Authorization/etc/di.xml +++ b/app/code/Magento/Authorization/etc/di.xml @@ -10,7 +10,6 @@ Magento\Framework\Acl\RootResource\Proxy - Magento\Framework\Acl\Cache\Proxy diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index 8894f2293fa35..e9a1754cad81b 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -89,11 +89,6 @@ Magento\Framework\Acl\Loader\ResourceLoader - - - backend_acl_resources - - Magento_Backend::all diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index 63dba866c7c60..289e621d4d6fd 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -202,11 +202,6 @@ frontend - - - global_acl_resources - - diff --git a/app/code/Magento/User/Model/ResourceModel/User.php b/app/code/Magento/User/Model/ResourceModel/User.php index 7950f55949a20..1cdff378cd117 100644 --- a/app/code/Magento/User/Model/ResourceModel/User.php +++ b/app/code/Magento/User/Model/ResourceModel/User.php @@ -17,13 +17,6 @@ */ class User extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { - /** - * @var \Magento\Framework\Acl\CacheInterface - * @deprecated since 2.2 due to native serialization elimination. - * Use data cache \Magento\Framework\Acl\Data\CacheInterface instead. - */ - protected $_aclCache; - /** * Role model * @@ -45,7 +38,6 @@ class User extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb * Construct * * @param \Magento\Framework\Model\ResourceModel\Db\Context $context - * @param \Magento\Framework\Acl\CacheInterface $aclCache * @param \Magento\Authorization\Model\RoleFactory $roleFactory * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param string $connectionName @@ -53,14 +45,12 @@ class User extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ public function __construct( \Magento\Framework\Model\ResourceModel\Db\Context $context, - \Magento\Framework\Acl\CacheInterface $aclCache, \Magento\Authorization\Model\RoleFactory $roleFactory, \Magento\Framework\Stdlib\DateTime $dateTime, $connectionName = null, \Magento\Framework\Acl\Data\CacheInterface $aclDataCache = null ) { parent::__construct($context, $connectionName); - $this->_aclCache = $aclCache; $this->_roleFactory = $roleFactory; $this->dateTime = $dateTime; $this->aclDataCache = $aclDataCache ?: \Magento\Framework\App\ObjectManager::getInstance()->get( diff --git a/app/code/Magento/User/Test/Unit/Model/ResourceModel/UserTest.php b/app/code/Magento/User/Test/Unit/Model/ResourceModel/UserTest.php index 87bacafa1578e..aa31a46f2e850 100644 --- a/app/code/Magento/User/Test/Unit/Model/ResourceModel/UserTest.php +++ b/app/code/Magento/User/Test/Unit/Model/ResourceModel/UserTest.php @@ -21,9 +21,6 @@ class UserTest extends \PHPUnit_Framework_TestCase /** @var \Magento\User\Model\User|\PHPUnit_framework_MockObject_MockObject */ protected $userMock; - /** @var \Magento\Framework\Acl\CacheInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $aclCacheMock; - /** @var \Magento\Framework\Model\ResourceModel\Db\Context|\PHPUnit_Framework_MockObject_MockObject */ protected $contextMock; @@ -62,11 +59,6 @@ protected function setUp() ->setMethods([]) ->getMock(); - $this->aclCacheMock = $this->getMockBuilder(\Magento\Framework\Acl\CacheInterface::class) - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); - $this->roleFactoryMock = $this->getMockBuilder(\Magento\Authorization\Model\RoleFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) @@ -102,7 +94,6 @@ protected function setUp() \Magento\User\Model\ResourceModel\User::class, [ 'resource' => $this->resourceMock, - 'aclCache' => $this->aclCacheMock, 'roleFactory' => $this->roleFactoryMock, 'dateTime' => $this->dateTimeMock, 'aclDataCache' => $this->aclDataCacheMock, diff --git a/app/code/Magento/User/etc/di.xml b/app/code/Magento/User/etc/di.xml index c4383e5561ae8..27fa3c2dc7d64 100644 --- a/app/code/Magento/User/etc/di.xml +++ b/app/code/Magento/User/etc/di.xml @@ -6,11 +6,6 @@ */ --> - - - Magento\Framework\Acl\Cache\Proxy - - diff --git a/app/etc/di.xml b/app/etc/di.xml index e114b98dfa17d..f8fb16815907c 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -106,7 +106,6 @@ - diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index 00200ffd43d59..074e5ab2dab89 100755 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -4227,4 +4227,7 @@ ['Magento\Framework\Search\Document', 'Magento\Framework\Api\Search\Document'], ['Magento\Framework\Search\DocumentField'], ['Magento\Quote\Setup\Recurring'], + ['Magento\Framework\Acl\Cache'], + ['Magento\Framework\Acl\CacheInterface'], + ['Magento\Framework\Acl\Test\Unit\CacheTest'], ]; diff --git a/lib/internal/Magento/Framework/Acl/Builder.php b/lib/internal/Magento/Framework/Acl/Builder.php index 970581e1eb3bd..a51801d68c81d 100644 --- a/lib/internal/Magento/Framework/Acl/Builder.php +++ b/lib/internal/Magento/Framework/Acl/Builder.php @@ -25,14 +25,6 @@ class Builder */ protected $_loaderPool; - /** - * ACL cache - * - * @var \Magento\Framework\Acl\CacheInterface - * @deprecated - */ - protected $_cache; - /** * @var \Magento\Framework\AclFactory */ @@ -40,20 +32,17 @@ class Builder /** * @param \Magento\Framework\AclFactory $aclFactory - * @param \Magento\Framework\Acl\CacheInterface $cache * @param \Magento\Framework\Acl\LoaderInterface $roleLoader * @param \Magento\Framework\Acl\LoaderInterface $resourceLoader * @param \Magento\Framework\Acl\LoaderInterface $ruleLoader */ public function __construct( \Magento\Framework\AclFactory $aclFactory, - \Magento\Framework\Acl\CacheInterface $cache, \Magento\Framework\Acl\LoaderInterface $roleLoader, \Magento\Framework\Acl\LoaderInterface $resourceLoader, \Magento\Framework\Acl\LoaderInterface $ruleLoader ) { $this->_aclFactory = $aclFactory; - $this->_cache = $cache; $this->_loaderPool = [$roleLoader, $resourceLoader, $ruleLoader]; } diff --git a/lib/internal/Magento/Framework/Acl/Cache.php b/lib/internal/Magento/Framework/Acl/Cache.php deleted file mode 100644 index af1c2928111d2..0000000000000 --- a/lib/internal/Magento/Framework/Acl/Cache.php +++ /dev/null @@ -1,92 +0,0 @@ -_cache = $cache; - $this->_cacheKey = $cacheKey; - } - - /** - * Check whether ACL object is in cache - * - * @return bool - */ - public function has() - { - return null !== $this->_acl || $this->_cache->test($this->_cacheKey); - } - - /** - * Retrieve ACL object from cache - * - * @return \Magento\Framework\Acl - */ - public function get() - { - if (null == $this->_acl) { - $this->_acl = unserialize($this->_cache->load($this->_cacheKey)); - } - return $this->_acl; - } - - /** - * Save ACL object to cache - * - * @param \Magento\Framework\Acl $acl - * @return void - */ - public function save(\Magento\Framework\Acl $acl) - { - $this->_acl = $acl; - $this->_cache->save(serialize($acl), $this->_cacheKey); - } - - /** - * Clear ACL instance cache - * - * @return void - */ - public function clean() - { - $this->_acl = null; - $this->_cache->remove($this->_cacheKey); - } -} diff --git a/lib/internal/Magento/Framework/Acl/CacheInterface.php b/lib/internal/Magento/Framework/Acl/CacheInterface.php deleted file mode 100644 index 40fcbc043f8f2..0000000000000 --- a/lib/internal/Magento/Framework/Acl/CacheInterface.php +++ /dev/null @@ -1,45 +0,0 @@ -_aclMock = new \Magento\Framework\Acl(); - $this->_aclCacheMock = $this->getMock(\Magento\Framework\Acl\CacheInterface::class); $this->_aclFactoryMock = $this->getMock(\Magento\Framework\AclFactory::class, [], [], '', false); $this->_aclFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_aclMock)); $this->_roleLoader = $this->getMock(\Magento\Framework\Acl\Loader\DefaultLoader::class); @@ -55,7 +49,6 @@ protected function setUp() $this->_resourceLoader = $this->getMock(\Magento\Framework\Acl\Loader\DefaultLoader::class); $this->_model = new \Magento\Framework\Acl\Builder( $this->_aclFactoryMock, - $this->_aclCacheMock, $this->_roleLoader, $this->_resourceLoader, $this->_ruleLoader @@ -64,10 +57,6 @@ protected function setUp() public function testGetAclUsesLoadersProvidedInConfigurationToPopulateAclIfCacheIsEmpty() { - $this->_aclCacheMock->expects($this->never())->method('has'); - $this->_aclCacheMock->expects($this->never())->method('get'); - $this->_aclCacheMock->expects($this->never())->method('save'); - $this->_aclCacheMock->expects($this->never())->method('clean'); $this->_ruleLoader->expects($this->once())->method('populateAcl')->with($this->equalTo($this->_aclMock)); $this->_roleLoader->expects($this->once())->method('populateAcl')->with($this->equalTo($this->_aclMock)); @@ -79,13 +68,6 @@ public function testGetAclUsesLoadersProvidedInConfigurationToPopulateAclIfCache public function testGetAclReturnsAclStoredInCache() { - /** - * The acl cache of type \Magento\Framework\Acl\CacheInterface is deprecated and should never be called - */ - $this->_aclCacheMock->expects($this->never())->method('has'); - $this->_aclCacheMock->expects($this->never())->method('get'); - $this->_aclCacheMock->expects($this->never())->method('save'); - $this->_aclCacheMock->expects($this->never())->method('clean'); $this->assertEquals($this->_aclMock, $this->_model->getAcl()); $this->assertEquals($this->_aclMock, $this->_model->getAcl()); } diff --git a/lib/internal/Magento/Framework/Acl/Test/Unit/CacheTest.php b/lib/internal/Magento/Framework/Acl/Test/Unit/CacheTest.php deleted file mode 100644 index 10bec1a45f06f..0000000000000 --- a/lib/internal/Magento/Framework/Acl/Test/Unit/CacheTest.php +++ /dev/null @@ -1,114 +0,0 @@ -cacheConfig = $this->getMock(\Magento\Framework\Config\CacheInterface::class); - $this->cacheKey = 'test_key'; - - $this->model = new Cache($this->cacheConfig, $this->cacheKey); - } - - /** - * @param array|bool $dataAcl - * @dataProvider aclDataProvider - */ - public function testGet($dataAcl) - { - $this->initAcl((is_array($dataAcl) ? serialize($dataAcl) : $dataAcl)); - $this->assertEquals($dataAcl, $this->model->get()); - } - - /** - * @return array - */ - public function aclDataProvider() - { - return [ - ['dataAcl' => ['someKey' => 'someValue']], - ['dataAcl' => false] - ]; - } - - /** - * @param bool $expectedTest - * @dataProvider hasWithoutAclDataProvider - */ - public function testHasWithoutAcl($expectedTest) - { - $this->cacheConfig->expects($this->once())->method('test')->will($this->returnValue($expectedTest)); - $this->assertEquals($expectedTest, $this->model->has()); - } - - /** - * @return array - */ - public function hasWithoutAclDataProvider() - { - return [ - ['expectedTest' => true], - ['expectedTest' => false] - ]; - } - - /** - * @param array|bool $dataAcl - * @dataProvider aclDataProvider - */ - public function testHasWithAcl($dataAcl) - { - $this->initAcl((is_array($dataAcl) ? serialize($dataAcl) : $dataAcl)); - $this->cacheConfig->expects($this->never())->method('test'); - - $this->model->get(); - $this->assertTrue($this->model->has()); - } - - protected function initAcl($aclData) - { - $this->cacheConfig->expects($this->once()) - ->method('load') - ->with($this->cacheKey) - ->will($this->returnValue($aclData)); - } - - public function testSave() - { - $acl = $this->getMockBuilder(\Magento\Framework\Acl::class)->disableOriginalConstructor()->getMock(); - - $this->cacheConfig->expects($this->once())->method('save')->with(serialize($acl), $this->cacheKey); - $this->model->save($acl); - } - - public function testClean() - { - $this->cacheConfig->expects($this->once()) - ->method('remove') - ->with($this->cacheKey); - $this->model->clean(); - } -} diff --git a/lib/internal/Magento/Framework/Unserialize/Test/Unit/UnserializeTest.php b/lib/internal/Magento/Framework/Unserialize/Test/Unit/UnserializeTest.php index 801e57cd09b83..7b0469a6c10be 100644 --- a/lib/internal/Magento/Framework/Unserialize/Test/Unit/UnserializeTest.php +++ b/lib/internal/Magento/Framework/Unserialize/Test/Unit/UnserializeTest.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\Unserialize\Test\Unit; +use Magento\Framework\Serialize\Serializer\Serialize; + /** * @package Magento\Framework */ @@ -15,7 +17,22 @@ class UnserializeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->unserialize = new \Magento\Framework\Unserialize\Unserialize(); + $serializer = $this->getMockBuilder(Serialize::class) + ->setMethods(['serialize', 'unserialize']) + ->getMock(); + $serializer->expects($this->any()) + ->method('serialize') + ->willReturnCallback(function ($parameter) { + return serialize($parameter); + }); + $serializer->expects($this->any()) + ->method('unserialize') + ->willReturnCallback(function ($parameter) { + return unserialize($parameter); + }); + $this->unserialize = new \Magento\Framework\Unserialize\Unserialize( + $serializer + ); } public function testUnserializeArray() diff --git a/lib/internal/Magento/Framework/Unserialize/Unserialize.php b/lib/internal/Magento/Framework/Unserialize/Unserialize.php index c50c9d2b4791a..4dfefac02062a 100644 --- a/lib/internal/Magento/Framework/Unserialize/Unserialize.php +++ b/lib/internal/Magento/Framework/Unserialize/Unserialize.php @@ -6,11 +6,29 @@ namespace Magento\Framework\Unserialize; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Serialize\Serializer\Serialize; + /** * @deprecated */ class Unserialize { + /** + * Serializer for safe string unserialization. + * + * @var Serialize + */ + private $serializer; + + /** + * @param Serialize|null $serializer Optional parameter for backward compatibility. + */ + public function __construct(Serialize $serializer = null) + { + $this->serializer = $serializer ?: ObjectManager::getInstance()->get(Serialize::class); + } + /** * @param string $string * @return bool|mixed @@ -21,6 +39,6 @@ public function unserialize($string) trigger_error('String contains serialized object'); return false; } - return unserialize($string); + return $this->serializer->unserialize($string); } }