Skip to content

Commit

Permalink
Magento Auto Sync Merge from: magento / magento2ce / develop
Browse files Browse the repository at this point in the history
  • Loading branch information
magento-team authored Mar 23, 2017
2 parents d60c55b + ed9edb1 commit f779ef2
Show file tree
Hide file tree
Showing 27 changed files with 392 additions and 57 deletions.
4 changes: 2 additions & 2 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<!--- Provide a description of the changes proposed in the pull request -->

### Fixed Issues (if relevant)
<!--- Provide a list of fixed issues in the format magento/magetno2#<issue_number>, if relevant -->
1. magento/magetno2#<issue_number>: Issue title
<!--- Provide a list of fixed issues in the format magento/magento2#<issue_number>, if relevant -->
1. magento/magento2#<issue_number>: Issue title
2. ...

### Manual testing scenarios
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Catalog/Model/Product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public function getQuality()
*/
public function setKeepAspectRatio($keep)
{
$this->_keepAspectRatio = (bool)$keep;
$this->_keepAspectRatio = $keep && $keep !== 'false';
return $this;
}

Expand All @@ -302,7 +302,7 @@ public function setKeepAspectRatio($keep)
*/
public function setKeepFrame($keep)
{
$this->_keepFrame = (bool)$keep;
$this->_keepFrame = $keep && $keep !== 'false';
return $this;
}

Expand All @@ -312,7 +312,7 @@ public function setKeepFrame($keep)
*/
public function setKeepTransparency($keep)
{
$this->_keepTransparency = (bool)$keep;
$this->_keepTransparency = $keep && $keep !== 'false';
return $this;
}

Expand All @@ -322,7 +322,7 @@ public function setKeepTransparency($keep)
*/
public function setConstrainOnly($flag)
{
$this->_constrainOnly = (bool)$flag;
$this->_constrainOnly = $flag && $flag !== 'false';
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/ResourceModel/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ public function getChildrenCategories($category)
)->setOrder(
'position',
\Magento\Framework\DB\Select::SQL_ASC
)->joinUrlRewrite()->load();
)->joinUrlRewrite();

