Skip to content

Commit c744040

Browse files
author
Stanislav Idolov
authored
ENGCOM-1019: ISSUE-14109: Allow modification of cookies via extension #14128
2 parents 618c9d7 + c740037 commit c744040

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
@@ -48,8 +48,6 @@ class PhpCookieManagerTest extends \PHPUnit\Framework\TestCase
4848
const COOKIE_HTTP_ONLY = true;
4949
const COOKIE_NOT_HTTP_ONLY = false;
5050
const COOKIE_EXPIRE_END_OF_SESSION = 0;
51-
const MAX_NUM_COOKIES = 50;
52-
const MAX_COOKIE_SIZE = 4096;
5351

5452
/**
5553
* Mapping from constant names to functions that handle the assertions.
@@ -533,7 +531,9 @@ public function testSetCookieSizeTooLarge()
533531
);
534532

535533
$cookieValue = '';
536-
for ($i = 0; $i < self::MAX_COOKIE_SIZE + 1; $i++) {
534+
535+
$cookieManager = $this->cookieManager;
536+
for ($i = 0; $i < $cookieManager::MAX_COOKIE_SIZE + 1; $i++) {
537537
$cookieValue = $cookieValue . 'a';
538538
}
539539

@@ -561,8 +561,9 @@ public function testSetTooManyCookies()
561561

562562
$userAgent = 'some_user_agent';
563563

564-
// Set self::MAX_NUM_COOKIES number of cookies in superglobal $_COOKIE.
565-
for ($i = count($_COOKIE); $i < self::MAX_NUM_COOKIES; $i++) {
564+
$cookieManager = $this->cookieManager;
565+
// Set $cookieManager::MAX_NUM_COOKIES number of cookies in superglobal $_COOKIE.
566+
for ($i = count($_COOKIE); $i < $cookieManager::MAX_NUM_COOKIES; $i++) {
566567
$_COOKIE['test_cookie_' . $i] = self::COOKIE_VALUE . '_' . $i;
567568
}
568569

0 commit comments

Comments
 (0)