From 04d4cbc3f2579e03d303cd859620f1c1f1da0706 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Jan 2023 01:54:57 +0000 Subject: [PATCH 01/56] chore(deps-dev): update rector/rector requirement from 0.15.2 to 0.15.3 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.2...0.15.3) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 50bd5e6dacac..b597ada4b887 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "phpunit/phpcov": "^8.2", "phpunit/phpunit": "^9.1", "predis/predis": "^1.1 || ^2.0", - "rector/rector": "0.15.2", + "rector/rector": "0.15.3", "vimeo/psalm": "^5.0" }, "suggest": { From 4f54e7e42c3fa7d00d4899ca487040431b96a2d7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 9 Jan 2023 16:24:35 +0900 Subject: [PATCH 02/56] docs: add links to GitHub Actions to watch --- admin/RELEASE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/RELEASE.md b/admin/RELEASE.md index e5ab1b4d70ba..1b0554d4063c 100644 --- a/admin/RELEASE.md +++ b/admin/RELEASE.md @@ -73,9 +73,9 @@ cd release-test composer test && composer info codeigniter4/framework ``` * Verify that the user guide actions succeeded: - * "Deploy Distributable Repos", framework repo - * "Deploy Production", UG repo - * "pages-build-deployment", UG repo + * "[Deploy Distributable Repos](https://github.com/codeigniter4/CodeIgniter4/actions/workflows/deploy-distributables.yml)", the main repo + * "[Deploy Production](https://github.com/codeigniter4/userguide/actions/workflows/deploy.yml)", UG repo + * "[pages-build-deployment](https://github.com/codeigniter4/userguide/actions/workflows/pages/pages-build-deployment)", UG repo * Fast-forward `develop` branch to catch the merge commit from `master` ```console git fetch origin From c884200546fee0c832342573cbf52e2014e4d829 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 10 Jan 2023 15:21:36 +0900 Subject: [PATCH 03/56] docs: add missing link to CHANGELOG.md --- user_guide_src/source/changelogs/v4.3.0.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/user_guide_src/source/changelogs/v4.3.0.rst b/user_guide_src/source/changelogs/v4.3.0.rst index 671ce5c6cf0f..ed6047cd320e 100644 --- a/user_guide_src/source/changelogs/v4.3.0.rst +++ b/user_guide_src/source/changelogs/v4.3.0.rst @@ -369,3 +369,7 @@ Bugs Fixed - Fixed a bug with variable filtering in JSON requests using with ``IncomingRequest::getVar()`` or ``IncomingRequest::getJsonVar()`` methods. - Fixed a bug when variable type may be changed when using a specified index with ``IncomingRequest::getVar()`` or ``IncomingRequest::getJsonVar()`` methods. - Fixed a bug that Honeypot field appears when CSP is enabled. See also :ref:`upgrade-430-honeypot-and-csp`. + +See the repo's +`CHANGELOG.md `_ +for a complete list of bugs fixed. From 068a0fa5449013ad27639325b970a18fbf5a8e32 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 10 Jan 2023 15:27:11 +0900 Subject: [PATCH 04/56] docs: add changelog v4.3.1 --- user_guide_src/source/changelogs/index.rst | 1 + user_guide_src/source/changelogs/v4.3.1.rst | 29 +++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 user_guide_src/source/changelogs/v4.3.1.rst diff --git a/user_guide_src/source/changelogs/index.rst b/user_guide_src/source/changelogs/index.rst index 29f118e55f86..401d178f285f 100644 --- a/user_guide_src/source/changelogs/index.rst +++ b/user_guide_src/source/changelogs/index.rst @@ -12,6 +12,7 @@ See all the changes. .. toctree:: :titlesonly: + v4.3.1 v4.3.0 v4.2.12 v4.2.11 diff --git a/user_guide_src/source/changelogs/v4.3.1.rst b/user_guide_src/source/changelogs/v4.3.1.rst new file mode 100644 index 000000000000..e1eb66188411 --- /dev/null +++ b/user_guide_src/source/changelogs/v4.3.1.rst @@ -0,0 +1,29 @@ +Version 4.3.1 +############# + +Release Date: Unreleased + +**4.3.1 release of CodeIgniter4** + +.. contents:: + :local: + :depth: 3 + +BREAKING +******** + +Message Changes +*************** + +Changes +******* + +Deprecations +************ + +Bugs Fixed +********** + +See the repo's +`CHANGELOG.md `_ +for a complete list of bugs fixed. From 16453ff158fb33d12c26da341cc9c7221de5268c Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 10 Jan 2023 15:27:36 +0900 Subject: [PATCH 05/56] docs: update changelog templates --- admin/next-changelog-minor.rst | 4 +++- admin/next-changelog-patch.rst | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/admin/next-changelog-minor.rst b/admin/next-changelog-minor.rst index 310dffdeafa2..f5bb20004d77 100644 --- a/admin/next-changelog-minor.rst +++ b/admin/next-changelog-minor.rst @@ -71,4 +71,6 @@ Deprecations Bugs Fixed ********** -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG.md `_ +for a complete list of bugs fixed. diff --git a/admin/next-changelog-patch.rst b/admin/next-changelog-patch.rst index 2761f6b90434..4c76ca01a112 100644 --- a/admin/next-changelog-patch.rst +++ b/admin/next-changelog-patch.rst @@ -12,9 +12,6 @@ Release Date: Unreleased BREAKING ******** -Enhancements -************ - Message Changes *************** @@ -27,4 +24,6 @@ Deprecations Bugs Fixed ********** -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG.md `_ +for a complete list of bugs fixed. From 50838c3621d37b889dc4bce24be972cec41bb5fe Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 10 Jan 2023 15:29:38 +0900 Subject: [PATCH 06/56] docs: remove empty sections --- user_guide_src/source/changelogs/v4.2.3.rst | 15 --------------- user_guide_src/source/changelogs/v4.2.5.rst | 10 ---------- user_guide_src/source/changelogs/v4.2.6.rst | 15 --------------- user_guide_src/source/changelogs/v4.2.7.rst | 15 --------------- user_guide_src/source/changelogs/v4.2.8.rst | 20 -------------------- 5 files changed, 75 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.2.3.rst b/user_guide_src/source/changelogs/v4.2.3.rst index cfa036fd69b8..69a2889a810e 100644 --- a/user_guide_src/source/changelogs/v4.2.3.rst +++ b/user_guide_src/source/changelogs/v4.2.3.rst @@ -9,26 +9,11 @@ Release Date: August 6, 2022 :local: :depth: 2 -BREAKING -******** - -none. - Enhancements ************ - Now ``Security::generateHash()`` is public, and can be used to regenerate CSRF token manually when ``Config\Security::$regenerate`` is false. -Changes -******* - -none. - -Deprecations -************ - -none. - Bugs Fixed ********** diff --git a/user_guide_src/source/changelogs/v4.2.5.rst b/user_guide_src/source/changelogs/v4.2.5.rst index c9ff36b05508..96908b750843 100644 --- a/user_guide_src/source/changelogs/v4.2.5.rst +++ b/user_guide_src/source/changelogs/v4.2.5.rst @@ -21,16 +21,6 @@ Enhancements - Kint has been updated to 4.2.0. -Changes -******* - -none. - -Deprecations -************ - -none. - Bugs Fixed ********** - When using subqueries in the main query, prefixes are added to the table alias. diff --git a/user_guide_src/source/changelogs/v4.2.6.rst b/user_guide_src/source/changelogs/v4.2.6.rst index 0b86636e0dcb..154927470ba7 100644 --- a/user_guide_src/source/changelogs/v4.2.6.rst +++ b/user_guide_src/source/changelogs/v4.2.6.rst @@ -9,21 +9,6 @@ Release Date: September 4, 2022 :local: :depth: 2 -BREAKING -******** - -none. - -Enhancements -************ - -none. - -Changes -******* - -none. - Deprecations ************ diff --git a/user_guide_src/source/changelogs/v4.2.7.rst b/user_guide_src/source/changelogs/v4.2.7.rst index c7d29b0ce70e..920ba72761ce 100644 --- a/user_guide_src/source/changelogs/v4.2.7.rst +++ b/user_guide_src/source/changelogs/v4.2.7.rst @@ -22,27 +22,12 @@ BREAKING - ``Time::__toString()`` is now locale-independent. It returns database-compatible strings like '2022-09-07 12:00:00' in any locale. - The Validation rule ``Validation\Rule::required_without()`` and ``Validation\StrictRules\Rule::required_without()`` parameters have been changed and the logic of these rule has also been fixed. -Enhancements -************ - -none. - Message Changes *************** - Fixed typos in some items in ``Language/en/Email.php``. - Added missing item ``valid_json`` in ``Language/en/Validation.php``. -Changes -******* - -none. - -Deprecations -************ - -none. - Bugs Fixed ********** diff --git a/user_guide_src/source/changelogs/v4.2.8.rst b/user_guide_src/source/changelogs/v4.2.8.rst index 0463b4883def..4b6d83c98a6a 100644 --- a/user_guide_src/source/changelogs/v4.2.8.rst +++ b/user_guide_src/source/changelogs/v4.2.8.rst @@ -9,26 +9,6 @@ Release Date: October 30, 2022 :local: :depth: 2 -BREAKING -******** - -none. - -Enhancements -************ - -none. - -Message Changes -*************** - -none. - -Changes -******* - -none. - Deprecations ************ From ad085a2a09a794e836609341bc41a55cabb9f30f Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 10 Jan 2023 15:12:16 +0900 Subject: [PATCH 07/56] docs: update RELEASE.md for minor version release --- admin/RELEASE.md | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/admin/RELEASE.md b/admin/RELEASE.md index 1b0554d4063c..cfa7fe3bcdb6 100644 --- a/admin/RELEASE.md +++ b/admin/RELEASE.md @@ -2,9 +2,17 @@ > Documentation guide based on the releases of `4.0.5` and `4.1.0` on January 31, 2021. > -> Updated for `4.2.10` on November 5, 2022. +> Updated for `4.3.0` on January 10, 2023. > -> -MGatner +> -MGatner, kenjis + +## [Minor version only] Merge minor version branch into develop + +If you release a new minor version. + +* Create PR to merge `4.x` into `develop` and merge it +* Delete the merged `4.x` branch (This closes all PRs to the branch) +* Do the regular release process. Go to the next "Changelog" section ## Changelog @@ -17,7 +25,20 @@ When generating the changelog each Pull Request to be included must have one of PRs with breaking changes must have the following additional label: - **breaking change** ... PRs that may break existing functionalities -To auto-generate, start drafting a new Release and use the "Generate release notes" button. +### Generate Changelog + +To auto-generate, navigate to the [Releases](https://github.com/codeigniter4/CodeIgniter4/releases) page, +click the "Draft a new release" button. + +* Tag: "v4.x.x" (Create new tag) +* Target: develop + +Click the "Generate release notes" button. + +Check the resulting content. If there are items in the *Others* section which +should be included in the changelog, add a label to the PR and regenerate +the changelog. + Copy the resulting content into **CHANGELOG.md** and adjust the format to match the existing content. ## Preparation @@ -92,6 +113,13 @@ git merge origin/4.x git merge origin/develop git push origin HEAD ``` +* [Minor version only] Create the next minor upgrade branch `4.x`: +```console +git fetch origin +git switch develop +git switch -c 4.x +git push origin HEAD +``` * Publish any Security Advisories that were resolved from private forks * Announce the release on the forums and Slack channel (note: this forum is restricted to administrators): * Make a new topic in the "News & Discussion" forums: https://forum.codeigniter.com/forum-2.html From d76f051d029a0ac93225ef14536858939870b595 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 10 Jan 2023 16:10:12 +0900 Subject: [PATCH 08/56] docs: update from version --- user_guide_src/source/installation/upgrade_430.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index 69a4e756b2e0..0f1ada0ba9ab 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -1,6 +1,6 @@ -############################# -Upgrading from 4.2.9 to 4.3.0 -############################# +############################## +Upgrading from 4.2.12 to 4.3.0 +############################## Please refer to the upgrade instructions corresponding to your installation method. From 130225eb469105bd04a292150247c3a6cbdfc5d4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 10 Jan 2023 19:52:21 +0900 Subject: [PATCH 09/56] style: break long line --- system/Email/Email.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/Email/Email.php b/system/Email/Email.php index d113398d5dab..488a5ee76f04 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -1539,7 +1539,11 @@ public function send($autoClear = true) $this->setReplyTo($this->headers['From']); } - if (empty($this->recipients) && ! isset($this->headers['To']) && empty($this->BCCArray) && ! isset($this->headers['Bcc']) && ! isset($this->headers['Cc'])) { + if ( + empty($this->recipients) && ! isset($this->headers['To']) + && empty($this->BCCArray) && ! isset($this->headers['Bcc']) + && ! isset($this->headers['Cc']) + ) { $this->setErrorMessage(lang('Email.noRecipients')); return false; From 97736e22b5ac20dd7a31f20825eb2a76004fffe3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 10 Jan 2023 19:51:40 +0900 Subject: [PATCH 10/56] fix: Email config in the .env doesn't appear as expected Initialize typed properties. --- app/Config/Email.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Config/Email.php b/app/Config/Email.php index 729e8957f9ab..01350186a3e9 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -6,9 +6,9 @@ class Email extends BaseConfig { - public string $fromEmail; - public string $fromName; - public string $recipients; + public string $fromEmail = ''; + public string $fromName = ''; + public string $recipients = ''; /** * The "user agent" @@ -28,17 +28,17 @@ class Email extends BaseConfig /** * SMTP Server Address */ - public string $SMTPHost; + public string $SMTPHost = ''; /** * SMTP Username */ - public string $SMTPUser; + public string $SMTPUser = ''; /** * SMTP Password */ - public string $SMTPPass; + public string $SMTPPass = ''; /** * SMTP Port From 6ada20b06ba4e9691ff9c119e3c0f49094c8a8da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Jan 2023 15:04:35 +0000 Subject: [PATCH 11/56] chore(deps-dev): update rector/rector requirement from 0.15.3 to 0.15.4 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.3...0.15.4) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b597ada4b887..2cd21cd2aec8 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "phpunit/phpcov": "^8.2", "phpunit/phpunit": "^9.1", "predis/predis": "^1.1 || ^2.0", - "rector/rector": "0.15.3", + "rector/rector": "0.15.4", "vimeo/psalm": "^5.0" }, "suggest": { From 84507394cd0a295ca604bcff186a8a3b279c17a7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 09:36:16 +0900 Subject: [PATCH 12/56] fix: revert method name changed accidentally --- system/Database/BaseBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 3142aa18d01b..11250b54fd0b 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -3274,7 +3274,7 @@ protected function isLiteral(string $str): bool * * @return $this */ - public function resetQueryAsData() + public function resetQuery() { $this->resetSelect(); $this->resetWrite(); @@ -3456,7 +3456,7 @@ protected function setBind(string $key, $value = null, bool $escape = true): str */ protected function cleanClone() { - return (clone $this)->from([], true)->resetQueryAsData(); + return (clone $this)->from([], true)->resetQuery(); } /** From 7d195e3a580141b7d1488af2007c4df2b12357e8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 10:30:52 +0900 Subject: [PATCH 13/56] test: refactor: remove duplicate code --- .../Validation/DatabaseRelatedRulesTest.php | 182 +----------------- .../StrictRules/DatabaseRelatedRulesTest.php | 8 +- 2 files changed, 8 insertions(+), 182 deletions(-) diff --git a/tests/system/Validation/DatabaseRelatedRulesTest.php b/tests/system/Validation/DatabaseRelatedRulesTest.php index 42881bab444e..ec98605fba05 100644 --- a/tests/system/Validation/DatabaseRelatedRulesTest.php +++ b/tests/system/Validation/DatabaseRelatedRulesTest.php @@ -11,10 +11,7 @@ namespace CodeIgniter\Validation; -use CodeIgniter\Test\CIUnitTestCase; -use CodeIgniter\Test\DatabaseTestTrait; -use Config\Database; -use Config\Services; +use CodeIgniter\Validation\StrictRules\DatabaseRelatedRulesTest as StrictDatabaseRelatedRulesTest; use Tests\Support\Validation\TestRules; /** @@ -22,12 +19,9 @@ * * @group DatabaseLive */ -final class DatabaseRelatedRulesTest extends CIUnitTestCase +final class DatabaseRelatedRulesTest extends StrictDatabaseRelatedRulesTest { - use DatabaseTestTrait; - - private Validation $validation; - private array $config = [ + protected array $config = [ 'ruleSets' => [ Rules::class, FormatRules::class, @@ -44,174 +38,4 @@ final class DatabaseRelatedRulesTest extends CIUnitTestCase ], ], ]; - - protected function setUp(): void - { - parent::setUp(); - $this->validation = new Validation((object) $this->config, Services::renderer()); - $this->validation->reset(); - } - - public function testIsUniqueFalse(): void - { - Database::connect() - ->table('user') - ->insert([ - 'name' => 'Derek Travis', - 'email' => 'derek@world.com', - 'country' => 'Elbonia', - ]); - - $data = ['email' => 'derek@world.com']; - $this->validation->setRules(['email' => 'is_unique[user.email]']); - $this->assertFalse($this->validation->run($data)); - } - - public function testIsUniqueTrue(): void - { - $data = ['email' => 'derek@world.co.uk']; - $this->validation->setRules(['email' => 'is_unique[user.email]']); - $this->assertTrue($this->validation->run($data)); - } - - public function testIsUniqueIgnoresParams(): void - { - $db = Database::connect(); - $db - ->table('user') - ->insert([ - 'name' => 'Developer A', - 'email' => 'deva@example.com', - 'country' => 'Elbonia', - ]); - $row = $db->table('user') - ->limit(1) - ->get() - ->getRow(); - - $data = ['email' => 'derek@world.co.uk']; - $this->validation->setRules(['email' => "is_unique[user.email,id,{$row->id}]"]); - $this->assertTrue($this->validation->run($data)); - } - - public function testIsUniqueIgnoresParamsPlaceholders(): void - { - $this->hasInDatabase('user', [ - 'name' => 'Derek', - 'email' => 'derek@world.co.uk', - 'country' => 'GB', - ]); - - $row = Database::connect() - ->table('user') - ->limit(1) - ->get() - ->getRow(); - - $data = [ - 'id' => $row->id, - 'email' => 'derek@world.co.uk', - ]; - - $this->validation->setRules(['email' => 'is_unique[user.email,id,{id}]']); - $this->assertTrue($this->validation->run($data)); - } - - public function testIsUniqueByManualRun(): void - { - Database::connect() - ->table('user') - ->insert([ - 'name' => 'Developer A', - 'email' => 'deva@example.com', - 'country' => 'Elbonia', - ]); - - $this->assertFalse((new Rules())->is_unique('deva@example.com', 'user.email,id,{id}', [])); - } - - public function testIsNotUniqueFalse(): void - { - Database::connect() - ->table('user') - ->insert([ - 'name' => 'Derek Travis', - 'email' => 'derek@world.com', - 'country' => 'Elbonia', - ]); - - $data = ['email' => 'derek1@world.com']; - $this->validation->setRules(['email' => 'is_not_unique[user.email]']); - $this->assertFalse($this->validation->run($data)); - } - - public function testIsNotUniqueTrue(): void - { - Database::connect() - ->table('user') - ->insert([ - 'name' => 'Derek Travis', - 'email' => 'derek@world.com', - 'country' => 'Elbonia', - ]); - - $data = ['email' => 'derek@world.com']; - $this->validation->setRules(['email' => 'is_not_unique[user.email]']); - $this->assertTrue($this->validation->run($data)); - } - - public function testIsNotUniqueIgnoresParams(): void - { - $db = Database::connect(); - $db->table('user') - ->insert([ - 'name' => 'Developer A', - 'email' => 'deva@example.com', - 'country' => 'Elbonia', - ]); - - $row = $db->table('user') - ->limit(1) - ->get() - ->getRow(); - - $data = ['email' => 'derek@world.co.uk']; - $this->validation->setRules(['email' => "is_not_unique[user.email,id,{$row->id}]"]); - $this->assertFalse($this->validation->run($data)); - } - - public function testIsNotUniqueIgnoresParamsPlaceholders(): void - { - $this->hasInDatabase('user', [ - 'name' => 'Derek', - 'email' => 'derek@world.co.uk', - 'country' => 'GB', - ]); - - $row = Database::connect() - ->table('user') - ->limit(1) - ->get() - ->getRow(); - - $data = [ - 'id' => $row->id, - 'email' => 'derek@world.co.uk', - ]; - $this->validation->setRules(['email' => 'is_not_unique[user.email,id,{id}]']); - $this->assertTrue($this->validation->run($data)); - } - - public function testIsNotUniqueByManualRun(): void - { - Database::connect() - ->table('user') - ->insert([ - 'name' => 'Developer A', - 'email' => 'deva@example.com', - 'country' => 'Elbonia', - ]); - - $this->assertTrue((new Rules())->is_not_unique('deva@example.com', 'user.email,id,{id}', [])); - } } diff --git a/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php b/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php index 79c9c7d39e9f..b17319fe5951 100644 --- a/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php +++ b/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php @@ -21,14 +21,16 @@ /** * @internal * + * @no-final + * * @group DatabaseLive */ -final class DatabaseRelatedRulesTest extends CIUnitTestCase +class DatabaseRelatedRulesTest extends CIUnitTestCase { use DatabaseTestTrait; - private Validation $validation; - private array $config = [ + protected Validation $validation; + protected array $config = [ 'ruleSets' => [ Rules::class, FormatRules::class, From 7f789ace3f2d7793ccf0e0ff8b1cbe0ae5d648b6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 10:35:40 +0900 Subject: [PATCH 14/56] test: fix wrong Rules instance --- tests/system/Validation/DatabaseRelatedRulesTest.php | 5 +++++ .../Validation/StrictRules/DatabaseRelatedRulesTest.php | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/system/Validation/DatabaseRelatedRulesTest.php b/tests/system/Validation/DatabaseRelatedRulesTest.php index ec98605fba05..e9abd11f83aa 100644 --- a/tests/system/Validation/DatabaseRelatedRulesTest.php +++ b/tests/system/Validation/DatabaseRelatedRulesTest.php @@ -38,4 +38,9 @@ final class DatabaseRelatedRulesTest extends StrictDatabaseRelatedRulesTest ], ], ]; + + protected function createRules() + { + return new Rules(); + } } diff --git a/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php b/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php index b17319fe5951..a1003899f8e9 100644 --- a/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php +++ b/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php @@ -55,6 +55,11 @@ protected function setUp(): void $this->validation->reset(); } + protected function createRules() + { + return new Rules(); + } + public function testIsUniqueFalse(): void { Database::connect() @@ -130,7 +135,7 @@ public function testIsUniqueByManualRun(): void 'country' => 'Elbonia', ]); - $this->assertFalse((new Rules())->is_unique('deva@example.com', 'user.email,id,{id}', [])); + $this->assertFalse($this->createRules()->is_unique('deva@example.com', 'user.email,id,{id}', [])); } public function testIsNotUniqueFalse(): void @@ -215,6 +220,6 @@ public function testIsNotUniqueByManualRun(): void 'country' => 'Elbonia', ]); - $this->assertTrue((new Rules())->is_not_unique('deva@example.com', 'user.email,id,{id}', [])); + $this->assertTrue($this->createRules()->is_not_unique('deva@example.com', 'user.email,id,{id}', [])); } } From 5ab8487749727a8eb0feca7e8047c994d5d81ef3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 10:38:42 +0900 Subject: [PATCH 15/56] test: add test for is_unique and int value --- .../StrictRules/DatabaseRelatedRulesTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php b/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php index a1003899f8e9..9b56dc3e3205 100644 --- a/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php +++ b/tests/system/Validation/StrictRules/DatabaseRelatedRulesTest.php @@ -138,6 +138,21 @@ public function testIsUniqueByManualRun(): void $this->assertFalse($this->createRules()->is_unique('deva@example.com', 'user.email,id,{id}', [])); } + public function testIsUniqueIntValueByManualRun(): void + { + Database::connect() + ->table('user') + ->insert([ + 'name' => 'Developer A', + 'email' => 'deva@example.com', + 'country' => 'Elbonia', + ]); + + $result = $this->createRules()->is_unique(1, 'user.id', []); + + $this->assertFalse($result); + } + public function testIsNotUniqueFalse(): void { Database::connect() From d7099ccdf874a5274af47df67c545a6692cbd0e1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 10:53:01 +0900 Subject: [PATCH 16/56] fix: TypeError in Rules::is_unique() TypeError : CodeIgniter\Validation\Rules::is_unique(): Argument #1 ($str) must be of type ?string, int given, called in /.../CodeIgniter4/system/Validation/StrictRules/Rules.php on line 154 /.../CodeIgniter4/system/Validation/Rules.php:126 --- system/Validation/Rules.php | 26 ++++++++++++------------- system/Validation/StrictRules/Rules.php | 20 ++++++++++++++++++- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index 40a5955b157d..c8284629d3b3 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -11,6 +11,7 @@ namespace CodeIgniter\Validation; +use CodeIgniter\Validation\StrictRules\Rules as StrictRules; use Config\Database; use InvalidArgumentException; @@ -19,6 +20,15 @@ */ class Rules { + private ?StrictRules $strictRules = null; + + private function createStrictRules(): void + { + if ($this->strictRules === null) { + $this->strictRules = new StrictRules(); + } + } + /** * The value does not match another field in $data. * @@ -125,21 +135,9 @@ public function in_list(?string $value, string $list): bool */ public function is_unique(?string $str, string $field, array $data): bool { - [$field, $ignoreField, $ignoreValue] = array_pad(explode(',', $field), 3, null); - - sscanf($field, '%[^.].%[^.]', $table, $field); - - $row = Database::connect($data['DBGroup'] ?? null) - ->table($table) - ->select('1') - ->where($field, $str) - ->limit(1); - - if (! empty($ignoreField) && ! empty($ignoreValue) && ! preg_match('/^\{(\w+)\}$/', $ignoreValue)) { - $row = $row->where("{$ignoreField} !=", $ignoreValue); - } + $this->createStrictRules(); - return $row->get()->getRow() === null; + return $this->strictRules->is_unique($str, $field, $data); } /** diff --git a/system/Validation/StrictRules/Rules.php b/system/Validation/StrictRules/Rules.php index 47dbee9b5ae7..1091b319f43f 100644 --- a/system/Validation/StrictRules/Rules.php +++ b/system/Validation/StrictRules/Rules.php @@ -151,7 +151,25 @@ public function in_list($value, string $list): bool */ public function is_unique($str, string $field, array $data): bool { - return $this->nonStrictRules->is_unique($str, $field, $data); + [$field, $ignoreField, $ignoreValue] = array_pad( + explode(',', $field), + 3, + null + ); + + sscanf($field, '%[^.].%[^.]', $table, $field); + + $row = Database::connect($data['DBGroup'] ?? null) + ->table($table) + ->select('1') + ->where($field, $str) + ->limit(1); + + if (! empty($ignoreField) && ! empty($ignoreValue) && ! preg_match('/^\{(\w+)\}$/', $ignoreValue)) { + $row = $row->where("{$ignoreField} !=", $ignoreValue); + } + + return $row->get()->getRow() === null; } /** From 5722ab0f3e0c0ddeea4eb2d3dfa2274f8877313d Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 10:56:13 +0900 Subject: [PATCH 17/56] fix: TypeError in Rules::is_not_unique() --- system/Validation/Rules.php | 18 ++---------------- system/Validation/StrictRules/Rules.php | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index c8284629d3b3..1e543a8fd858 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -95,23 +95,9 @@ public function greater_than_equal_to(?string $str, string $min): bool */ public function is_not_unique(?string $str, string $field, array $data): bool { - // Grab any data for exclusion of a single row. - [$field, $whereField, $whereValue] = array_pad(explode(',', $field), 3, null); - - // Break the table and field apart - sscanf($field, '%[^.].%[^.]', $table, $field); - - $row = Database::connect($data['DBGroup'] ?? null) - ->table($table) - ->select('1') - ->where($field, $str) - ->limit(1); - - if (! empty($whereField) && ! empty($whereValue) && ! preg_match('/^\{(\w+)\}$/', $whereValue)) { - $row = $row->where($whereField, $whereValue); - } + $this->createStrictRules(); - return $row->get()->getRow() !== null; + return $this->strictRules->is_not_unique($str, $field, $data); } /** diff --git a/system/Validation/StrictRules/Rules.php b/system/Validation/StrictRules/Rules.php index 1091b319f43f..ad21b6126696 100644 --- a/system/Validation/StrictRules/Rules.php +++ b/system/Validation/StrictRules/Rules.php @@ -117,7 +117,27 @@ public function greater_than_equal_to($str, string $min): bool */ public function is_not_unique($str, string $field, array $data): bool { - return $this->nonStrictRules->is_not_unique($str, $field, $data); + // Grab any data for exclusion of a single row. + [$field, $whereField, $whereValue] = array_pad( + explode(',', $field), + 3, + null + ); + + // Break the table and field apart + sscanf($field, '%[^.].%[^.]', $table, $field); + + $row = Database::connect($data['DBGroup'] ?? null) + ->table($table) + ->select('1') + ->where($field, $str) + ->limit(1); + + if (! empty($whereField) && ! empty($whereValue) && ! preg_match('/^\{(\w+)\}$/', $whereValue)) { + $row = $row->where($whereField, $whereValue); + } + + return $row->get()->getRow() !== null; } /** From 7b405d1309a89ac5d3e26f84e982bcb39f373f28 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 11:03:37 +0900 Subject: [PATCH 18/56] fix: add type check --- system/Validation/StrictRules/Rules.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/system/Validation/StrictRules/Rules.php b/system/Validation/StrictRules/Rules.php index ad21b6126696..8aa8f85fc228 100644 --- a/system/Validation/StrictRules/Rules.php +++ b/system/Validation/StrictRules/Rules.php @@ -117,6 +117,10 @@ public function greater_than_equal_to($str, string $min): bool */ public function is_not_unique($str, string $field, array $data): bool { + if (is_object($str) || is_array($str)) { + return false; + } + // Grab any data for exclusion of a single row. [$field, $whereField, $whereValue] = array_pad( explode(',', $field), @@ -171,6 +175,10 @@ public function in_list($value, string $list): bool */ public function is_unique($str, string $field, array $data): bool { + if (is_object($str) || is_array($str)) { + return false; + } + [$field, $ignoreField, $ignoreValue] = array_pad( explode(',', $field), 3, From 7d4e0ebecef745be2be0599318b781f92e561f02 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 11:07:13 +0900 Subject: [PATCH 19/56] fix: revert Traditional is_unique() is_not_unique() implementation If we use Strict Rules, the behavior may change. --- system/Validation/Rules.php | 44 +++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index 1e543a8fd858..40a5955b157d 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -11,7 +11,6 @@ namespace CodeIgniter\Validation; -use CodeIgniter\Validation\StrictRules\Rules as StrictRules; use Config\Database; use InvalidArgumentException; @@ -20,15 +19,6 @@ */ class Rules { - private ?StrictRules $strictRules = null; - - private function createStrictRules(): void - { - if ($this->strictRules === null) { - $this->strictRules = new StrictRules(); - } - } - /** * The value does not match another field in $data. * @@ -95,9 +85,23 @@ public function greater_than_equal_to(?string $str, string $min): bool */ public function is_not_unique(?string $str, string $field, array $data): bool { - $this->createStrictRules(); + // Grab any data for exclusion of a single row. + [$field, $whereField, $whereValue] = array_pad(explode(',', $field), 3, null); + + // Break the table and field apart + sscanf($field, '%[^.].%[^.]', $table, $field); + + $row = Database::connect($data['DBGroup'] ?? null) + ->table($table) + ->select('1') + ->where($field, $str) + ->limit(1); - return $this->strictRules->is_not_unique($str, $field, $data); + if (! empty($whereField) && ! empty($whereValue) && ! preg_match('/^\{(\w+)\}$/', $whereValue)) { + $row = $row->where($whereField, $whereValue); + } + + return $row->get()->getRow() !== null; } /** @@ -121,9 +125,21 @@ public function in_list(?string $value, string $list): bool */ public function is_unique(?string $str, string $field, array $data): bool { - $this->createStrictRules(); + [$field, $ignoreField, $ignoreValue] = array_pad(explode(',', $field), 3, null); + + sscanf($field, '%[^.].%[^.]', $table, $field); + + $row = Database::connect($data['DBGroup'] ?? null) + ->table($table) + ->select('1') + ->where($field, $str) + ->limit(1); + + if (! empty($ignoreField) && ! empty($ignoreValue) && ! preg_match('/^\{(\w+)\}$/', $ignoreValue)) { + $row = $row->where("{$ignoreField} !=", $ignoreValue); + } - return $this->strictRules->is_unique($str, $field, $data); + return $row->get()->getRow() === null; } /** From 76c8997c4984f521c755ff6e9ec230f7c5fed822 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 11:15:44 +0900 Subject: [PATCH 20/56] style: break long lines --- system/Validation/Rules.php | 22 ++++++++++++++++++---- system/Validation/StrictRules/Rules.php | 10 ++++++++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index 40a5955b157d..93b86ea6b1dd 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -86,7 +86,11 @@ public function greater_than_equal_to(?string $str, string $min): bool public function is_not_unique(?string $str, string $field, array $data): bool { // Grab any data for exclusion of a single row. - [$field, $whereField, $whereValue] = array_pad(explode(',', $field), 3, null); + [$field, $whereField, $whereValue] = array_pad( + explode(',', $field), + 3, + null + ); // Break the table and field apart sscanf($field, '%[^.].%[^.]', $table, $field); @@ -97,7 +101,10 @@ public function is_not_unique(?string $str, string $field, array $data): bool ->where($field, $str) ->limit(1); - if (! empty($whereField) && ! empty($whereValue) && ! preg_match('/^\{(\w+)\}$/', $whereValue)) { + if ( + ! empty($whereField) && ! empty($whereValue) + && ! preg_match('/^\{(\w+)\}$/', $whereValue) + ) { $row = $row->where($whereField, $whereValue); } @@ -125,7 +132,11 @@ public function in_list(?string $value, string $list): bool */ public function is_unique(?string $str, string $field, array $data): bool { - [$field, $ignoreField, $ignoreValue] = array_pad(explode(',', $field), 3, null); + [$field, $ignoreField, $ignoreValue] = array_pad( + explode(',', $field), + 3, + null + ); sscanf($field, '%[^.].%[^.]', $table, $field); @@ -135,7 +146,10 @@ public function is_unique(?string $str, string $field, array $data): bool ->where($field, $str) ->limit(1); - if (! empty($ignoreField) && ! empty($ignoreValue) && ! preg_match('/^\{(\w+)\}$/', $ignoreValue)) { + if ( + ! empty($ignoreField) && ! empty($ignoreValue) + && ! preg_match('/^\{(\w+)\}$/', $ignoreValue) + ) { $row = $row->where("{$ignoreField} !=", $ignoreValue); } diff --git a/system/Validation/StrictRules/Rules.php b/system/Validation/StrictRules/Rules.php index 8aa8f85fc228..05d9e96a305b 100644 --- a/system/Validation/StrictRules/Rules.php +++ b/system/Validation/StrictRules/Rules.php @@ -137,7 +137,10 @@ public function is_not_unique($str, string $field, array $data): bool ->where($field, $str) ->limit(1); - if (! empty($whereField) && ! empty($whereValue) && ! preg_match('/^\{(\w+)\}$/', $whereValue)) { + if ( + ! empty($whereField) && ! empty($whereValue) + && ! preg_match('/^\{(\w+)\}$/', $whereValue) + ) { $row = $row->where($whereField, $whereValue); } @@ -193,7 +196,10 @@ public function is_unique($str, string $field, array $data): bool ->where($field, $str) ->limit(1); - if (! empty($ignoreField) && ! empty($ignoreValue) && ! preg_match('/^\{(\w+)\}$/', $ignoreValue)) { + if ( + ! empty($ignoreField) && ! empty($ignoreValue) + && ! preg_match('/^\{(\w+)\}$/', $ignoreValue) + ) { $row = $row->where("{$ignoreField} !=", $ignoreValue); } From 95e87512669d7b1e5136ba12e6020d19b591c32f Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 12:32:13 +0900 Subject: [PATCH 21/56] docs: add sample for STDERR testing --- user_guide_src/source/installation/upgrade_430.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index 0f1ada0ba9ab..40198aff2abb 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -142,6 +142,7 @@ The way error and output streams are captured has changed. Now instead of:: { CITestStreamFilter::$buffer = ''; $this->stream_filter = stream_filter_append(STDOUT, 'CITestStreamFilter'); + $this->streamFilter = stream_filter_append(STDERR, 'CITestStreamFilter'); } protected function tearDown(): void @@ -157,11 +158,13 @@ need to use:: { CITestStreamFilter::registration(); CITestStreamFilter::addOutputFilter(); + CITestStreamFilter::addErrorFilter(); } protected function tearDown(): void { CITestStreamFilter::removeOutputFilter(); + CITestStreamFilter::removeErrorFilter(); } Or use the trait ``CodeIgniter\Test\StreamFilterTrait``. See :ref:`testing-cli-output`. From 1b4601ee7c44e35d8c0172c1bff343562f8417fd Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 12:34:43 +0900 Subject: [PATCH 22/56] docs: rename property name --- user_guide_src/source/installation/upgrade_430.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index 40198aff2abb..36312248c931 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -141,13 +141,13 @@ The way error and output streams are captured has changed. Now instead of:: protected function setUp(): void { CITestStreamFilter::$buffer = ''; - $this->stream_filter = stream_filter_append(STDOUT, 'CITestStreamFilter'); + $this->streamFilter = stream_filter_append(STDOUT, 'CITestStreamFilter'); $this->streamFilter = stream_filter_append(STDERR, 'CITestStreamFilter'); } protected function tearDown(): void { - stream_filter_remove($this->stream_filter); + stream_filter_remove($this->streamFilter); } need to use:: From 6e9785778c63f34ce1adb7afd0195e593f637ae2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 21:58:32 +0900 Subject: [PATCH 23/56] test: add @TODO These tests are a misuse of (:any). They are not appropriate test code. --- tests/system/CommonFunctionsTest.php | 8 ++++++++ tests/system/Helpers/URLHelper/MiscUrlTest.php | 2 ++ .../system/Router/RouteCollectionReverseRouteTest.php | 10 ++++++++++ tests/system/Router/RouteCollectionTest.php | 4 ++++ tests/system/View/ParserPluginTest.php | 2 ++ 5 files changed, 26 insertions(+) diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index 2e8c3be0d625..a0b5280ec6bc 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -266,6 +266,8 @@ public function testRouteTo() { // prime the pump $routes = service('routes'); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2'); $this->assertSame('/path/string/to/13', route_to('myController::goto', 'string', 13)); @@ -275,6 +277,8 @@ public function testRouteToInCliWithoutLocaleInRoute() { Services::createRequest(new App(), true); $routes = service('routes'); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2'); $this->assertSame('/path/string/to/13', route_to('myController::goto', 'string', 13)); @@ -284,6 +288,8 @@ public function testRouteToInCliWithLocaleInRoute() { Services::createRequest(new App(), true); $routes = service('routes'); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('{locale}/path/(:any)/to/(:num)', 'myController::goto/$1/$2', ['as' => 'path-to']); $this->assertSame( @@ -296,6 +302,8 @@ public function testRouteToWithUnsupportedLocale() { Services::createRequest(new App(), false); $routes = service('routes'); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('{locale}/path/(:any)/to/(:num)', 'myController::goto/$1/$2', ['as' => 'path-to']); $this->assertSame( diff --git a/tests/system/Helpers/URLHelper/MiscUrlTest.php b/tests/system/Helpers/URLHelper/MiscUrlTest.php index 8181705389ca..fb949f2e9ecc 100644 --- a/tests/system/Helpers/URLHelper/MiscUrlTest.php +++ b/tests/system/Helpers/URLHelper/MiscUrlTest.php @@ -835,6 +835,8 @@ public function testUrlTo(string $expected, string $input, ...$args) $_SERVER['HTTP_HOST'] = 'example.com'; $routes = service('routes'); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2', ['as' => 'gotoPage']); $routes->add('route/(:any)/to/(:num)', 'myOtherController::goto/$1/$2'); diff --git a/tests/system/Router/RouteCollectionReverseRouteTest.php b/tests/system/Router/RouteCollectionReverseRouteTest.php index 8f5bea1996bf..2e6de5aacdf7 100644 --- a/tests/system/Router/RouteCollectionReverseRouteTest.php +++ b/tests/system/Router/RouteCollectionReverseRouteTest.php @@ -56,6 +56,8 @@ public function testReverseRoutingFindsSimpleMatch() { $routes = $this->getCollector(); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2'); $match = $routes->reverseRoute('myController::goto', 'string', 13); @@ -67,6 +69,8 @@ public function testReverseRoutingWithLocaleAndFindsSimpleMatch() { $routes = $this->getCollector(); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('{locale}/path/(:any)/to/(:num)', 'myController::goto/$1/$2'); $match = $routes->reverseRoute('myController::goto', 'string', 13); @@ -78,6 +82,8 @@ public function testReverseRoutingReturnsFalseWithBadParamCount() { $routes = $this->getCollector(); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('path/(:any)/to/(:num)', 'myController::goto/$1'); $this->assertFalse($routes->reverseRoute('myController::goto', 'string', 13)); @@ -87,6 +93,8 @@ public function testReverseRoutingReturnsFalseWithNoMatch() { $routes = $this->getCollector(); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2'); $this->assertFalse($routes->reverseRoute('myBadController::goto', 'string', 13)); @@ -96,6 +104,8 @@ public function testReverseRoutingThrowsExceptionWithBadParamTypes() { $routes = $this->getCollector(); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2'); $this->expectException(RouterException::class); diff --git a/tests/system/Router/RouteCollectionTest.php b/tests/system/Router/RouteCollectionTest.php index fbd99fd88b62..70d378467414 100644 --- a/tests/system/Router/RouteCollectionTest.php +++ b/tests/system/Router/RouteCollectionTest.php @@ -889,6 +889,8 @@ public function testNamedRoutesFillInParams() { $routes = $this->getCollector(); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2', ['as' => 'namedRoute']); $match = $routes->reverseRoute('namedRoute', 'string', 13); @@ -900,6 +902,8 @@ public function testNamedRoutesWithLocaleAndFillInParams() { $routes = $this->getCollector(); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('{locale}/path/(:any)/to/(:num)', 'myController::goto/$1/$2', ['as' => 'namedRoute']); $match = $routes->reverseRoute('namedRoute', 'string', 13); diff --git a/tests/system/View/ParserPluginTest.php b/tests/system/View/ParserPluginTest.php index 3c8c781d0edc..daea90de7fa7 100644 --- a/tests/system/View/ParserPluginTest.php +++ b/tests/system/View/ParserPluginTest.php @@ -96,6 +96,8 @@ public function testRoute() { // prime the pump $routes = service('routes'); + // @TODO Do not put any placeholder after (:any). + // Because the number of parameters passed to the controller method may change. $routes->add('path/(:any)/to/(:num)', 'myController::goto/$1/$2'); $template = '{+ route myController::goto string 13 +}'; From 39f9e42b7c06b13ef849ef75640418291ce19afb Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 09:09:42 +0900 Subject: [PATCH 24/56] test: add test for resetQuery --- tests/system/Database/Builder/SelectTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/system/Database/Builder/SelectTest.php b/tests/system/Database/Builder/SelectTest.php index 60919a87dd8d..af7bf96d119e 100644 --- a/tests/system/Database/Builder/SelectTest.php +++ b/tests/system/Database/Builder/SelectTest.php @@ -309,4 +309,18 @@ public function testSelectSubquery() $this->assertSame($expected, str_replace("\n", ' ', $builder->getCompiledSelect())); } + + public function testSelectResetQuery() + { + $builder = new BaseBuilder('users', $this->db); + $builder->select('name, role'); + + $builder->resetQuery(); + + $sql = $builder->getCompiledSelect(); + $this->assertSame( + 'SELECT * FROM "users"', + str_replace("\n", ' ', $sql) + ); + } } From 02679aa9fcf22d4f365bce4dc6cba7925597902b Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 10:27:54 +0900 Subject: [PATCH 25/56] chore: update phpstan-baseline for PHPStan 1.9.9 --- phpstan-baseline.neon.dist | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpstan-baseline.neon.dist b/phpstan-baseline.neon.dist index 986601771fef..525d807b2e7b 100644 --- a/phpstan-baseline.neon.dist +++ b/phpstan-baseline.neon.dist @@ -25,11 +25,6 @@ parameters: count: 1 path: system/Cache/Handlers/MemcachedHandler.php - - - message: "#^Variable \\$data might not be defined\\.$#" - count: 1 - path: system/Cache/Handlers/MemcachedHandler.php - - message: "#^Property CodeIgniter\\\\Cache\\\\Handlers\\\\RedisHandler\\:\\:\\$redis \\(Redis\\) in isset\\(\\) is not nullable\\.$#" count: 1 From e297ff137fa0c2c2fcba94645ea74827020e46d8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 10:48:06 +0900 Subject: [PATCH 26/56] docs: add comment --- system/Debug/Exceptions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index 2670732d19d0..bcce589db894 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -80,6 +80,8 @@ public function __construct(ExceptionsConfig $config, $request, ResponseInterfac $this->response = $response; // workaround for upgraded users + // This causes "Deprecated: Creation of dynamic property" in PHP 8.2. + // @TODO remove this after dropping PHP 8.1 support. if (! isset($this->config->sensitiveDataInTrace)) { $this->config->sensitiveDataInTrace = []; } From c5664b2d97eb5ea1953a53c71ca2c72eab519499 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 10:48:31 +0900 Subject: [PATCH 27/56] docs: make it easier to read how to make changes in Config Files --- user_guide_src/source/installation/upgrade_430.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index 36312248c931..4e510fc64607 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -33,7 +33,18 @@ The following files received significant changes and Config Files ============ -- **app/Config/Kint.php** has been updated for Kint 5.0. You need to replace ``Kint\Renderer\Renderer`` with ``Kint\Renderer\AbstractRenderer`` and replace ``Renderer::SORT_FULL`` with ``AbstractRenderer::SORT_FULL``. +app/Config/Kint.php +------------------- + +- **app/Config/Kint.php** has been updated for Kint 5.0. +- You need to replace: + + - ``Kint\Renderer\Renderer`` with ``Kint\Renderer\AbstractRenderer`` + - ``Renderer::SORT_FULL`` with ``AbstractRenderer::SORT_FULL`` + +Mock Config Classes +------------------- + - If you are using the following Mock Config classes in testing, you need to update the corresponding Config files in **app/Config**: - ``MockAppConfig`` (``Config\App``) From 1c270013475eeef53e759a8d0cd6ba5ecaee9d9c Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 10:51:59 +0900 Subject: [PATCH 28/56] docs: add missing instruction for Config/Exceptions.php --- user_guide_src/source/installation/upgrade_430.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index 4e510fc64607..785ff111a260 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -42,6 +42,11 @@ app/Config/Kint.php - ``Kint\Renderer\Renderer`` with ``Kint\Renderer\AbstractRenderer`` - ``Renderer::SORT_FULL`` with ``AbstractRenderer::SORT_FULL`` +app/Config/Exceptions.php +------------------------- + +- If you are using PHP 8.2, you need to add new properties ``$logDeprecations`` and ``$deprecationLogLevel``. + Mock Config Classes ------------------- From 78e47c022bd8a703e8be6a042a4757b41907b37f Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 10:00:19 +0900 Subject: [PATCH 29/56] test: fix test method name --- tests/system/Validation/RulesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/Validation/RulesTest.php b/tests/system/Validation/RulesTest.php index 19e6bde1f18c..f95aa84eb0d1 100644 --- a/tests/system/Validation/RulesTest.php +++ b/tests/system/Validation/RulesTest.php @@ -482,7 +482,7 @@ public function lessThanProvider(): Generator /** * @dataProvider lessThanEqualProvider */ - public function testLessEqualThan(?string $first, ?string $second, bool $expected): void + public function testLessThanEqual(?string $first, ?string $second, bool $expected): void { $data = ['foo' => $first]; $this->validation->setRules(['foo' => "less_than_equal_to[{$second}]"]); From 8e5861d500f78392d1b3fe846051f3ccebb3307d Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 10:04:22 +0900 Subject: [PATCH 30/56] test: add float test cases for Traditional Rules --- tests/system/Validation/RulesTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/system/Validation/RulesTest.php b/tests/system/Validation/RulesTest.php index f95aa84eb0d1..3bf60aca8131 100644 --- a/tests/system/Validation/RulesTest.php +++ b/tests/system/Validation/RulesTest.php @@ -427,6 +427,9 @@ public function greaterThanProvider(): Generator ['-10', '-11', true], ['10', '9', true], ['10', '10', false], + ['10.1', '10', true], + ['10.0', '10', false], + ['9.9', '10', false], ['10', 'a', false], ['10a', '10', false], [null, null, false], @@ -449,6 +452,9 @@ public function greaterThanEqualProvider(): Generator ['0', '0', true], ['1', '0', true], ['-1', '0', false], + ['1.0', '1', true], + ['1.1', '1', true], + ['0.9', '1', false], ['10a', '0', false], [null, null, false], ['1', null, true], @@ -473,6 +479,9 @@ public function lessThanProvider(): Generator ['9', '10', true], ['10', '9', false], ['10', '10', false], + ['9.9', '10', true], + ['10.1', '10', false], + ['10.0', '10', false], ['10', 'a', true], ['10a', '10', false], [null, null, false], @@ -495,6 +504,9 @@ public function lessThanEqualProvider(): Generator ['0', '0', true], ['1', '0', false], ['-1', '0', true], + ['1.0', '1', true], + ['0.9', '1', true], + ['1.1', '1', false], ['10a', '0', false], [null, null, false], ['1', null, false], From a286430d9ddd2602a5e157ff9cfbb0d3b9154c31 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 10:14:48 +0900 Subject: [PATCH 31/56] test: add float test cases for Strict Rules --- tests/system/Validation/StrictRules/RulesTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/system/Validation/StrictRules/RulesTest.php b/tests/system/Validation/StrictRules/RulesTest.php index d153367b8220..4c0e84274226 100644 --- a/tests/system/Validation/StrictRules/RulesTest.php +++ b/tests/system/Validation/StrictRules/RulesTest.php @@ -106,6 +106,9 @@ public function provideGreaterThanEqualStrict(): Generator [0, '0', true], [1, '0', true], [-1, '0', false], + [1.0, '1', true], + [1.1, '1', true], + [0.9, '1', false], [true, '0', false], ]; } @@ -129,6 +132,9 @@ public function provideGreaterThanStrict(): Generator [-10, '-11', true], [10, '9', true], [10, '10', false], + [10.1, '10', true], + [10.0, '10', false], + [9.9, '10', false], [10, 'a', false], [true, '0', false], ]; @@ -154,6 +160,9 @@ public function provideLessThanStrict(): Generator [9, '10', true], [10, '9', false], [10, '10', false], + [9.9, '10', true], + [10.1, '10', false], + [10.0, '10', false], [10, 'a', true], [true, '0', false], ]; @@ -178,6 +187,9 @@ public function provideLessThanEqualStrict(): Generator [0, '0', true], [1, '0', false], [-1, '0', true], + [1.0, '1', true], + [0.9, '1', true], + [1.1, '1', false], [true, '0', false], ]; } From 65d9b216797ba1bdd74c7f8701a41b3fd891a7bf Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 10:16:07 +0900 Subject: [PATCH 32/56] fix: handling float in greater_than, greater_than_equal_to, less_than, less_than_equal_to --- system/Validation/StrictRules/Rules.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/Validation/StrictRules/Rules.php b/system/Validation/StrictRules/Rules.php index 05d9e96a305b..f95bbe7d4083 100644 --- a/system/Validation/StrictRules/Rules.php +++ b/system/Validation/StrictRules/Rules.php @@ -75,7 +75,7 @@ public function exact_length($str, string $val): bool */ public function greater_than($str, string $min): bool { - if (is_int($str)) { + if (is_int($str) || is_float($str)) { $str = (string) $str; } @@ -93,7 +93,7 @@ public function greater_than($str, string $min): bool */ public function greater_than_equal_to($str, string $min): bool { - if (is_int($str)) { + if (is_int($str) || is_float($str)) { $str = (string) $str; } @@ -213,7 +213,7 @@ public function is_unique($str, string $field, array $data): bool */ public function less_than($str, string $max): bool { - if (is_int($str)) { + if (is_int($str) || is_float($str)) { $str = (string) $str; } @@ -231,7 +231,7 @@ public function less_than($str, string $max): bool */ public function less_than_equal_to($str, string $max): bool { - if (is_int($str)) { + if (is_int($str) || is_float($str)) { $str = (string) $str; } From 2512962fb1aa818e29e653126f941c40162f3c2b Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 11:33:05 +0900 Subject: [PATCH 33/56] docs: add about "Call to undefined method ComposerInstalledVersions::getAllRawData()" --- .../source/installation/upgrade_430.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index 36312248c931..c291f8f417cd 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -12,6 +12,23 @@ Please refer to the upgrade instructions corresponding to your installation meth :local: :depth: 2 +Trouble Shooting +**************** + +Call to undefined method Composer\InstalledVersions::getAllRawData() +==================================================================== + +Some users reported "*Fatal error: Uncaught Error: Call to undefined method Composer\InstalledVersions::getAllRawData()*" after upgrading with Composer. + +If you get the error, upgrade your ``composer`` command, and delete the **vendor/** +directory, and run ``composer update`` again. + +The procedure, for example, is as follows:: + + > composer self-update + > rm -rf vendor/ + > composer update + Mandatory File Changes ********************** From 8115516f1afeca1ca847f2d4f761dbcc6f6f20b6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 12:52:09 +0900 Subject: [PATCH 34/56] docs: fix by proofreading Co-authored-by: John Paul E. Balandan, CPA --- user_guide_src/source/installation/upgrade_430.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index c291f8f417cd..50f4cc84edd0 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -20,7 +20,7 @@ Call to undefined method Composer\InstalledVersions::getAllRawData() Some users reported "*Fatal error: Uncaught Error: Call to undefined method Composer\InstalledVersions::getAllRawData()*" after upgrading with Composer. -If you get the error, upgrade your ``composer`` command, and delete the **vendor/** +If you get the error, upgrade your ``composer`` tool, and delete the **vendor/** directory, and run ``composer update`` again. The procedure, for example, is as follows:: From e8dc7f5124ba470feccde270f0095c2d4d1c5c48 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 15:33:12 +0900 Subject: [PATCH 35/56] docs: add missing backslashes --- user_guide_src/source/installation/upgrade_430.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index 82556e268358..29a801f77db2 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -15,10 +15,10 @@ Please refer to the upgrade instructions corresponding to your installation meth Trouble Shooting **************** -Call to undefined method Composer\InstalledVersions::getAllRawData() -==================================================================== +Call to undefined method Composer\\InstalledVersions::getAllRawData() +===================================================================== -Some users reported "*Fatal error: Uncaught Error: Call to undefined method Composer\InstalledVersions::getAllRawData()*" after upgrading with Composer. +Some users reported "*Fatal error: Uncaught Error: Call to undefined method Composer\\InstalledVersions::getAllRawData()*" after upgrading with Composer. If you get the error, upgrade your ``composer`` tool, and delete the **vendor/** directory, and run ``composer update`` again. From ee9abc7408be3826dc9d266f8f4450470e1381d5 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 11 Jan 2023 17:52:21 +0700 Subject: [PATCH 36/56] [Rector] Enable AddDefaultValueForUndefinedVariableRector --- phpstan-baseline.neon.dist | 20 ------------------- rector.php | 4 ---- system/Cache/Handlers/MemcachedHandler.php | 3 ++- .../Generators/MigrationGenerator.php | 1 + .../Generators/SessionMigrationGenerator.php | 1 + system/Commands/Utilities/FilterCheck.php | 1 + system/Database/BaseBuilder.php | 1 + system/Database/SQLSRV/Connection.php | 1 + system/Debug/Toolbar.php | 1 + system/Debug/Toolbar/Collectors/Database.php | 1 + system/Helpers/html_helper.php | 1 + system/Helpers/url_helper.php | 11 +++++----- system/Images/Handlers/ImageMagickHandler.php | 5 ++++- system/Model.php | 1 + tests/system/Database/Live/MetadataTest.php | 2 ++ tests/system/Validation/ValidationTest.php | 1 + 16 files changed, 23 insertions(+), 32 deletions(-) diff --git a/phpstan-baseline.neon.dist b/phpstan-baseline.neon.dist index 525d807b2e7b..af189e08b8b1 100644 --- a/phpstan-baseline.neon.dist +++ b/phpstan-baseline.neon.dist @@ -195,11 +195,6 @@ parameters: count: 1 path: system/Helpers/number_helper.php - - - message: "#^Variable \\$count might not be defined\\.$#" - count: 1 - path: system/Helpers/url_helper.php - - message: "#^Property CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:\\$image \\(CodeIgniter\\\\Images\\\\Image\\) in empty\\(\\) is not falsy\\.$#" count: 1 @@ -225,21 +220,6 @@ parameters: count: 4 path: system/Images/Handlers/ImageMagickHandler.php - - - message: "#^Variable \\$gravity might not be defined\\.$#" - count: 1 - path: system/Images/Handlers/ImageMagickHandler.php - - - - message: "#^Variable \\$xAxis might not be defined\\.$#" - count: 1 - path: system/Images/Handlers/ImageMagickHandler.php - - - - message: "#^Variable \\$yAxis might not be defined\\.$#" - count: 1 - path: system/Images/Handlers/ImageMagickHandler.php - - message: "#^Call to an undefined method CodeIgniter\\\\Router\\\\RouteCollectionInterface\\:\\:getDefaultNamespace\\(\\)\\.$#" count: 3 diff --git a/rector.php b/rector.php index d53f9af118eb..095cb2444c62 100644 --- a/rector.php +++ b/rector.php @@ -36,7 +36,6 @@ use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; -use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector; use Rector\Php70\Rector\FuncCall\RandomFunctionRector; use Rector\Php71\Rector\FuncCall\CountOnNullRector; use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; @@ -106,9 +105,6 @@ // sometime too detail CountOnNullRector::class, - // may not be unitialized on purpose - AddDefaultValueForUndefinedVariableRector::class, - // use mt_rand instead of random_int on purpose on non-cryptographically random RandomFunctionRector::class, diff --git a/system/Cache/Handlers/MemcachedHandler.php b/system/Cache/Handlers/MemcachedHandler.php index f7d5ec8bcd1a..5053b1a6752a 100644 --- a/system/Cache/Handlers/MemcachedHandler.php +++ b/system/Cache/Handlers/MemcachedHandler.php @@ -124,7 +124,8 @@ public function initialize() */ public function get(string $key) { - $key = static::validateKey($key, $this->prefix); + $data = []; + $key = static::validateKey($key, $this->prefix); if ($this->memcached instanceof Memcached) { $data = $this->memcached->get($key); diff --git a/system/Commands/Generators/MigrationGenerator.php b/system/Commands/Generators/MigrationGenerator.php index 5cc3b6dfd56a..817c16885205 100644 --- a/system/Commands/Generators/MigrationGenerator.php +++ b/system/Commands/Generators/MigrationGenerator.php @@ -97,6 +97,7 @@ public function run(array $params) */ protected function prepare(string $class): string { + $data = []; $data['session'] = false; if ($this->getOption('session')) { diff --git a/system/Commands/Generators/SessionMigrationGenerator.php b/system/Commands/Generators/SessionMigrationGenerator.php index a1e02a131b63..fbfb2d3db1ff 100644 --- a/system/Commands/Generators/SessionMigrationGenerator.php +++ b/system/Commands/Generators/SessionMigrationGenerator.php @@ -89,6 +89,7 @@ public function run(array $params) */ protected function prepare(string $class): string { + $data = []; $data['session'] = true; $data['table'] = $this->getOption('t'); $data['DBGroup'] = $this->getOption('g'); diff --git a/system/Commands/Utilities/FilterCheck.php b/system/Commands/Utilities/FilterCheck.php index 15f66e97a8a7..d2eb2fb728a4 100644 --- a/system/Commands/Utilities/FilterCheck.php +++ b/system/Commands/Utilities/FilterCheck.php @@ -72,6 +72,7 @@ class FilterCheck extends BaseCommand */ public function run(array $params) { + $tbody = []; if (! isset($params[0], $params[1])) { CLI::error('You must specify a HTTP verb and a route.'); CLI::write(' Usage: ' . $this->usage); diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 11250b54fd0b..9e2c634cb7f2 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -1423,6 +1423,7 @@ public function orHaving($key, $value = null, ?bool $escape = null) */ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = null) { + $qbOrderBy = []; if (empty($orderBy)) { return $this; } diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index b74435036c18..5d9b208d6010 100755 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -529,6 +529,7 @@ public function getPlatform(): string */ public function getVersion(): string { + $info = []; if (isset($this->dataCache['version'])) { return $this->dataCache['version']; } diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 10dad0f4a947..17e67aa8eb94 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -76,6 +76,7 @@ public function __construct(ToolbarConfig $config) */ public function run(float $startTime, float $totalTime, RequestInterface $request, ResponseInterface $response): string { + $data = []; // Data items used within the view. $data['url'] = current_url(); $data['method'] = strtoupper($request->getMethod()); diff --git a/system/Debug/Toolbar/Collectors/Database.php b/system/Debug/Toolbar/Collectors/Database.php index 2991840c8de1..c7ed6703b402 100644 --- a/system/Debug/Toolbar/Collectors/Database.php +++ b/system/Debug/Toolbar/Collectors/Database.php @@ -140,6 +140,7 @@ protected function formatTimelineData(): array */ public function display(): array { + $data = []; $data['queries'] = array_map(static function (array $query) { $isDuplicate = $query['duplicate'] === true; diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php index 979aae1b9179..c7a36e270860 100755 --- a/system/Helpers/html_helper.php +++ b/system/Helpers/html_helper.php @@ -236,6 +236,7 @@ function link_tag( bool $indexPage = false, string $hreflang = '' ): string { + $attributes = []; // extract fields if needed if (is_array($href)) { $rel = $href['rel'] ?? $rel; diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 1f2db240e627..682830ba1e5a 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -56,12 +56,10 @@ function _get_uri(string $relativePath = '', ?App $config = null): URI // Build the full URL based on $config and $relativePath $request = Services::request(); - if ($request instanceof CLIRequest) { - /** @var App $config */ - $url = rtrim($config->baseURL, '/ ') . '/'; - } else { - $url = $request->getUri()->getBaseURL(); - } + /** @var App $config */ + $url = $request instanceof CLIRequest + ? rtrim($config->baseURL, '/ ') . '/' + : $request->getUri()->getBaseURL(); // Check for an index page if ($config->indexPage !== '') { @@ -329,6 +327,7 @@ function mailto(string $email, string $title = '', $attributes = ''): string */ function safe_mailto(string $email, string $title = '', $attributes = ''): string { + $count = 0; if (trim($title) === '') { $title = $email; } diff --git a/system/Images/Handlers/ImageMagickHandler.php b/system/Images/Handlers/ImageMagickHandler.php index b96fdc06d20d..41274c6a9591 100644 --- a/system/Images/Handlers/ImageMagickHandler.php +++ b/system/Images/Handlers/ImageMagickHandler.php @@ -322,7 +322,10 @@ protected function supportedFormatCheck() */ protected function _text(string $text, array $options = []) { - $cmd = ''; + $xAxis = 0; + $yAxis = 0; + $gravity = ''; + $cmd = ''; // Reverse the vertical offset // When the image is positioned at the bottom diff --git a/system/Model.php b/system/Model.php index 0278be4e4d21..de646c6f8c7c 100644 --- a/system/Model.php +++ b/system/Model.php @@ -427,6 +427,7 @@ protected function doUpdateBatch(?array $set = null, ?string $index = null, int */ protected function doDelete($id = null, bool $purge = false) { + $set = []; $builder = $this->builder(); if ($id) { diff --git a/tests/system/Database/Live/MetadataTest.php b/tests/system/Database/Live/MetadataTest.php index d698f647abe5..1506c7b3d2f5 100644 --- a/tests/system/Database/Live/MetadataTest.php +++ b/tests/system/Database/Live/MetadataTest.php @@ -123,6 +123,8 @@ public function testListTablesConstrainedByPrefixReturnsOnlyTablesWithMatchingPr public function testListTablesConstrainedByExtraneousPrefixReturnsOnlyTheExtraneousTable() { + $oldPrefix = ''; + try { $this->createExtraneousTable(); diff --git a/tests/system/Validation/ValidationTest.php b/tests/system/Validation/ValidationTest.php index 100cf1535495..6597866b3f88 100644 --- a/tests/system/Validation/ValidationTest.php +++ b/tests/system/Validation/ValidationTest.php @@ -288,6 +288,7 @@ public function testClosureRuleWithLabel(): void */ public function testCanValidatetArrayData($value, bool $expected): void { + $data = []; $this->validation->setRules(['arr' => 'is_array']); $data['arr'] = $value; From 10600c62d730d6a228ff9d92ae51f445f9b1e2d0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 21:17:58 +0900 Subject: [PATCH 37/56] fix: add method_exists() check and improve error message --- system/Autoloader/Autoloader.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index 0041937c78d1..1c03b0419fa8 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -373,7 +373,16 @@ private function loadComposerNamespaces(ClassLoader $composer, array $composerPa unset($namespacePaths['CodeIgniter\\']); } - $packageList = InstalledVersions::getAllRawData()[0]['versions']; + if (method_exists(InstalledVersions::class, 'getAllRawData')) { + // This method requires Composer 2.0.14 or later. + $packageList = InstalledVersions::getAllRawData()[0]['versions']; + } else { + throw new RuntimeException( + 'Your Composer version is too old.' + . ' Please update Composer (run `composer self-update`) and remove your vendor/ directory,' + . ' and run `composer update`.' + ); + } // Check config for $composerPackages. $only = $composerPackages['only'] ?? []; From 46513a96f5ae2d4e968853601888fd4261a7188a Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 21:19:23 +0900 Subject: [PATCH 38/56] docs: update user guide --- .../source/installation/installing_composer.rst | 2 ++ user_guide_src/source/installation/upgrade_430.rst | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/user_guide_src/source/installation/installing_composer.rst b/user_guide_src/source/installation/installing_composer.rst index fc3fbe5c5c7b..97c39b34a19b 100644 --- a/user_guide_src/source/installation/installing_composer.rst +++ b/user_guide_src/source/installation/installing_composer.rst @@ -7,6 +7,8 @@ Composer Installation Composer can be used in several ways to install CodeIgniter4 on your system. +.. important:: CodeIgniter4 requires Composer 2.0.14 or later. + The first technique describes creating a skeleton project using CodeIgniter4, that you would then use as the base for a new webapp. The second technique described below lets you add CodeIgniter4 to an existing diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index 29a801f77db2..07169f661f86 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -12,16 +12,14 @@ Please refer to the upgrade instructions corresponding to your installation meth :local: :depth: 2 -Trouble Shooting +Composer Version **************** -Call to undefined method Composer\\InstalledVersions::getAllRawData() -===================================================================== +.. important:: If you use Composer Installation, CodeIgniter v4.3.0 requires + Composer 2.0.14 or later. -Some users reported "*Fatal error: Uncaught Error: Call to undefined method Composer\\InstalledVersions::getAllRawData()*" after upgrading with Composer. - -If you get the error, upgrade your ``composer`` tool, and delete the **vendor/** -directory, and run ``composer update`` again. +If you are using older version of Composer, upgrade your ``composer`` tool, +and delete the **vendor/** directory, and run ``composer update`` again. The procedure, for example, is as follows:: From b840a60d36fc8af4b73cee37a6749510300d7702 Mon Sep 17 00:00:00 2001 From: Stefan Bauer Date: Thu, 12 Jan 2023 16:16:32 +0100 Subject: [PATCH 39/56] docs: update errors_list template check for empty $errors now with the same content as https://github.com/codeigniter4/CodeIgniter4/blob/develop/user_guide_src/source/models/model/033.php --- user_guide_src/source/libraries/validation/030.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/user_guide_src/source/libraries/validation/030.php b/user_guide_src/source/libraries/validation/030.php index f7c69eb42e99..32005c35b635 100644 --- a/user_guide_src/source/libraries/validation/030.php +++ b/user_guide_src/source/libraries/validation/030.php @@ -1,7 +1,7 @@ - + + From 7899f8afe5ee8a5e5d56dcdf37af7d7d60e658c9 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 13 Jan 2023 08:43:42 +0900 Subject: [PATCH 40/56] docs: fix note Composer installation does not matter. If using Composer autoloader, the error occurs. --- user_guide_src/source/installation/upgrade_430.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index 07169f661f86..fb93b74c782b 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -15,7 +15,7 @@ Please refer to the upgrade instructions corresponding to your installation meth Composer Version **************** -.. important:: If you use Composer Installation, CodeIgniter v4.3.0 requires +.. important:: If you use Composer, CodeIgniter v4.3.0 requires Composer 2.0.14 or later. If you are using older version of Composer, upgrade your ``composer`` tool, From 50c10f2bb407ec70d41236068587f2acfd73f5be Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 13 Jan 2023 08:47:40 +0900 Subject: [PATCH 41/56] fix: improve error message --- system/Autoloader/Autoloader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index 1c03b0419fa8..06c378273332 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -379,8 +379,8 @@ private function loadComposerNamespaces(ClassLoader $composer, array $composerPa } else { throw new RuntimeException( 'Your Composer version is too old.' - . ' Please update Composer (run `composer self-update`) and remove your vendor/ directory,' - . ' and run `composer update`.' + . ' Please update Composer (run `composer self-update`) to v2.0.14 or later' + . ' and remove your vendor/ directory, and run `composer update`.' ); } From fb71890d4dee336cc48006fb8fb51c3cf562c25e Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 13 Jan 2023 08:49:08 +0900 Subject: [PATCH 42/56] refactor: remove else --- system/Autoloader/Autoloader.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index 06c378273332..0f1d91eb7809 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -373,16 +373,15 @@ private function loadComposerNamespaces(ClassLoader $composer, array $composerPa unset($namespacePaths['CodeIgniter\\']); } - if (method_exists(InstalledVersions::class, 'getAllRawData')) { - // This method requires Composer 2.0.14 or later. - $packageList = InstalledVersions::getAllRawData()[0]['versions']; - } else { + if (! method_exists(InstalledVersions::class, 'getAllRawData')) { throw new RuntimeException( 'Your Composer version is too old.' . ' Please update Composer (run `composer self-update`) to v2.0.14 or later' . ' and remove your vendor/ directory, and run `composer update`.' ); } + // This method requires Composer 2.0.14 or later. + $packageList = InstalledVersions::getAllRawData()[0]['versions']; // Check config for $composerPackages. $only = $composerPackages['only'] ?? []; From acc335852dc88d0961df6e7f3eda576161099676 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 13 Jan 2023 10:00:56 +0900 Subject: [PATCH 43/56] docs: add explanation for 0 --- user_guide_src/source/helpers/cookie_helper.rst | 2 +- user_guide_src/source/outgoing/response.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/helpers/cookie_helper.rst b/user_guide_src/source/helpers/cookie_helper.rst index d19f4dbe5589..a26bf180f27b 100755 --- a/user_guide_src/source/helpers/cookie_helper.rst +++ b/user_guide_src/source/helpers/cookie_helper.rst @@ -25,7 +25,7 @@ The following functions are available: :param mixed $name: Cookie name *or* associative array of all of the parameters available to this function :param string $value: Cookie value - :param int $expire: Number of seconds until expiration + :param int $expire: Number of seconds until expiration. If set to ``0`` the cookie will only last as long as the browser is open :param string $domain: Cookie domain (usually: .yourdomain.com) :param string $path: Cookie path :param string $prefix: Cookie name prefix. If ``''``, the default from **app/Config/Cookie.php** is used diff --git a/user_guide_src/source/outgoing/response.rst b/user_guide_src/source/outgoing/response.rst index f3e0909487a4..c3c10bc8d40d 100644 --- a/user_guide_src/source/outgoing/response.rst +++ b/user_guide_src/source/outgoing/response.rst @@ -366,7 +366,7 @@ The methods provided by the parent class that are available are: :param array|Cookie|string $name: Cookie name or an array of parameters or an instance of ``CodeIgniter\Cookie\Cookie`` :param string $value: Cookie value - :param int $expire: Cookie expiration time in seconds + :param int $expire: Cookie expiration time in seconds. If set to ``0`` the cookie will only last as long as the browser is open :param string $domain: Cookie domain :param string $path: Cookie path :param string $prefix: Cookie name prefix. If set to ``''``, the default value from **app/Config/Cookie.php** will be used From 816cce7cbdf2a6d7227dfe8ba83cc57d84599550 Mon Sep 17 00:00:00 2001 From: Stefan Bauer Date: Fri, 13 Jan 2023 07:24:32 +0100 Subject: [PATCH 44/56] add esc to echo $error --- user_guide_src/source/libraries/validation/030.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/validation/030.php b/user_guide_src/source/libraries/validation/030.php index 32005c35b635..f0e48d26de73 100644 --- a/user_guide_src/source/libraries/validation/030.php +++ b/user_guide_src/source/libraries/validation/030.php @@ -1,7 +1,7 @@
$error): ?> -

