Skip to content

Commit 8cfc85c

Browse files
brideorostyslav-hymon
authored andcommitted
ISSUE-14109: Allow modification of cookies via extension
1 parent cec4bf4 commit 8cfc85c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ private function checkAbilityToSendCookie($name, $value)
204204

205205
$sizeOfCookie = $this->sizeOfCookie($name, $value);
206206

207-
if ($numCookies > PhpCookieManager::MAX_NUM_COOKIES) {
207+
if ($numCookies > static::MAX_NUM_COOKIES) {
208208
$this->logger->warning(
209209
new Phrase('Unable to send the cookie. Maximum number of cookies would be exceeded.'),
210210
array_merge($_COOKIE, ['user-agent' => $this->httpHeader->getHttpUserAgent()])
211211
);
212212
}
213213

214-
if ($sizeOfCookie > PhpCookieManager::MAX_COOKIE_SIZE) {
214+
if ($sizeOfCookie > static::MAX_COOKIE_SIZE) {
215215
throw new CookieSizeLimitReachedException(
216216
new Phrase(
217217
'Unable to send the cookie. Size of \'%name\' is %size bytes.',

lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ class PhpCookieManagerTest extends \PHPUnit\Framework\TestCase
4747
const COOKIE_HTTP_ONLY = true;
4848
const COOKIE_NOT_HTTP_ONLY = false;
4949
const COOKIE_EXPIRE_END_OF_SESSION = 0;
50-
const MAX_NUM_COOKIES = 50;
51-
const MAX_COOKIE_SIZE = 4096;
5250

5351
/**
5452
* Mapping from constant names to functions that handle the assertions.
@@ -499,7 +497,9 @@ public function testSetCookieSizeTooLarge()
499497
);
500498

501499
$cookieValue = '';
502-
for ($i = 0; $i < self::MAX_COOKIE_SIZE + 1; $i++) {
500+
501+
$cookieManager = $this->cookieManager;
502+
for ($i = 0; $i < $cookieManager::MAX_COOKIE_SIZE + 1; $i++) {
503503
$cookieValue = $cookieValue . 'a';
504504
}
505505

@@ -527,8 +527,9 @@ public function testSetTooManyCookies()
527527

528528
$userAgent = 'some_user_agent';
529529

530-
// Set self::MAX_NUM_COOKIES number of cookies in superglobal $_COOKIE.
531-
for ($i = count($_COOKIE); $i < self::MAX_NUM_COOKIES; $i++) {
530+
$cookieManager = $this->cookieManager;
531+
// Set $cookieManager::MAX_NUM_COOKIES number of cookies in superglobal $_COOKIE.
532+
for ($i = count($_COOKIE); $i < $cookieManager::MAX_NUM_COOKIES; $i++) {
532533
$_COOKIE['test_cookie_' . $i] = self::COOKIE_VALUE . '_' . $i;
533534
}
534535

0 commit comments

Comments
 (0)