Skip to content

Commit 2951e0a

Browse files
Merge pull request #1482 from magento-engcom/2.1-develop-prs
[EngCom] Public Pull Requests - 2.1 - MAGETWO-72254: Backport PR-9713 for Magento 2.1 - stringify cookie value to fix #5596 #10749
2 parents 8390ef4 + ee022ac commit 2951e0a

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

app/code/Magento/Cookie/Helper/Cookie.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,22 @@ public function __construct(
6969
public function isUserNotAllowSaveCookie()
7070
{
7171
$acceptedSaveCookiesWebsites = $this->_getAcceptedSaveCookiesWebsites();
72+
return $this->isCookieRestrictionModeEnabled() &&
73+
empty($acceptedSaveCookiesWebsites[$this->_website->getId()]);
74+
}
75+
76+
/**
77+
* Check if cookie restriction mode is enabled for this store
78+
*
79+
* @return bool
80+
*/
81+
public function isCookieRestrictionModeEnabled()
82+
{
7283
return $this->scopeConfig->getValue(
7384
self::XML_PATH_COOKIE_RESTRICTION,
7485
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
7586
$this->_currentStore
76-
) && empty($acceptedSaveCookiesWebsites[$this->_website->getId()]);
87+
);
7788
}
7889

7990
/**

app/code/Magento/Cookie/view/frontend/templates/html/notices.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
?>
1010
<?php /** @var \Magento\Cookie\Block\Html\Notices $block */ ?>
11-
<?php if ($this->helper('Magento\Cookie\Helper\Cookie')->isUserNotAllowSaveCookie()): ?>
11+
<?php if ($this->helper('Magento\Cookie\Helper\Cookie')->isCookieRestrictionModeEnabled()): ?>
1212
<div class="message global cookie" id="notice-cookie-block" style="display: none">
1313
<div class="content">
1414
<p>

app/code/Magento/Cookie/view/frontend/web/js/notices.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ define([
2020
$(this.options.cookieAllowButtonSelector).on('click', $.proxy(function() {
2121
var cookieExpires = new Date(new Date().getTime() + this.options.cookieLifetime * 1000);
2222

23-
$.mage.cookies.set(this.options.cookieName, this.options.cookieValue, {expires: cookieExpires});
23+
$.mage.cookies.set(this.options.cookieName, JSON.stringify(this.options.cookieValue), {
24+
expires: cookieExpires
25+
});
26+
2427
if ($.mage.cookies.get(this.options.cookieName)) {
2528
window.location.reload();
2629
} else {

dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected function _getAdapter($adapterType)
116116
{
117117
try {
118118
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
119-
$adapter = $objectManager->get('Magento\Framework\Image\AdapterFactory')->create($adapterType);
119+
$adapter = $objectManager->get(\Magento\Framework\Image\AdapterFactory::class)->create($adapterType);
120120
return $adapter;
121121
} catch (\Exception $e) {
122122
$this->markTestSkipped($e->getMessage());
@@ -547,15 +547,15 @@ public function cropDataProvider()
547547
*/
548548
public function testCreatePngFromString($pixel1, $expectedColor1, $pixel2, $expectedColor2, $adapterType)
549549
{
550-
if (!function_exists('imagettfbbox')) {
551-
$this->markTestSkipped('Workaround of problem with imagettfbbox function on Travis');
550+
if (!function_exists('imagettfbbox') || (getenv('TRAVIS'))) {
551+
$this->markTestSkipped('Workaround for problem with imagettfbbox() function on Travis');
552552
}
553553

554554
$adapter = $this->_getAdapter($adapterType);
555555

556556
/** @var \Magento\Framework\Filesystem\Directory\ReadFactory readFactory */
557557
$readFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
558-
'Magento\Framework\Filesystem\Directory\ReadFactory'
558+
\Magento\Framework\Filesystem\Directory\ReadFactory::class
559559
);
560560
$reader = $readFactory->create(BP);
561561
$path = $reader->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_Re-4.4.1.ttf');
@@ -611,7 +611,7 @@ public function createPngFromStringDataProvider()
611611
public function testValidateUploadFile()
612612
{
613613
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
614-
$imageAdapter = $objectManager->get('Magento\Framework\Image\AdapterFactory')->create();
614+
$imageAdapter = $objectManager->get(\Magento\Framework\Image\AdapterFactory::class)->create();
615615
$this->assertTrue($imageAdapter->validateUploadFile($this->_getFixture('magento_thumbnail.jpg')));
616616
}
617617

@@ -621,7 +621,7 @@ public function testValidateUploadFile()
621621
public function testValidateUploadFileException()
622622
{
623623
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
624-
$imageAdapter = $objectManager->get('Magento\Framework\Image\AdapterFactory')->create();
624+
$imageAdapter = $objectManager->get(\Magento\Framework\Image\AdapterFactory::class)->create();
625625
$imageAdapter->validateUploadFile(__FILE__);
626626
}
627627
}

0 commit comments

Comments
 (0)