Skip to content

Commit

Permalink
Merge pull request #640 from magento-jackalopes/pr
Browse files Browse the repository at this point in the history
Issues Fixed:

- MAGETWO-58446 Remove uses of unserialize in usages of \Magento\Framework\Cache\FrontendInterface::load()
- MAGETWO-58450 Remove uses of unserialize in usages of \Magento\Framework\App\CacheInterface::load()
- MAGETWO-58680 Remove uses of unserialize in usages of \Magento\Framework\Cache\FrontendInterface::load() 2
- MAGETWO-60442 Add optional SerializerInterface dependency to child classes of \Magento\Framework\Config\Data
- MAGETWO-60353 Replace json_decode in \Magento\Framework\ObjectManager\DefinitionFactory::_unpack with SerializerInterface
  • Loading branch information
sdwright authored Dec 2, 2016
2 parents 3f4fe5e + b072b98 commit b4c3bfd
Show file tree
Hide file tree
Showing 174 changed files with 4,221 additions and 3,364 deletions.
7 changes: 0 additions & 7 deletions app/code/Magento/Backend/Model/Session/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\GroupManagementInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Quote\Api\CartManagementInterface;

/**
* Adminhtml quote session
Expand Down Expand Up @@ -81,11 +79,6 @@ class Quote extends \Magento\Framework\Session\SessionManager
*/
protected $quoteFactory;

/**
* @var \Magento\Quote\Api\CartManagementInterface;
*/
private $cartManagement;

/**
* @param \Magento\Framework\App\Request\Http $request
* @param \Magento\Framework\Session\SidResolverInterface $sidResolver
Expand Down
13 changes: 10 additions & 3 deletions app/code/Magento/Backend/Model/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\Backend\Model;

use Magento\Framework\Url\HostChecker;
use Magento\Framework\App\ObjectManager;

/**
* Class \Magento\Backend\Model\UrlInterface
Expand Down Expand Up @@ -77,6 +79,8 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn
protected $_scope;

/**
* Constructor
*
* @param \Magento\Framework\App\Route\ConfigInterface $routeConfig
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo
Expand All @@ -96,7 +100,7 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn
* @param \Magento\Store\Model\StoreFactory $storeFactory
* @param \Magento\Framework\Data\Form\FormKey $formKey
* @param array $data
*
* @param HostChecker|null $hostChecker
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -118,9 +122,11 @@ public function __construct(
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Magento\Store\Model\StoreFactory $storeFactory,
\Magento\Framework\Data\Form\FormKey $formKey,
array $data = []
array $data = [],
HostChecker $hostChecker = null
) {
$this->_encryptor = $encryptor;
$hostChecker = $hostChecker ?: ObjectManager::getInstance()->get(HostChecker::class);
parent::__construct(
$routeConfig,
$request,
Expand All @@ -133,7 +139,8 @@ public function __construct(
$scopeConfig,
$routeParamsPreprocessor,
$scopeType,
$data
$data,
$hostChecker
);
$this->_backendHelper = $backendHelper;
$this->_menuConfig = $menuConfig;
Expand Down
37 changes: 6 additions & 31 deletions app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
*/
class QuoteTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
*/
private $objectManager;

/**
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
Expand Down Expand Up @@ -92,11 +97,6 @@ class QuoteTest extends \PHPUnit_Framework_TestCase
*/
protected $quoteFactoryMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $cartManagementMock;

/**
* Set up
*
Expand All @@ -105,6 +105,7 @@ class QuoteTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->customerRepositoryMock = $this->getMockForAbstractClass(
\Magento\Customer\Api\CustomerRepositoryInterface::class,
[],
Expand Down Expand Up @@ -197,13 +198,6 @@ protected function setUp()
);

$this->quoteFactoryMock = $this->getMock(\Magento\Quote\Model\QuoteFactory::class, ['create'], [], '', false);
$this->cartManagementMock = $this->getMock(
\Magento\Quote\Api\CartManagementInterface::class,
[],
[],
'',
false
);

$this->quote = $this->getMock(
\Magento\Backend\Model\Session\Quote::class,
Expand All @@ -226,10 +220,6 @@ protected function setUp()
'quoteFactory' => $this->quoteFactoryMock
]
);

$this->prepareObjectManager([
[\Magento\Quote\Api\CartManagementInterface::class, $this->cartManagementMock]
]);
}

/**
Expand Down Expand Up @@ -416,19 +406,4 @@ public function getQuoteDataProvider()
'customer ids same' => [66, 66, 'never'],
];
}

/**
* @param array $map
* @deprecated
*/
private function prepareObjectManager($map)
{
$objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class);
$objectManagerMock->expects($this->any())->method('getInstance')->willReturnSelf();
$objectManagerMock->expects($this->any())->method('get')->will($this->returnValueMap($map));
$reflectionClass = new \ReflectionClass(\Magento\Framework\App\ObjectManager::class);
$reflectionProperty = $reflectionClass->getProperty('_instance');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($objectManagerMock);
}
}
63 changes: 19 additions & 44 deletions app/code/Magento/Backend/Test/Unit/Model/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/**
* Test class for \Magento\Backend\Model\Url
*/
namespace Magento\Backend\Test\Unit\Model;

use Magento\Framework\Url\HostChecker;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @codingStandardsIgnoreFile
*/
class UrlTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -21,10 +18,12 @@ class UrlTest extends \PHPUnit_Framework_TestCase
*/
protected $_model;

/**
* @var string
*/
protected $_areaFrontName = 'backendArea';

