From 26630ad94c2e04ea6b0205b2d884f18fc1cff5c6 Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Sun, 12 Jan 2025 18:00:29 +0300 Subject: [PATCH 1/7] refactor: Remove deprecated `Config\Security::$samesite` --- app/Config/Security.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/app/Config/Security.php b/app/Config/Security.php index 0858b9bbb257..635f8b77b9b7 100644 --- a/app/Config/Security.php +++ b/app/Config/Security.php @@ -83,21 +83,4 @@ class Security extends BaseConfig * @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure */ public bool $redirect = (ENVIRONMENT === 'production'); - - /** - * -------------------------------------------------------------------------- - * CSRF SameSite - * -------------------------------------------------------------------------- - * - * Setting for CSRF SameSite cookie token. - * - * Allowed values are: None - Lax - Strict - ''. - * - * Defaults to `Lax` as recommended in this link: - * - * @see https://portswigger.net/web-security/csrf/samesite-cookies - * - * @deprecated `Config\Cookie` $samesite property is used. - */ - public string $samesite = 'Lax'; } From a115c4241e8d3710344c4da725c3346e25e8804d Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Sun, 12 Jan 2025 18:38:42 +0300 Subject: [PATCH 2/7] refactor: Remove deprecated methods in `CookieStore` --- system/Cookie/CookieStore.php | 46 ----------------------------------- 1 file changed, 46 deletions(-) diff --git a/system/Cookie/CookieStore.php b/system/Cookie/CookieStore.php index 05ebf9925ee6..6d5caa2aa5e0 100644 --- a/system/Cookie/CookieStore.php +++ b/system/Cookie/CookieStore.php @@ -159,28 +159,6 @@ public function remove(string $name, string $prefix = '') return $store; } - /** - * Dispatches all cookies in store. - * - * @deprecated Response should dispatch cookies. - */ - public function dispatch(): void - { - foreach ($this->cookies as $cookie) { - $name = $cookie->getPrefixedName(); - $value = $cookie->getValue(); - $options = $cookie->getOptions(); - - if ($cookie->isRaw()) { - $this->setRawCookie($name, $value, $options); - } else { - $this->setCookie($name, $value, $options); - } - } - - $this->clear(); - } - /** * Returns all cookie instances in store. * @@ -232,28 +210,4 @@ protected function validateCookies(array $cookies): void } } } - - /** - * Extracted call to `setrawcookie()` in order to run unit tests on it. - * - * @codeCoverageIgnore - * - * @deprecated - */ - protected function setRawCookie(string $name, string $value, array $options): void - { - setrawcookie($name, $value, $options); - } - - /** - * Extracted call to `setcookie()` in order to run unit tests on it. - * - * @codeCoverageIgnore - * - * @deprecated - */ - protected function setCookie(string $name, string $value, array $options): void - { - setcookie($name, $value, $options); - } } From 90960bec89bac54b3f8d5206e2c5f0e09fca03c7 Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Sun, 12 Jan 2025 18:57:50 +0300 Subject: [PATCH 3/7] docs: Update changelog --- user_guide_src/source/changelogs/v4.6.0.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/changelogs/v4.6.0.rst b/user_guide_src/source/changelogs/v4.6.0.rst index 85901cd52743..91f61f5a6a2a 100644 --- a/user_guide_src/source/changelogs/v4.6.0.rst +++ b/user_guide_src/source/changelogs/v4.6.0.rst @@ -203,6 +203,8 @@ Removed Deprecated Items - **View:** The deprecated property ``CodeIgniter\View\View::$currentSection`` has been removed. - **Config:** The deprecated property ``Config\Cache::$storePath`` has been removed. Use ``Config\Cache::$file['storePath']`` instead. - **Formatter:** The deprecated ``Config\Format::getFormatter()`` has been removed. Use ``CodeIgniter\Format\Format::getFormatter()`` instead. +- **Security:** ``Config\Security::$samesite`` has been removed. Use ``Config\Cookie::$samesite`` instead. +- **Cookie:** Methods ``dispatch()``, ``setRawCookie()``, ``setCookie()`` in ``CodeIgniter\Cookie\CookieStore`` has been removed. They are now part of ``CodeIgniter\HTTP\ResponseTrait``. ************ Enhancements From 8caf76c46148621e02f47589d767820e1ab46953 Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Sun, 12 Jan 2025 19:00:10 +0300 Subject: [PATCH 4/7] refactor: Update phpstan baseline --- .../phpstan-baseline/missingType.iterableValue.neon | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index efa0cdea552b..8a99113f5f0f 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -1,4 +1,4 @@ -# total 1667 errors +# total 1665 errors parameters: ignoreErrors: @@ -852,16 +852,6 @@ parameters: count: 1 path: ../../system/Controller.php - - - message: '#^Method CodeIgniter\\Cookie\\CookieStore\:\:setCookie\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Cookie/CookieStore.php - - - - message: '#^Method CodeIgniter\\Cookie\\CookieStore\:\:setRawCookie\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Cookie/CookieStore.php - - message: '#^Method CodeIgniter\\Cookie\\CookieStore\:\:validateCookies\(\) has parameter \$cookies with no value type specified in iterable type array\.$#' count: 1 From 992a89513dbe868a5e44ebac3e71de085311e1da Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Sun, 12 Jan 2025 19:25:35 +0300 Subject: [PATCH 5/7] docs: Update userguide --- user_guide_src/source/libraries/cookies.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/libraries/cookies.rst b/user_guide_src/source/libraries/cookies.rst index c6ac80706829..ae09cb7c685d 100644 --- a/user_guide_src/source/libraries/cookies.rst +++ b/user_guide_src/source/libraries/cookies.rst @@ -228,9 +228,7 @@ the instance with the modified instance. Dispatching Cookies in Store ============================ -.. deprecated:: 4.1.6 - -.. important:: This method is deprecated. It will be removed in future releases. +.. important:: This method is deprecated since 4.1.6 and removed in 4.6.0. More often than not, you do not need to concern yourself in manually sending cookies. CodeIgniter will do this for you. However, if you really need to manually send cookies, you can use the ``dispatch`` method. Just like @@ -484,6 +482,8 @@ Class Reference .. php:method:: dispatch(): void + .. important:: This method is deprecated since 4.1.6 and removed in 4.6.0. + :rtype: void Dispatches all cookies in store. From d36d556f317a4339048fc31ae964be901afc0cb7 Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Sun, 12 Jan 2025 19:31:58 +0300 Subject: [PATCH 6/7] refactor: Remove deprecated `Cookie::withNeverExpiring()` --- system/Cookie/CloneableCookieInterface.php | 9 --------- system/Cookie/Cookie.php | 12 ------------ tests/system/Cookie/CookieTest.php | 2 -- 3 files changed, 23 deletions(-) diff --git a/system/Cookie/CloneableCookieInterface.php b/system/Cookie/CloneableCookieInterface.php index 0b7d6fdf5015..3055129a0b4b 100644 --- a/system/Cookie/CloneableCookieInterface.php +++ b/system/Cookie/CloneableCookieInterface.php @@ -58,15 +58,6 @@ public function withExpires($expires); */ public function withExpired(); - /** - * Creates a new Cookie that will virtually never expire from the browser. - * - * @return static - * - * @deprecated See https://github.com/codeigniter4/CodeIgniter4/pull/6413 - */ - public function withNeverExpiring(); - /** * Creates a new Cookie with a new path on the server the cookie is available. * diff --git a/system/Cookie/Cookie.php b/system/Cookie/Cookie.php index 468254f65336..df75c03c7bcb 100644 --- a/system/Cookie/Cookie.php +++ b/system/Cookie/Cookie.php @@ -465,18 +465,6 @@ public function withExpired() return $cookie; } - /** - * @deprecated See https://github.com/codeigniter4/CodeIgniter4/pull/6413 - */ - public function withNeverExpiring() - { - $cookie = clone $this; - - $cookie->expires = Time::now()->getTimestamp() + 5 * YEAR; - - return $cookie; - } - /** * {@inheritDoc} */ diff --git a/tests/system/Cookie/CookieTest.php b/tests/system/Cookie/CookieTest.php index 7f98e5e1e0b0..e4421a8bc443 100644 --- a/tests/system/Cookie/CookieTest.php +++ b/tests/system/Cookie/CookieTest.php @@ -235,7 +235,6 @@ public function testCloningCookies(): void $e = $a->withValue('muffin'); $f = $a->withExpires('+30 days'); $g = $a->withExpired(); - $h = $a->withNeverExpiring(); $i = $a->withDomain('localhost'); $j = $a->withPath('/web'); $k = $a->withSecure(); @@ -248,7 +247,6 @@ public function testCloningCookies(): void $this->assertNotSame($a, $e); $this->assertNotSame($a, $f); $this->assertNotSame($a, $g); - $this->assertNotSame($a, $h); $this->assertNotSame($a, $i); $this->assertNotSame($a, $j); $this->assertNotSame($a, $k); From b87710c1f2a3ecf4e41f0eaa439cb2ba083b88e4 Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Mon, 13 Jan 2025 00:22:48 +0300 Subject: [PATCH 7/7] docs: Update changelog, userguide --- user_guide_src/source/libraries/cookies.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/libraries/cookies.rst b/user_guide_src/source/libraries/cookies.rst index ae09cb7c685d..00239b0911f7 100644 --- a/user_guide_src/source/libraries/cookies.rst +++ b/user_guide_src/source/libraries/cookies.rst @@ -228,7 +228,7 @@ the instance with the modified instance. Dispatching Cookies in Store ============================ -.. important:: This method is deprecated since 4.1.6 and removed in 4.6.0. +.. important:: This method was deprecated as of version 4.1.6 and was removed in 4.6.0. More often than not, you do not need to concern yourself in manually sending cookies. CodeIgniter will do this for you. However, if you really need to manually send cookies, you can use the ``dispatch`` method. Just like @@ -367,9 +367,7 @@ Class Reference .. php:method:: withNeverExpiring() - .. deprecated:: 4.2.6 - - .. important:: This method is deprecated. It will be removed in future releases. + .. important:: This method was deprecated as of version 4.2.6 and was removed in 4.6.0. :param string $name: :rtype: ``Cookie`` @@ -482,7 +480,7 @@ Class Reference .. php:method:: dispatch(): void - .. important:: This method is deprecated since 4.1.6 and removed in 4.6.0. + .. important:: This method was deprecated as of version 4.1.6 and was removed in 4.6.0. :rtype: void