return $collection;
}
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/CatalogInventory/Helper/Stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public function __construct(
public function assignStatusToProduct(Product $product, $status = null)
{
if ($status === null) {
$websiteId = $this->getStockConfiguration()->getDefaultScopeId();
$stockStatus = $this->stockRegistryProvider->getStockStatus($product->getId(), $websiteId);
$scopeId = $this->getStockConfiguration()->getDefaultScopeId();
$stockStatus = $this->stockRegistryProvider->getStockStatus($product->getId(), $scopeId);
$status = $stockStatus->getStockStatus();
}
$product->setIsSalable($status);
Expand All @@ -98,10 +98,10 @@ public function assignStatusToProduct(Product $product, $status = null)
*/
public function addStockStatusToProducts(AbstractCollection $productCollection)
{
$websiteId = $this->getStockConfiguration()->getDefaultScopeId();
$scopeId = $this->getStockConfiguration()->getDefaultScopeId();
foreach ($productCollection as $product) {
$productId = $product->getId();
$stockStatus = $this->stockRegistryProvider->getStockStatus($productId, $websiteId);
$stockStatus = $this->stockRegistryProvider->getStockStatus($productId, $scopeId);
$status = $stockStatus->getStockStatus();
$product->setIsSalable($status);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/Block/Cart/Item/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function getProductOptions()
}

/**
* Get list of all otions for product
* Get list of all options for product
*
* @return array
* @codeCoverageIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function execute()
$isSubscribed = $this->getRequest()->getPost('subscription');
}
if ($isSubscribed !== null) {
if ($isSubscribed !== 'false') {
if ($isSubscribed !== '0') {
$this->_subscriberFactory->create()->subscribeCustomerById($customerId);
} else {
$this->_subscriberFactory->create()->unsubscribeCustomerById($customerId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ public function testExecuteWithNewCustomer()
{
$customerId = 22;
$addressId = 11;
$subscription = 'false';
$subscription = '0';
$postValue = [
'customer' => [
'coolness' => false,
Expand Down Expand Up @@ -875,7 +875,7 @@ public function testExecuteWithNewCustomer()
*/
public function testExecuteWithNewCustomerAndValidationException()
{
$subscription = 'false';
$subscription = '0';
$postValue = [
'customer' => [
'coolness' => false,
Expand Down Expand Up @@ -1018,7 +1018,7 @@ public function testExecuteWithNewCustomerAndValidationException()
*/
public function testExecuteWithNewCustomerAndLocalizedException()
{
$subscription = 'false';
$subscription = '0';
$postValue = [
'customer' => [
'coolness' => false,
Expand Down Expand Up @@ -1161,7 +1161,7 @@ public function testExecuteWithNewCustomerAndLocalizedException()
*/
public function testExecuteWithNewCustomerAndException()
{
$subscription = 'false';
$subscription = '0';
$postValue = [
'customer' => [
'coolness' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
if ($item->getProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE
|| $item->getRealProductType() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE
) {
if (in_array($item->getStatusId(), $expiredStatuses)) {
if ($order->isCanceled() || in_array($item->getStatusId(), $expiredStatuses)) {
$downloadableItemsStatuses[$item->getId()] = $linkStatuses['expired'];
} else {
$downloadableItemsStatuses[$item->getId()] = $linkStatuses['avail'];
Expand Down
27 changes: 24 additions & 3 deletions app/code/Magento/PageCache/Controller/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,44 @@
*/
namespace Magento\PageCache\Controller;

use Magento\Framework\Serialize\Serializer\Base64Json;
use Magento\Framework\Serialize\Serializer\Json;

abstract class Block extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Framework\Translate\InlineInterface
*/
protected $translateInline;

/**
* @var Json
*/
private $jsonSerializer;

/**
* @var Base64Json
*/
private $base64jsonSerializer;

/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\Translate\InlineInterface $translateInline
* @param Json $jsonSerializer
* @param Base64Json $base64jsonSerializer
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\Translate\InlineInterface $translateInline
\Magento\Framework\Translate\InlineInterface $translateInline,
Json $jsonSerializer = null,
Base64Json $base64jsonSerializer = null
) {
parent::__construct($context);
$this->translateInline = $translateInline;
$this->jsonSerializer = $jsonSerializer
?: \Magento\Framework\App\ObjectManager::getInstance()->get(Json::class);
$this->base64jsonSerializer = $base64jsonSerializer
?: \Magento\Framework\App\ObjectManager::getInstance()->get(Base64Json::class);
}

/**
Expand All @@ -39,8 +60,8 @@ protected function _getBlocks()
if (!$handles || !$blocks) {
return [];
}
$blocks = json_decode($blocks);
$handles = json_decode($handles);
$blocks = $this->jsonSerializer->unserialize($blocks);
$handles = $this->base64jsonSerializer->unserialize($handles);

$this->_view->loadLayout($handles, true, true, false);
$data = [];
Expand Down
28 changes: 25 additions & 3 deletions app/code/Magento/PageCache/Observer/ProcessLayoutRenderElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\View\EntitySpecificHandlesList;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\Serialize\Serializer\Base64Json;

class ProcessLayoutRenderElement implements ObserverInterface
{
Expand Down Expand Up @@ -37,19 +39,37 @@ class ProcessLayoutRenderElement implements ObserverInterface
*/
private $entitySpecificHandlesList;

/**
* @var Base64Json
*/
private $base64jsonSerializer;

/**
* @var Json
*/
private $jsonSerializer;

/**
* Class constructor
*
* @param \Magento\PageCache\Model\Config $config
* @param EntitySpecificHandlesList $entitySpecificHandlesList
* @param Json $jsonSerializer
* @param Base64Json $base64jsonSerializer
*/
public function __construct(
\Magento\PageCache\Model\Config $config,
EntitySpecificHandlesList $entitySpecificHandlesList = null
EntitySpecificHandlesList $entitySpecificHandlesList = null,
Json $jsonSerializer = null,
Base64Json $base64jsonSerializer = null
) {
$this->_config = $config;
$this->entitySpecificHandlesList = $entitySpecificHandlesList
?: \Magento\Framework\App\ObjectManager::getInstance()->get(EntitySpecificHandlesList::class);
$this->jsonSerializer = $jsonSerializer
?: \Magento\Framework\App\ObjectManager::getInstance()->get(Json::class);
$this->base64jsonSerializer = $base64jsonSerializer
?: \Magento\Framework\App\ObjectManager::getInstance()->get(Base64Json::class);
}

/**
Expand All @@ -68,8 +88,10 @@ private function _wrapEsi(
$url = $block->getUrl(
'page_cache/block/esi',
[
'blocks' => json_encode([$block->getNameInLayout()]),
'handles' => json_encode(array_values(array_diff($handles, $pageSpecificHandles)))
'blocks' => $this->jsonSerializer->serialize([$block->getNameInLayout()]),
'handles' => $this->base64jsonSerializer->serialize(
array_values(array_diff($handles, $pageSpecificHandles))
)
]
);
// Varnish does not support ESI over HTTPS must change to HTTP
Expand Down
12 changes: 10 additions & 2 deletions app/code/Magento/PageCache/Test/Unit/Controller/Block/EsiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Magento\PageCache\Test\Unit\Controller\Block;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class EsiTest extends \PHPUnit_Framework_TestCase
{
/**
Expand Down Expand Up @@ -69,7 +72,12 @@ protected function setUp()
$helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->action = $helperObjectManager->getObject(
\Magento\PageCache\Controller\Block\Esi::class,
['context' => $contextMock, 'translateInline' => $this->translateInline]
[
'context' => $contextMock,
'translateInline' => $this->translateInline,
'jsonSerializer' => new \Magento\Framework\Serialize\Serializer\Json(),
'base64jsonSerializer' => new \Magento\Framework\Serialize\Serializer\Base64Json()
]
);
}

Expand All @@ -83,7 +91,7 @@ public function testExecute($blockClass, $shouldSetHeaders)
$block = 'block';
$handles = ['handle1', 'handle2'];
$html = 'some-html';
$mapData = [['blocks', '', json_encode([$block])], ['handles', '', json_encode($handles)]];
$mapData = [['blocks', '', json_encode([$block])], ['handles', '', base64_encode(json_encode($handles))]];

$blockInstance1 = $this->getMock(
$blockClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Magento\PageCache\Test\Unit\Controller\Block;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class RenderTest extends \PHPUnit_Framework_TestCase
{
/**
Expand Down Expand Up @@ -71,7 +74,12 @@ protected function setUp()
$helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->action = $helperObjectManager->getObject(
\Magento\PageCache\Controller\Block\Render::class,
['context' => $contextMock, 'translateInline' => $this->translateInline]
[
'context' => $contextMock,
'translateInline' => $this->translateInline,
'jsonSerializer' => new \Magento\Framework\Serialize\Serializer\Json(),
'base64jsonSerializer' => new \Magento\Framework\Serialize\Serializer\Base64Json()
]
);
}

Expand Down Expand Up @@ -151,7 +159,7 @@ public function testExecute()
$this->requestMock->expects($this->at(11))
->method('getParam')
->with($this->equalTo('handles'), $this->equalTo(''))
->will($this->returnValue(json_encode($handles)));
->will($this->returnValue(base64_encode(json_encode($handles))));
$this->viewMock->expects($this->once())->method('loadLayout')->with($this->equalTo($handles));
$this->viewMock->expects($this->any())->method('getLayout')->will($this->returnValue($this->layoutMock));
$this->layoutMock->expects($this->at(0))
Expand Down
Loading

0 comments on commit f779ef2

Please sign in to comment.