/**
* Mock menu model
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $_menuMock;
Expand Down Expand Up @@ -62,7 +61,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $_paramsResolverMock;
protected $routeParamsResolverFactoryMock;

/**
* @var \Magento\Framework\Encryption\EncryptorInterface
Expand All @@ -75,6 +74,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->_menuMock = $this->getMock(
\Magento\Backend\Model\Menu::class,
[],
Expand Down Expand Up @@ -141,25 +141,21 @@ protected function setUp()
false,
false
);
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->_encryptor = $this->getMock(\Magento\Framework\Encryption\Encryptor::class, null, [], '', false);
$this->_paramsResolverMock = $this->getMock(
$routeParamsResolver = $this->getMock(\Magento\Framework\Url\RouteParamsResolver::class, [], [], '', false);
$this->routeParamsResolverFactoryMock = $this->getMock(
\Magento\Framework\Url\RouteParamsResolverFactory::class,
[],
[],
'',
false
);
$this->_paramsResolverMock->expects(
$this->any()
)->method(
'create'
)->will(
$this->returnValue(
$this->getMock(\Magento\Framework\Url\RouteParamsResolver::class, [], [], '', false)
)
);
$this->_model = $helper->getObject(
$this->routeParamsResolverFactoryMock->expects($this->any())
->method('create')
->willReturn($routeParamsResolver);
/** @var HostChecker|\PHPUnit_Framework_MockObject_MockObject $hostCheckerMock */
$hostCheckerMock = $this->getMock(HostChecker::class, [], [], '', false);
$this->_model = $objectManager->getObject(
\Magento\Backend\Model\Url::class,
[
'scopeConfig' => $this->_scopeConfigMock,
Expand All @@ -168,31 +164,10 @@ protected function setUp()
'menuConfig' => $this->_menuConfigMock,
'authSession' => $this->_authSessionMock,
'encryptor' => $this->_encryptor,
'routeParamsResolverFactory' => $this->_paramsResolverMock
'routeParamsResolverFactory' => $this->routeParamsResolverFactoryMock,
'hostChecker' => $hostCheckerMock
]
);
$this->_paramsResolverMock->expects(
$this->any()
)->method(
'create'
)->will(
$this->returnValue(
$this->getMock(\Magento\Framework\Url\RouteParamsResolver::class, [], [], '', false)
)
);
$this->_model = $helper->getObject(
\Magento\Backend\Model\Url::class,
[
'scopeConfig' => $this->_scopeConfigMock,
'backendHelper' => $helperMock,
'formKey' => $this->_formKey,
'menuConfig' => $this->_menuConfigMock,
'authSession' => $this->_authSessionMock,
'encryptor' => $this->_encryptor,
'routeParamsResolverFactory' => $this->_paramsResolverMock
]
);

$this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false);
$this->_model->setRequest($this->_requestMock);
}
Expand Down Expand Up @@ -262,7 +237,7 @@ public function testGetAreaFrontName()
[
'backendHelper' => $helperMock,
'authSession' => $this->_authSessionMock,
'routeParamsResolverFactory' => $this->_paramsResolverMock
'routeParamsResolverFactory' => $this->routeParamsResolverFactoryMock
]
);
$urlModel->getAreaFrontName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Magento\BundleImportExport\Model\Import\Product\Type;

use \Magento\Bundle\Model\Product\Price as BundlePrice;
use \Magento\BundleImportExport\Model\Export\RowCustomizer;
use \Magento\Catalog\Model\Product\Type\AbstractType;

/**
Expand Down Expand Up @@ -55,20 +54,6 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
*/
const SELECTION_PRICE_TYPE_PERCENT = 1;

/**
* Instance of database adapter.
*
* @var \Magento\Framework\DB\Adapter\AdapterInterface
*/
protected $connection;

/**
* Instance of application resource.
*
* @var \Magento\Framework\App\ResourceConnection
*/
protected $_resource;

/**
* Array of cached options.
*
Expand Down Expand Up @@ -144,23 +129,6 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
'multiselect' => 'multi',
];

/**
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $attrSetColFac
* @param \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $prodAttrColFac
* @param \Magento\Framework\App\ResourceConnection $resource
* @param array $params
*/
public function __construct(
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $attrSetColFac,
\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $prodAttrColFac,
\Magento\Framework\App\ResourceConnection $resource,
array $params
) {
parent::__construct($attrSetColFac, $prodAttrColFac, $resource, $params);
$this->_resource = $resource;
$this->connection = $resource->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);
}

/**
* Parse selections.
*
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/BundleImportExport/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"magento/module-import-export": "100.2.*",
"magento/module-catalog-import-export": "100.2.*",
"magento/module-bundle": "100.2.*",
"magento/module-eav": "100.2.*",
"magento/framework": "100.2.*"
},
"type": "magento2-module",
Expand Down
17 changes: 13 additions & 4 deletions app/code/Magento/Catalog/Model/Attribute/Config/Data.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
<?php
/**
* Catalog attributes configuration data container. Provides catalog attributes configuration data.
*
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Model\Attribute\Config;

use Magento\Framework\Serialize\SerializerInterface;

/**
* Provides catalog attributes configuration
*/
class Data extends \Magento\Framework\Config\Data
{
/**
* Constructor
*
* @param \Magento\Catalog\Model\Attribute\Config\Reader $reader
* @param \Magento\Framework\Config\CacheInterface $cache
* @param string|null $cacheId
* @param SerializerInterface|null $serializer
*/
public function __construct(
\Magento\Catalog\Model\Attribute\Config\Reader $reader,
\Magento\Framework\Config\CacheInterface $cache
\Magento\Framework\Config\CacheInterface $cache,
$cacheId = 'catalog_attributes',
SerializerInterface $serializer = null
) {
parent::__construct($reader, $cache, 'catalog_attributes');
parent::__construct($reader, $cache, $cacheId, $serializer);
}
}
Loading

0 comments on commit b4c3bfd

Please sign in to comment.