+

From 3542afc1cefda95e89a09d3909a8f99f85676a6b Mon Sep 17 00:00:00 2001 From: Stefan Bauer Date: Fri, 13 Jan 2023 07:26:21 +0100 Subject: [PATCH 45/56] docs: add esc() to echo $error --- user_guide_src/source/models/model/033.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/models/model/033.php b/user_guide_src/source/models/model/033.php index 32005c35b635..f0e48d26de73 100644 --- a/user_guide_src/source/models/model/033.php +++ b/user_guide_src/source/models/model/033.php @@ -1,7 +1,7 @@
$error): ?> -

+

From 62cf0d912570d42a97203ad9049f0f0748c07411 Mon Sep 17 00:00:00 2001 From: Stefan Bauer Date: Fri, 13 Jan 2023 09:26:10 +0100 Subject: [PATCH 46/56] revert changes, just put if !empty around --- user_guide_src/source/libraries/validation/030.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/libraries/validation/030.php b/user_guide_src/source/libraries/validation/030.php index f0e48d26de73..86e4aaf85583 100644 --- a/user_guide_src/source/libraries/validation/030.php +++ b/user_guide_src/source/libraries/validation/030.php @@ -1,7 +1,9 @@ -
- $error): ?> -

- + From 25c87f3f72638d16171caa6ee67d2d7604c9dc60 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Jan 2023 15:00:56 +0000 Subject: [PATCH 47/56] chore(deps-dev): update rector/rector requirement from 0.15.4 to 0.15.5 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.15.4...0.15.5) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2cd21cd2aec8..682e3f9c81c4 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "phpunit/phpcov": "^8.2", "phpunit/phpunit": "^9.1", "predis/predis": "^1.1 || ^2.0", - "rector/rector": "0.15.4", + "rector/rector": "0.15.5", "vimeo/psalm": "^5.0" }, "suggest": { From ddd6410d3ea9fce94a2982370b36214e17c646f0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 14 Jan 2023 10:11:35 +0900 Subject: [PATCH 48/56] Prep for 4.3.1 release --- CHANGELOG.md | 14 ++++ system/CodeIgniter.php | 2 +- user_guide_src/source/changelogs/v4.3.1.rst | 20 ++--- user_guide_src/source/conf.py | 2 +- .../source/installation/upgrade_431.rst | 81 +++++++++++++++++++ .../source/installation/upgrading.rst | 1 + 6 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 user_guide_src/source/installation/upgrade_431.rst diff --git a/CHANGELOG.md b/CHANGELOG.md index 60e6e3b4ed00..97bae414d146 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [v4.3.1](https://github.com/codeigniter4/CodeIgniter4/tree/v4.3.1) (2023-01-14) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.3.0...v4.3.1) + +### Fixed Bugs +* fix: Email config in the .env doesn't appear as expected by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7078 +* fix: TypeError in Validation is_unique/is_not_unique by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7085 +* fix: revert method name resetQuery() changed accidentally by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7083 +* fix: handling float in Validation Strcit Rules (greater_than, greater_than_equal_to, less_than, less_than_equal_to) by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7098 +* docs: add missing instruction for Config/Exceptions in PHP 8.2 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7100 +* fix: Call to undefined method Composer\InstalledVersions::getAllRawData() error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7107 + +### Refactoring +* [Rector] Enable AddDefaultValueForUndefinedVariableRector by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/7088 + ## [v4.3.0](https://github.com/codeigniter4/CodeIgniter4/tree/v4.3.0) (2023-01-10) [Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.12...v4.3.0) diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 43f4caad61ea..5cb98c438863 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -47,7 +47,7 @@ class CodeIgniter /** * The current version of CodeIgniter Framework */ - public const CI_VERSION = '4.3.0'; + public const CI_VERSION = '4.3.1'; /** * App startup time. diff --git a/user_guide_src/source/changelogs/v4.3.1.rst b/user_guide_src/source/changelogs/v4.3.1.rst index e1eb66188411..f671fa3ffcc0 100644 --- a/user_guide_src/source/changelogs/v4.3.1.rst +++ b/user_guide_src/source/changelogs/v4.3.1.rst @@ -1,7 +1,7 @@ Version 4.3.1 ############# -Release Date: Unreleased +Release Date: January 14, 2023 **4.3.1 release of CodeIgniter4** @@ -9,21 +9,15 @@ Release Date: Unreleased :local: :depth: 3 -BREAKING -******** - -Message Changes -*************** - -Changes -******* - -Deprecations -************ - Bugs Fixed ********** +* Fixed: some environment variable (**.env**) values were not reflected in Email Config +* Fixed: TypeError in Validation ``is_unique`` and ``is_not_unique`` +* Fixed: revert method name ``BaseBuilder::resetQuery()`` changed accidentally +* Fixed: handling float in Validation Strcit Rules (``greater_than``, ``greater_than_equal_to``, ``less_than``, ``less_than_equal_to``) +* Fixed: missing instruction for ``Config\Exceptions`` in PHP 8.2 in the user guide + See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index 16e0209a916d..a0484b3d0c3c 100644 --- a/user_guide_src/source/conf.py +++ b/user_guide_src/source/conf.py @@ -26,7 +26,7 @@ version = '4.3' # The full version, including alpha/beta/rc tags. -release = '4.3.0' +release = '4.3.1' # -- General configuration --------------------------------------------------- diff --git a/user_guide_src/source/installation/upgrade_431.rst b/user_guide_src/source/installation/upgrade_431.rst new file mode 100644 index 000000000000..4adce6d4af2d --- /dev/null +++ b/user_guide_src/source/installation/upgrade_431.rst @@ -0,0 +1,81 @@ +############################## +Upgrading from 4.3.0 to 4.3.1 +############################## + +Please refer to the upgrade instructions corresponding to your installation method. + +- :ref:`Composer Installation App Starter Upgrading ` +- :ref:`Composer Installation Adding CodeIgniter4 to an Existing Project Upgrading ` +- :ref:`Manual Installation Upgrading ` + +.. contents:: + :local: + :depth: 2 + +Composer Version +**************** + +.. important:: If you use Composer, CodeIgniter v4.3 requires + Composer 2.0.14 or later. + +If you are using older version of Composer, upgrade your ``composer`` tool, +and delete the **vendor/** directory, and run ``composer update`` again. + +The procedure, for example, is as follows:: + + > composer self-update + > rm -rf vendor/ + > composer update + +Mandatory File Changes +********************** + +Config Files +============ + +app/Config/Email.php +-------------------- + +- If you updated **app/Config/Email.php** when upgrading to v4.3.0, you must + set the default values to ``$fromEmail``, ``$fromName``, ``$recipients``, + ``$SMTPHost``, ``$SMTPUser`` and ``$SMTPPass`` to apply environment variable + (**.env**) values. +- If no default values are set, setting environment variables for them will not + be reflected in the Config object. + +app/Config/Exceptions.php +------------------------- + +- If you are using PHP 8.2, you need to add new properties ``$logDeprecations`` and ``$deprecationLogLevel``. + +Project Files +************* + +Some files in the **project space** (root, app, public, writable) received updates. Due to +these files being outside of the **system** scope they will not be changed without your intervention. + +There are some third-party CodeIgniter modules available to assist with merging changes to +the project space: `Explore on Packagist `_. + +Content Changes +=============== + +The following files received significant changes (including deprecations or visual adjustments) +and it is recommended that you merge the updated versions with your application: + +Config +------ + +- app/Config/Encryption.php + - Set the default value ``''`` to ``$fromEmail``, ``$fromName``, + ``$recipients``, ``$SMTPHost``, ``$SMTPUser`` and ``$SMTPPass`` + to apply environment variable (**.env**) values. + +All Changes +=========== + +This is a list of all files in the **project space** that received changes; +many will be simple comments or formatting that have no effect on the runtime: + +- app/Config/Email.php +- composer.json diff --git a/user_guide_src/source/installation/upgrading.rst b/user_guide_src/source/installation/upgrading.rst index 1608661204d7..f5600aa52d00 100644 --- a/user_guide_src/source/installation/upgrading.rst +++ b/user_guide_src/source/installation/upgrading.rst @@ -16,6 +16,7 @@ See also :doc:`./backward_compatibility_notes`. backward_compatibility_notes + upgrade_431 upgrade_430 upgrade_4212 upgrade_4211 From 235d260fad956b50941c6c2c8772d8dc3ea6ec37 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 14 Jan 2023 10:46:38 +0900 Subject: [PATCH 49/56] docs: add empty lines --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97bae414d146..122d301359ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ [Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.3.0...v4.3.1) ### Fixed Bugs + * fix: Email config in the .env doesn't appear as expected by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7078 * fix: TypeError in Validation is_unique/is_not_unique by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7085 * fix: revert method name resetQuery() changed accidentally by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7083 @@ -12,6 +13,7 @@ * fix: Call to undefined method Composer\InstalledVersions::getAllRawData() error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7107 ### Refactoring + * [Rector] Enable AddDefaultValueForUndefinedVariableRector by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/7088 ## [v4.3.0](https://github.com/codeigniter4/CodeIgniter4/tree/v4.3.0) (2023-01-10) From c0c54c06153fa885e49221d5901f80dc4051c1b7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 14 Jan 2023 10:46:52 +0900 Subject: [PATCH 50/56] docs: remove reverted PR in CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 122d301359ce..74b2f56755c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,6 @@ * fix: exceptionHandler may return invalid HTTP status code by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6228 * feat: add Form helpers for Validation Errors by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6384 * fix: ValidationInterface by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6253 -* [Reverted] Make Unique Index Name Unique by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6516 * fix: types in database classes by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6527 * fix: ResponseInterface (1) by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6556 * Improve BaseConnection::getForeignKeyData() and Forge::addForeignKey() by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6468 From 08d1c3481ee2337d5b474d4b6750f3c1521aaead Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 14 Jan 2023 13:06:41 +0900 Subject: [PATCH 51/56] docs: update out of dated config item --- user_guide_src/source/libraries/sessions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index 866236d7fde2..ba3776129c9e 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -569,7 +569,7 @@ For PostgreSQL:: and the session ID and a delimiter. It should be increased as needed, for example, when using long session IDs. -You will also need to add a PRIMARY KEY **depending on your 'sessionMatchIP' +You will also need to add a PRIMARY KEY **depending on your $matchIP setting**. The examples below work both on MySQL and PostgreSQL:: // When sessionMatchIP = true From cf775dcc0fd0a7144f00d78cbdf5adcdd59c8134 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 14 Jan 2023 13:07:28 +0900 Subject: [PATCH 52/56] docs: change warning to important Warning note is used for security warning. --- user_guide_src/source/libraries/sessions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index ba3776129c9e..a639f09861f1 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -632,7 +632,7 @@ link you to it: https://github.com/phpredis/phpredis -.. warning:: CodeIgniter's Session library does NOT use the actual 'redis' +.. important:::: CodeIgniter's Session library does NOT use the actual 'redis' ``session.save_handler``. Take note **only** of the path format in the link above. From e7aa97b7d91b564ec8cb64f6dd404c421ad48fde Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 14 Jan 2023 13:08:43 +0900 Subject: [PATCH 53/56] docs: move note up --- user_guide_src/source/libraries/sessions.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index a639f09861f1..f97e52ef412e 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -525,6 +525,14 @@ into using `tmpfs Date: Sat, 14 Jan 2023 13:09:08 +0900 Subject: [PATCH 54/56] docs: add section titles --- user_guide_src/source/libraries/sessions.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index f97e52ef412e..8315c0fb7ef5 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -542,6 +542,9 @@ However, there are some conditions that must be met: - You can NOT use a persistent connection. +Configure DatabaseHandler +------------------------- + In order to use the 'DatabaseHandler' session driver, you must also create this table that we already mentioned and then set it as your ``$savePath`` value. @@ -623,6 +626,9 @@ bundled with PHP. Chances are, you're only be using the RedisHandler driver only if you're already both familiar with Redis and using it for other purposes. +Configure RedisHandler +---------------------- + Just as with the 'FileHandler' and 'DatabaseHandler' drivers, you must also configure the storage location for your sessions via the ``$savePath`` setting. @@ -665,6 +671,9 @@ deleted after Y seconds have passed (but not necessarily that it won't expire earlier than that time). This happens very rarely, but should be considered as it may result in loss of sessions. +Configure RedisHandler +---------------------- + The ``$savePath`` format is fairly straightforward here, being just a ``host:port`` pair: From e2af88035848a34f67aecda0d25ea9beb4801506 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 14 Jan 2023 13:09:25 +0900 Subject: [PATCH 55/56] docs: change text decoration --- user_guide_src/source/libraries/sessions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index 8315c0fb7ef5..d7b68b36895f 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -603,7 +603,7 @@ from the cli to generate a migration file for you:: > php spark make:migration --session > php spark migrate -This command will take the **savePath** and **matchIP** settings into account +This command will take the ``$savePath`` and ``$matchIP`` settings into account when it generates the code. .. _sessions-redishandler-driver: From 4f4e2f0f5993fb6521d50652aeedf854c73970a7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 14 Jan 2023 13:09:46 +0900 Subject: [PATCH 56/56] docs: add empty lines in sample code --- user_guide_src/source/libraries/sessions/039.php | 2 ++ user_guide_src/source/libraries/sessions/041.php | 2 ++ user_guide_src/source/libraries/sessions/042.php | 2 ++ 3 files changed, 6 insertions(+) diff --git a/user_guide_src/source/libraries/sessions/039.php b/user_guide_src/source/libraries/sessions/039.php index 77a0a02b0222..a561e4a49cb6 100644 --- a/user_guide_src/source/libraries/sessions/039.php +++ b/user_guide_src/source/libraries/sessions/039.php @@ -9,7 +9,9 @@ class Session extends BaseConfig { // ... public string $driver = 'CodeIgniter\Session\Handlers\DatabaseHandler'; + // ... public string $savePath = 'ci_sessions'; + // ... } diff --git a/user_guide_src/source/libraries/sessions/041.php b/user_guide_src/source/libraries/sessions/041.php index 4f26bf79661b..091ec22ce651 100644 --- a/user_guide_src/source/libraries/sessions/041.php +++ b/user_guide_src/source/libraries/sessions/041.php @@ -9,7 +9,9 @@ class Session extends BaseConfig { // ... public string $driver = 'CodeIgniter\Session\Handlers\RedisHandler'; + // ... public string $savePath = 'tcp://localhost:6379'; + // ... } diff --git a/user_guide_src/source/libraries/sessions/042.php b/user_guide_src/source/libraries/sessions/042.php index 3cdbe41f2ae1..92ba42b9af3d 100644 --- a/user_guide_src/source/libraries/sessions/042.php +++ b/user_guide_src/source/libraries/sessions/042.php @@ -9,7 +9,9 @@ class Session extends BaseConfig { // ... public string $driver = 'CodeIgniter\Session\Handlers\MemcachedHandler'; + // ... public string $savePath = 'localhost:11211'; + // ... }