From efe7ae5ada41c1b2f52e75ca9cbd8ddb99de651e Mon Sep 17 00:00:00 2001 From: baycik Date: Tue, 10 Jan 2023 13:04:06 +0300 Subject: [PATCH 001/290] Fixing bug on stuck content-type header When I use FeatureTestTrait if I use withBodyFormat('json') function on one request all subsequent requests are sent with content-type: application/json even if their body format is not 'json'. This bug started when I upgraded CI from 4.0.x to 4.2.11. After long investigation I think I found the source of the problem. On line 289 initialization of request has been changed to Services::request($config, true) so for each subsequent test request same instance is used. That's why if content-type on one request is set then all other requests are sent with this header. We need some reset mechanism. I dont know if this method is right but it worked for me. --- system/Test/FeatureTestTrait.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/system/Test/FeatureTestTrait.php b/system/Test/FeatureTestTrait.php index 3b36129f71e1..8207b24c3933 100644 --- a/system/Test/FeatureTestTrait.php +++ b/system/Test/FeatureTestTrait.php @@ -364,7 +364,8 @@ protected function setRequestBody(Request $request, ?array $params = null): Requ return $request; } - + + $request->removeHeader('Content-Type'); if (isset($this->bodyFormat) && $this->bodyFormat !== '') { if (empty($params)) { $params = $request->fetchGlobal('request'); @@ -381,7 +382,7 @@ protected function setRequestBody(Request $request, ?array $params = null): Requ $request->setHeader('Content-Type', $formatMime); } } - + return $request; } } From bf36c4177a68f44fb9879681bc20aff636046a9e Mon Sep 17 00:00:00 2001 From: baycik Date: Tue, 10 Jan 2023 16:32:49 +0300 Subject: [PATCH 002/290] Update FeatureTestTrait.php --- system/Test/FeatureTestTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Test/FeatureTestTrait.php b/system/Test/FeatureTestTrait.php index 8207b24c3933..38a85dabfb5c 100644 --- a/system/Test/FeatureTestTrait.php +++ b/system/Test/FeatureTestTrait.php @@ -364,7 +364,7 @@ protected function setRequestBody(Request $request, ?array $params = null): Requ return $request; } - + $request->removeHeader('Content-Type'); if (isset($this->bodyFormat) && $this->bodyFormat !== '') { if (empty($params)) { @@ -382,7 +382,7 @@ protected function setRequestBody(Request $request, ?array $params = null): Requ $request->setHeader('Content-Type', $formatMime); } } - + return $request; } } From ce60e23d0b941d55df4fc083e841655f133b1457 Mon Sep 17 00:00:00 2001 From: baycik Date: Tue, 10 Jan 2023 16:59:31 +0300 Subject: [PATCH 003/290] Update FeatureTestTrait.php --- system/Test/FeatureTestTrait.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system/Test/FeatureTestTrait.php b/system/Test/FeatureTestTrait.php index 38a85dabfb5c..e6e8492ea466 100644 --- a/system/Test/FeatureTestTrait.php +++ b/system/Test/FeatureTestTrait.php @@ -286,7 +286,7 @@ protected function setupRequest(string $method, ?string $path = null): IncomingR { $path = URI::removeDotSegments($path); $config = config(App::class); - $request = Services::request($config, true); + $request = Services::request($config, false); // $path may have a query in it $parts = explode('?', $path); @@ -365,7 +365,6 @@ protected function setRequestBody(Request $request, ?array $params = null): Requ return $request; } - $request->removeHeader('Content-Type'); if (isset($this->bodyFormat) && $this->bodyFormat !== '') { if (empty($params)) { $params = $request->fetchGlobal('request'); From ea25c9cfd0913184dbf865e247e83d099b02e587 Mon Sep 17 00:00:00 2001 From: Stefan Bauer Date: Wed, 11 Jan 2023 16:39:38 +0100 Subject: [PATCH 004/290] remove All from Options All -Indexes Options All -Indexes causes a 500 Internal Server Error. (Apache on hostpoint.ch / interxion). Without the -All it works fine. I'm not sure about all the effects, but I think the -All is already handled in the Apache directive and has not to be in .htaccess --- public/.htaccess | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/.htaccess b/public/.htaccess index a5d6c2a54128..dbed322fdc1e 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,5 +1,5 @@ # Disable directory browsing -Options All -Indexes +Options -Indexes # ---------------------------------------------------------------------- # Rewrite engine From 160e4a485f3692754badbfa7fe9981fb94ca8708 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 12 Jan 2023 15:55:36 +0900 Subject: [PATCH 005/290] docs: fix incorrect sample code --- user_guide_src/source/outgoing/view_parser/009.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/outgoing/view_parser/009.php b/user_guide_src/source/outgoing/view_parser/009.php index 6f4b96e82274..e48f7ab5d8dd 100644 --- a/user_guide_src/source/outgoing/view_parser/009.php +++ b/user_guide_src/source/outgoing/view_parser/009.php @@ -4,7 +4,9 @@ $data = [ 'name' => 'George', - 'location' => ['city' => 'Red City', 'planet' => 'Mars'], + 'location' => [ + ['city' => 'Red City', 'planet' => 'Mars'], + ], ]; return $parser->setData($data)->renderString($template); From e8e5fac33ee8d5cdfb3aa74bc258cac7f592a524 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 13 Jan 2023 09:30:33 +0900 Subject: [PATCH 006/290] docs: fix incorrect sample code --- user_guide_src/source/outgoing/view_parser/008.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/outgoing/view_parser/008.php b/user_guide_src/source/outgoing/view_parser/008.php index 8cac9bbbaa9d..f7898a27bfa9 100644 --- a/user_guide_src/source/outgoing/view_parser/008.php +++ b/user_guide_src/source/outgoing/view_parser/008.php @@ -4,8 +4,8 @@ 'blog_title' => 'My Blog Title', 'blog_heading' => 'My Blog Heading', 'blog_entry' => [ - 'title' => 'Title 1', - 'body' => 'Body 1', + ['title' => 'Title 1'], + ['body' => 'Body 1'], ], ]; From 8bb1c1761fb691aa2028eda33f0bc0f0df1973fb Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 13 Jan 2023 09:30:59 +0900 Subject: [PATCH 007/290] docs: imporve pseudo-variable names --- user_guide_src/source/outgoing/view_parser.rst | 8 ++++---- user_guide_src/source/outgoing/view_parser/008.php | 2 +- user_guide_src/source/outgoing/view_parser/009.php | 6 +++--- user_guide_src/source/outgoing/view_parser/010.php | 8 +++++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/user_guide_src/source/outgoing/view_parser.rst b/user_guide_src/source/outgoing/view_parser.rst index 9fb3f55c1007..b6083ba7054e 100644 --- a/user_guide_src/source/outgoing/view_parser.rst +++ b/user_guide_src/source/outgoing/view_parser.rst @@ -200,21 +200,21 @@ an associative array of values, like a record from a database: .. literalinclude:: view_parser/008.php -The value for the pseudo-variable ``blog_entry`` is an associative +The value for the pseudo-variable ``blog_entries`` is an associative array. The key/value pairs defined inside it will be exposed inside the variable pair loop for that variable. A **blog_template.php** that might work for the above::

{blog_title} - {blog_heading}

- {blog_entry} + {blog_entries}

{title}

{body}

- {/blog_entry} + {/blog_entries} -If you would like the other pseudo-variables accessible inside the ``blog_entry`` +If you would like the other pseudo-variables accessible inside the ``blog_entries`` scope, then make sure that the ``cascadeData`` option is set to true. Comments diff --git a/user_guide_src/source/outgoing/view_parser/008.php b/user_guide_src/source/outgoing/view_parser/008.php index f7898a27bfa9..1bc8a5a52d53 100644 --- a/user_guide_src/source/outgoing/view_parser/008.php +++ b/user_guide_src/source/outgoing/view_parser/008.php @@ -3,7 +3,7 @@ $data = [ 'blog_title' => 'My Blog Title', 'blog_heading' => 'My Blog Heading', - 'blog_entry' => [ + 'blog_entries' => [ ['title' => 'Title 1'], ['body' => 'Body 1'], ], diff --git a/user_guide_src/source/outgoing/view_parser/009.php b/user_guide_src/source/outgoing/view_parser/009.php index e48f7ab5d8dd..bfe83a52b41e 100644 --- a/user_guide_src/source/outgoing/view_parser/009.php +++ b/user_guide_src/source/outgoing/view_parser/009.php @@ -1,10 +1,10 @@ 'George', - 'location' => [ + 'name' => 'George', + 'locations' => [ ['city' => 'Red City', 'planet' => 'Mars'], ], ]; diff --git a/user_guide_src/source/outgoing/view_parser/010.php b/user_guide_src/source/outgoing/view_parser/010.php index 4eb11fd6d908..d0b52c4c300e 100644 --- a/user_guide_src/source/outgoing/view_parser/010.php +++ b/user_guide_src/source/outgoing/view_parser/010.php @@ -1,10 +1,12 @@ 'George', - 'location' => ['city' => 'Red City', 'planet' => 'Mars'], + 'name' => 'George', + 'locations' => [ + ['city' => 'Red City', 'planet' => 'Mars'], + ], ]; return $parser->setData($data)->renderString($template, ['cascadeData' => false]); From 05fbd3fe95b043290501aebe9e8bd4533c2bbde6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 09:57:48 +0900 Subject: [PATCH 008/290] docs: fix incorrect sample code --- user_guide_src/source/outgoing/view_parser/008.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/outgoing/view_parser/008.php b/user_guide_src/source/outgoing/view_parser/008.php index 1bc8a5a52d53..34fc2d6f0fdb 100644 --- a/user_guide_src/source/outgoing/view_parser/008.php +++ b/user_guide_src/source/outgoing/view_parser/008.php @@ -4,8 +4,10 @@ 'blog_title' => 'My Blog Title', 'blog_heading' => 'My Blog Heading', 'blog_entries' => [ - ['title' => 'Title 1'], - ['body' => 'Body 1'], + [ + 'title' => 'Title 1', + 'body' => 'Body 1', + ], ], ]; From fdc805921994727891da8076087392639914676b Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 11:45:04 +0900 Subject: [PATCH 009/290] docs: add missing Content Changes in View Files --- user_guide_src/source/installation/upgrade_430.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index fb93b74c782b..396b45b25f60 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -325,6 +325,17 @@ Config - app/Config/Validation.php - The default Validation Rules have been changed to Strict Rules for better security. See :ref:`validation-traditional-and-strict-rules`. +View Files +---------- + +The following view files have been changed to HTML5 compatible tags. +Also, error messages are now defined in the **Errors** language file. + +- app/Views/errors/html/error_404.php +- app/Views/errors/html/error_exception.php +- app/Views/errors/html/production.php +- app/Views/welcome_message.php + All Changes =========== From b96fcf10711f070dc2c033b4f91c5894705bae62 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 11:47:31 +0900 Subject: [PATCH 010/290] docs: add about missing Errors.php lang file --- user_guide_src/source/changelogs/v4.3.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelogs/v4.3.0.rst b/user_guide_src/source/changelogs/v4.3.0.rst index ed6047cd320e..5911f1686568 100644 --- a/user_guide_src/source/changelogs/v4.3.0.rst +++ b/user_guide_src/source/changelogs/v4.3.0.rst @@ -335,6 +335,7 @@ Message Changes - Updated English language strings to be more consistent. - Added ``CLI.generator.className.cell`` and ``CLI.generator.viewName.cell``. +- Added **en/Errors.php** file. Changes ******* From a21aaa126f70cb058606b51f99744ff2152f1930 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 11:55:46 +0900 Subject: [PATCH 011/290] docs: replace deprecated method in sample code --- user_guide_src/source/concepts/http/001.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/concepts/http/001.php b/user_guide_src/source/concepts/http/001.php index 59b5798a3541..4ed2d5c3a6a8 100644 --- a/user_guide_src/source/concepts/http/001.php +++ b/user_guide_src/source/concepts/http/001.php @@ -22,7 +22,7 @@ $request->getServer('Host'); // Retrieve an HTTP Request header, with case-insensitive names -$request->getHeader('host'); -$request->getHeader('Content-Type'); +$request->header('host'); +$request->header('Content-Type'); $request->getMethod(); // get, post, put, etc From e2f18bc4397f1b0e5d6f08775cbe24a4f6dd2966 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 11:58:12 +0900 Subject: [PATCH 012/290] docs: improve comment --- user_guide_src/source/concepts/http/001.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/concepts/http/001.php b/user_guide_src/source/concepts/http/001.php index 4ed2d5c3a6a8..27677fae36e6 100644 --- a/user_guide_src/source/concepts/http/001.php +++ b/user_guide_src/source/concepts/http/001.php @@ -4,7 +4,7 @@ $request = service('request'); -// the URI being requested (i.e., /about) +// the URI path being requested (i.e., /about) $request->getUri()->getPath(); // Retrieve $_GET and $_POST variables From ac477bcf94ebf56eca5366732abe1e556441f4fb Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 11:59:22 +0900 Subject: [PATCH 013/290] docs: update sample code for v4.3.0 --- user_guide_src/source/concepts/http/001.php | 6 ++++-- user_guide_src/source/concepts/http/002.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/concepts/http/001.php b/user_guide_src/source/concepts/http/001.php index 27677fae36e6..c224c211a4d1 100644 --- a/user_guide_src/source/concepts/http/001.php +++ b/user_guide_src/source/concepts/http/001.php @@ -2,7 +2,7 @@ use CodeIgniter\HTTP\IncomingRequest; -$request = service('request'); +$request = request(); // the URI path being requested (i.e., /about) $request->getUri()->getPath(); @@ -25,4 +25,6 @@ $request->header('host'); $request->header('Content-Type'); -$request->getMethod(); // get, post, put, etc +// Checks the HTTP method +$request->is('get'); +$request->is('post'); diff --git a/user_guide_src/source/concepts/http/002.php b/user_guide_src/source/concepts/http/002.php index e5fc38efeec2..9a15a6d42d5e 100644 --- a/user_guide_src/source/concepts/http/002.php +++ b/user_guide_src/source/concepts/http/002.php @@ -2,7 +2,7 @@ use CodeIgniter\HTTP\Response; -$response = service('response'); +$response = response(); $response->setStatusCode(Response::HTTP_OK); $response->setBody($output); From b780c0da3761f668ac1749b7e6da95db64c0e045 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 11:59:47 +0900 Subject: [PATCH 014/290] docs: lowercase preposition in title --- user_guide_src/source/concepts/http.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/concepts/http.rst b/user_guide_src/source/concepts/http.rst index 63b18e45e764..fbf9eb2ff29e 100644 --- a/user_guide_src/source/concepts/http.rst +++ b/user_guide_src/source/concepts/http.rst @@ -1,5 +1,5 @@ ########################## -Working With HTTP Requests +Working with HTTP Requests ########################## In order to get the most out of CodeIgniter, you need to have a basic understanding of how HTTP requests From edb69dec0ae7c6e3030f4259f49ce58a1dbfc85b Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 20:59:17 +0900 Subject: [PATCH 015/290] docs: fix incorrect method name --- user_guide_src/source/changelogs/v4.0.5.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.0.5.rst b/user_guide_src/source/changelogs/v4.0.5.rst index 33e14c380da6..fa2b42ea4a7b 100644 --- a/user_guide_src/source/changelogs/v4.0.5.rst +++ b/user_guide_src/source/changelogs/v4.0.5.rst @@ -41,7 +41,7 @@ Deprecations - Deprecated ``Config\Format::getFormatter`` in favor of ``CodeIgniter\Format\Format::getFormatter`` - Deprecated ``CodeIgniter\Security\Security::CSRFVerify`` in favor of ``CodeIgniter\Security\Security::verify`` - Deprecated ``CodeIgniter\Security\Security::getCSRFHash`` in favor of ``CodeIgniter\Security\Security::getHash`` -- Deprecated ``CodeIgniter\Security\Security::getCSRTokenName`` in favor of ``CodeIgniter\Security\Security::getCSRTokenName`` +- Deprecated ``CodeIgniter\Security\Security::getCSRTokenName()`` in favor of ``CodeIgniter\Security\Security::getTokenName()`` - Deprecated ``Config\App::$CSRFTokenName`` in favor of ``Config\Security::$tokenName`` - Deprecated ``Config\App::$CSRFHeaderName`` in favor of ``Config\Security::$headerName`` - Deprecated ``Config\App::$CSRFCookieName`` in favor of ``Config\Security::$cookieName`` From 5ef21fd564928e584b5507742cb45c1a3042e35b Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 21:00:01 +0900 Subject: [PATCH 016/290] docs: add () after method names --- user_guide_src/source/changelogs/v4.0.5.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.0.5.rst b/user_guide_src/source/changelogs/v4.0.5.rst index fa2b42ea4a7b..93b9f0dab52b 100644 --- a/user_guide_src/source/changelogs/v4.0.5.rst +++ b/user_guide_src/source/changelogs/v4.0.5.rst @@ -36,11 +36,11 @@ Bugs Fixed Deprecations ------------ -- Deprecated ``BaseCommand::getPad`` in favor of ``BaseCommand::setPad``. -- Deprecated ``CodeIgniter\Controller::loadHelpers`` in favor of ``helper`` function. -- Deprecated ``Config\Format::getFormatter`` in favor of ``CodeIgniter\Format\Format::getFormatter`` -- Deprecated ``CodeIgniter\Security\Security::CSRFVerify`` in favor of ``CodeIgniter\Security\Security::verify`` -- Deprecated ``CodeIgniter\Security\Security::getCSRFHash`` in favor of ``CodeIgniter\Security\Security::getHash`` +- Deprecated ``BaseCommand::getPad()`` in favor of ``BaseCommand::setPad()``. +- Deprecated ``CodeIgniter\Controller::loadHelpers()`` in favor of ``helper()`` function. +- Deprecated ``Config\Format::getFormatter()`` in favor of ``CodeIgniter\Format\Format::getFormatter()`` +- Deprecated ``CodeIgniter\Security\Security::CSRFVerify()`` in favor of ``CodeIgniter\Security\Security::verify()`` +- Deprecated ``CodeIgniter\Security\Security::getCSRFHash()`` in favor of ``CodeIgniter\Security\Security::getHash()`` - Deprecated ``CodeIgniter\Security\Security::getCSRTokenName()`` in favor of ``CodeIgniter\Security\Security::getTokenName()`` - Deprecated ``Config\App::$CSRFTokenName`` in favor of ``Config\Security::$tokenName`` - Deprecated ``Config\App::$CSRFHeaderName`` in favor of ``Config\Security::$headerName`` @@ -52,6 +52,6 @@ Deprecations - Deprecated ``migrate:create`` command in favor of ``make:migration`` command. - Deprecated ``CodeIgniter\Database\ModelFactory`` in favor of ``CodeIgniter\Config\Factories::models()`` - Deprecated ``CodeIgniter\Config\Config`` in favor of ``CodeIgniter\Config\Factories::config()`` -- Deprecated ``CodeIgniter\HTTP\Message::getHeader`` in favor of ``header()`` to prepare for PSR-7 -- Deprecated ``CodeIgniter\HTTP\Message::getHeaders`` in favor of ``headers()`` to prepare for PSR-7 +- Deprecated ``CodeIgniter\HTTP\Message::getHeader()`` in favor of ``header()`` to prepare for PSR-7 +- Deprecated ``CodeIgniter\HTTP\Message::getHeaders()`` in favor of ``headers()`` to prepare for PSR-7 - Deprecated ``Config\Cache::$storePath`` in favor of ``Config\Cache::$file['storePath']`` From 123a2b35cfcdbb05e7796960095452320b06333a Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 21:00:20 +0900 Subject: [PATCH 017/290] docs: change text decoration --- user_guide_src/source/changelogs/v4.0.5.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.0.5.rst b/user_guide_src/source/changelogs/v4.0.5.rst index 93b9f0dab52b..4f743d20163f 100644 --- a/user_guide_src/source/changelogs/v4.0.5.rst +++ b/user_guide_src/source/changelogs/v4.0.5.rst @@ -24,7 +24,7 @@ Enhancements Changes ------- -- System messages defined in ``system/Language/en/`` are now strictly for internal framework use and are not covered by backwards compatibility (BC) promise. Users may use these messages in their applications but at their own risks. +- System messages defined in **system/Language/en/** are now strictly for internal framework use and are not covered by backwards compatibility (BC) promise. Users may use these messages in their applications but at their own risks. Bugs Fixed ---------- From fe1267152913f9103e5c63df417330037a8e9304 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 21:00:44 +0900 Subject: [PATCH 018/290] docs: make function names linkable --- user_guide_src/source/changelogs/v4.0.5.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.0.5.rst b/user_guide_src/source/changelogs/v4.0.5.rst index 4f743d20163f..ac2d5c4fb610 100644 --- a/user_guide_src/source/changelogs/v4.0.5.rst +++ b/user_guide_src/source/changelogs/v4.0.5.rst @@ -12,9 +12,9 @@ Release Date: January 31, 2021 Enhancements ------------ -- New URL helper function ``url_to()`` which creates absolute URLs based on controllers. +- New URL helper function :php:func:`url_to()` which creates absolute URLs based on controllers. - New Model option: ``$useAutoIncrement`` which when set to ``false`` allows you to provide your own primary key for each record in the table. Handy when we want to implement 1:1 relation or use UUIDs for our model. -- New URL helper function ``url_is()`` which allows you to check the current URL to see if matches the given string. +- New URL helper function :php:func:`url_is()` which allows you to check the current URL to see if matches the given string. - Services now have their config parameters strictly typehinted. This will ensure no one will pass a different config instance. If you need to pass a new config with additional properties, you need to extend that particular config. - Support for setting SameSite attribute on Session and CSRF cookies has been added. For security and compatibility with latest browser versions, the default setting is ``Lax``. - Guessing file extensions from mime type in ``Config\Mimes::guessExtensionFromType`` now only reverse searches the ``$mimes`` array if no extension is proposed (i.e., usually not for uploaded files). From 3c483a26f97bf5363bda4545e35e2027957b6158 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 21:01:48 +0900 Subject: [PATCH 019/290] docs: add missing period --- user_guide_src/source/changelogs/v4.0.5.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.0.5.rst b/user_guide_src/source/changelogs/v4.0.5.rst index ac2d5c4fb610..940d917290b8 100644 --- a/user_guide_src/source/changelogs/v4.0.5.rst +++ b/user_guide_src/source/changelogs/v4.0.5.rst @@ -19,7 +19,7 @@ Enhancements - Support for setting SameSite attribute on Session and CSRF cookies has been added. For security and compatibility with latest browser versions, the default setting is ``Lax``. - Guessing file extensions from mime type in ``Config\Mimes::guessExtensionFromType`` now only reverse searches the ``$mimes`` array if no extension is proposed (i.e., usually not for uploaded files). - The getter functions for file extensions of uploaded files now have different fallback values (``$this->getClientExtension()`` for ``UploadedFile->getExtension()`` and ``''`` for ``UploadedFile->guessExtension()``). This is a security fix and makes the process less dependent on the client. -- The Cache ``FileHandler`` now allows setting the file permissions mode via ``Config\Cache`` +- The Cache ``FileHandler`` now allows setting the file permissions mode via ``Config\Cache``. Changes ------- From be7915f95550b26ace5f0b561db250ad797f2b7a Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 21:02:55 +0900 Subject: [PATCH 020/290] docs: fix class method notation --- user_guide_src/source/changelogs/v4.0.5.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.0.5.rst b/user_guide_src/source/changelogs/v4.0.5.rst index 940d917290b8..708b2c14994d 100644 --- a/user_guide_src/source/changelogs/v4.0.5.rst +++ b/user_guide_src/source/changelogs/v4.0.5.rst @@ -18,7 +18,7 @@ Enhancements - Services now have their config parameters strictly typehinted. This will ensure no one will pass a different config instance. If you need to pass a new config with additional properties, you need to extend that particular config. - Support for setting SameSite attribute on Session and CSRF cookies has been added. For security and compatibility with latest browser versions, the default setting is ``Lax``. - Guessing file extensions from mime type in ``Config\Mimes::guessExtensionFromType`` now only reverse searches the ``$mimes`` array if no extension is proposed (i.e., usually not for uploaded files). -- The getter functions for file extensions of uploaded files now have different fallback values (``$this->getClientExtension()`` for ``UploadedFile->getExtension()`` and ``''`` for ``UploadedFile->guessExtension()``). This is a security fix and makes the process less dependent on the client. +- The getter functions for file extensions of uploaded files now have different fallback values (``UploadedFile::getClientExtension()`` for ``UploadedFile::getExtension()`` and ``''`` for ``UploadedFile::guessExtension()``). This is a security fix and makes the process less dependent on the client. - The Cache ``FileHandler`` now allows setting the file permissions mode via ``Config\Cache``. Changes From 8d806a44586704c9c6b8c533842193260f2ff40f Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 15 Jan 2023 21:03:45 +0900 Subject: [PATCH 021/290] docs: add () after method name --- user_guide_src/source/changelogs/v4.0.5.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.0.5.rst b/user_guide_src/source/changelogs/v4.0.5.rst index 708b2c14994d..4c2fd34dabaf 100644 --- a/user_guide_src/source/changelogs/v4.0.5.rst +++ b/user_guide_src/source/changelogs/v4.0.5.rst @@ -17,7 +17,7 @@ Enhancements - New URL helper function :php:func:`url_is()` which allows you to check the current URL to see if matches the given string. - Services now have their config parameters strictly typehinted. This will ensure no one will pass a different config instance. If you need to pass a new config with additional properties, you need to extend that particular config. - Support for setting SameSite attribute on Session and CSRF cookies has been added. For security and compatibility with latest browser versions, the default setting is ``Lax``. -- Guessing file extensions from mime type in ``Config\Mimes::guessExtensionFromType`` now only reverse searches the ``$mimes`` array if no extension is proposed (i.e., usually not for uploaded files). +- Guessing file extensions from mime type in ``Config\Mimes::guessExtensionFromType()`` now only reverse searches the ``$mimes`` array if no extension is proposed (i.e., usually not for uploaded files). - The getter functions for file extensions of uploaded files now have different fallback values (``UploadedFile::getClientExtension()`` for ``UploadedFile::getExtension()`` and ``''`` for ``UploadedFile::guessExtension()``). This is a security fix and makes the process less dependent on the client. - The Cache ``FileHandler`` now allows setting the file permissions mode via ``Config\Cache``. From 929688c3df8b37a1702bde4757acda68a6a0f4ae Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 16 Jan 2023 11:14:01 +0900 Subject: [PATCH 022/290] docs: add BREAKING section --- user_guide_src/source/changelogs/v4.0.4.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.0.4.rst b/user_guide_src/source/changelogs/v4.0.4.rst index 740a150f42cb..89e12f1c86d9 100644 --- a/user_guide_src/source/changelogs/v4.0.4.rst +++ b/user_guide_src/source/changelogs/v4.0.4.rst @@ -9,6 +9,11 @@ Release Date: July 15, 2020 :local: :depth: 2 +BREAKING +-------- + +- Added ``$arguments`` parameter to ``after()`` and ``before()`` in ``FilterInterface``. This is a breaking change, so all code implementing the ``FilterInterface`` must be updated. + Enhancements ------------ @@ -59,5 +64,4 @@ Bugs Fixed - Fixed bug in Image GD handler that would try to compress images twice in certain cases - Ensure get translation output logic work on selected locale, dashed locale, and fallback "en" - Fix is_unique/is_not_unique validation called on POST/PUT via API in Postgresql -- Added ``$arguments`` parameter to after() and before() in FilterInterface. This is a breaking change, so all code implementing the FilterInterface must be updated - Fixed a bug where filter arguments were not passed to after() From a604d8e5b474d2863c755ccc1ca982e30168354f Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 16 Jan 2023 11:14:28 +0900 Subject: [PATCH 023/290] docs: improvements for readability --- user_guide_src/source/changelogs/v4.0.4.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.0.4.rst b/user_guide_src/source/changelogs/v4.0.4.rst index 89e12f1c86d9..4f2888c7656a 100644 --- a/user_guide_src/source/changelogs/v4.0.4.rst +++ b/user_guide_src/source/changelogs/v4.0.4.rst @@ -29,11 +29,11 @@ Enhancements - New :doc:`command() helper function ` to programatically run your CLI commands. Useful for testing and cron jobs. - New command, ``make:seeder`` to generate a :doc:`Database Seed class ` skeleton file. - Colors now available on the CLI within Windows, as well as other Windows-related CLI improvements. -- New helper :doc:`mb_url_title ` that functions like ``url_title`` but automatically escapes and extended URL characters. +- New helper :doc:`mb_url_title() ` that functions like ``url_title()`` but automatically escapes and extended URL characters. - :doc:`Image library ` now supports ``webp`` images. - Added Unicode support for regular expressions in the Router. -- Added support for removing hidden folders in the :doc:`delete_files ` helper -- ``fetchGlobal`` in the Request class now supports applying filters to arrays of data, not just the first item. +- Added support for removing hidden folders in the :doc:`delete_files() ` helper +- ``fetchGlobal()`` in the Request class now supports applying filters to arrays of data, not just the first item. - ``file`` validation now works with arrays of files. - URI class now supports a ``setSilent()`` method that will disable the throwing of Exceptions. - New argument to ``URI::getSegment()`` that allows us to change the default value returned if nothing exists. @@ -45,7 +45,7 @@ Bugs Fixed ---------- - Fixed location for the SQLite3 database which by default will be now located in a ``writable`` folder instead of the ``public`` folder. -- Fixed bug where ``force_https`` could add ``https://`` a second time. +- Fixed bug where ``force_https()`` could add ``https://`` a second time. - Fixed a bug with CurlRequest that could result in incorrect "100 Continue" headers. - Image::save() bug fixed when ``$target`` parameter was ``null`` - fixes for ``set_checkbox()`` and ``set_radio()`` when the $default parameter is set to ``true`` @@ -58,10 +58,10 @@ Bugs Fixed - setting validation errors within a config file should now work - Unicode characters are not escaped when saving JSON from Entities. - redirecting with a custom HTTP code should work correctly now -- Time::setTimezone now working correctly +- ``Time::setTimezone()`` now working correctly - added full outer join support for Postgres - some cast items in the Entity (like array, json) were not being set correctly during a ``fill()`` process. - Fixed bug in Image GD handler that would try to compress images twice in certain cases - Ensure get translation output logic work on selected locale, dashed locale, and fallback "en" -- Fix is_unique/is_not_unique validation called on POST/PUT via API in Postgresql -- Fixed a bug where filter arguments were not passed to after() +- Fix ``is_unique``/``is_not_unique`` validation called on POST/PUT via API in PostgreSQL. +- Fixed a bug where filter arguments were not passed to ``after()`` From 1975369b77f9d8ed02c5bfc61cd7d34453c9b5d0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 16 Jan 2023 11:17:43 +0900 Subject: [PATCH 024/290] docs: add periods --- user_guide_src/source/changelogs/v4.0.4.rst | 30 ++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.0.4.rst b/user_guide_src/source/changelogs/v4.0.4.rst index 4f2888c7656a..90dddc804c5a 100644 --- a/user_guide_src/source/changelogs/v4.0.4.rst +++ b/user_guide_src/source/changelogs/v4.0.4.rst @@ -32,7 +32,7 @@ Enhancements - New helper :doc:`mb_url_title() ` that functions like ``url_title()`` but automatically escapes and extended URL characters. - :doc:`Image library ` now supports ``webp`` images. - Added Unicode support for regular expressions in the Router. -- Added support for removing hidden folders in the :doc:`delete_files() ` helper +- Added support for removing hidden folders in the :doc:`delete_files() ` helper. - ``fetchGlobal()`` in the Request class now supports applying filters to arrays of data, not just the first item. - ``file`` validation now works with arrays of files. - URI class now supports a ``setSilent()`` method that will disable the throwing of Exceptions. @@ -47,21 +47,21 @@ Bugs Fixed - Fixed location for the SQLite3 database which by default will be now located in a ``writable`` folder instead of the ``public`` folder. - Fixed bug where ``force_https()`` could add ``https://`` a second time. - Fixed a bug with CurlRequest that could result in incorrect "100 Continue" headers. -- Image::save() bug fixed when ``$target`` parameter was ``null`` -- fixes for ``set_checkbox()`` and ``set_radio()`` when the $default parameter is set to ``true`` -- fix for result object handling in Model class . -- fixed escape character SQLite database -- fix for inserts on Postgres and Entities when the primary key was null +- Image::save() bug fixed when ``$target`` parameter was ``null``. +- fixes for ``set_checkbox()`` and ``set_radio()`` when the $default parameter is set to ``true``. +- fix for result object handling in Model class. +- fixed escape character SQLite database. +- fix for inserts on Postgres and Entities when the primary key was null. - CLI scripts can now correctly recognize dashes within arguments. -- CURLRequest now properly sets content length with multipart data -- Misc. stability improvements for the ImageMagick handler -- setting validation errors within a config file should now work +- CURLRequest now properly sets content length with multipart data. +- Misc. stability improvements for the ImageMagick handler. +- setting validation errors within a config file should now work. - Unicode characters are not escaped when saving JSON from Entities. -- redirecting with a custom HTTP code should work correctly now -- ``Time::setTimezone()`` now working correctly -- added full outer join support for Postgres +- redirecting with a custom HTTP code should work correctly now. +- ``Time::setTimezone()`` now working correctly. +- added full outer join support for Postgres. - some cast items in the Entity (like array, json) were not being set correctly during a ``fill()`` process. -- Fixed bug in Image GD handler that would try to compress images twice in certain cases -- Ensure get translation output logic work on selected locale, dashed locale, and fallback "en" +- Fixed bug in Image GD handler that would try to compress images twice in certain cases. +- Ensure get translation output logic work on selected locale, dashed locale, and fallback "en". - Fix ``is_unique``/``is_not_unique`` validation called on POST/PUT via API in PostgreSQL. -- Fixed a bug where filter arguments were not passed to ``after()`` +- Fixed a bug where filter arguments were not passed to ``after()``. From ffce09727e91b6edbad10008f2ec477b9b22fe79 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 16 Jan 2023 14:41:09 +0900 Subject: [PATCH 025/290] docs: add PHPDoc types --- system/Router/RouteCollection.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 30be78a2bce5..b07f6cb83f54 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -527,6 +527,8 @@ public function getRoutes(?string $verb = null): array /** * Returns one or all routes options + * + * @return array [key => value] */ public function getRoutesOptions(?string $from = null, ?string $verb = null): array { @@ -1149,6 +1151,11 @@ public function getFilterForRoute(string $search, ?string $verb = null): string * 'role:admin,manager' * * has a filter of "role", with parameters of ['admin', 'manager']. + * + * @param string $search routeKey + * + * @return array filter_name or filter_name:arguments like 'role:admin,manager' + * @phpstan-return list */ public function getFiltersForRoute(string $search, ?string $verb = null): array { @@ -1520,6 +1527,15 @@ public function resetRoutes() /** * Load routes options based on verb + * + * @return array> [routeKey(or from) => [key => value]] + * @phpstan-return array< + * string, + * array{ + * filter?: string|list, namespace?: string, hostname?: string, + * subdomain?: string, offset?: int, priority?: int + * } + * > */ protected function loadRoutesOptions(?string $verb = null): array { From 945342c837b50bb101814abd5f05c2c34c66f77c Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 16 Jan 2023 17:53:24 +0900 Subject: [PATCH 026/290] refactor: add array_key_exists() check --- system/Router/RouteCollection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index b07f6cb83f54..dc6dd88b429b 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1161,7 +1161,7 @@ public function getFiltersForRoute(string $search, ?string $verb = null): array { $options = $this->loadRoutesOptions($verb); - if (! array_key_exists($search, $options)) { + if (! array_key_exists($search, $options) || ! array_key_exists('filter', $options[$search])) { return []; } @@ -1169,7 +1169,7 @@ public function getFiltersForRoute(string $search, ?string $verb = null): array return [$options[$search]['filter']]; } - return $options[$search]['filter'] ?? []; + return $options[$search]['filter']; } /** From a1ebd150f2b54a8d1801a0c709d2f9a65db762fe Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 16 Jan 2023 18:49:51 +0900 Subject: [PATCH 027/290] docs: add missing array keys --- system/Router/RouteCollection.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index dc6dd88b429b..e0b556c55929 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1533,7 +1533,8 @@ public function resetRoutes() * string, * array{ * filter?: string|list, namespace?: string, hostname?: string, - * subdomain?: string, offset?: int, priority?: int + * subdomain?: string, offset?: int, priority?: int, as?: string, + * redirect?: string * } * > */ From 991151cab26bd045eea3739b1275518fae6ea251 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 16 Jan 2023 21:12:43 +0900 Subject: [PATCH 028/290] docs: fix doc comments --- system/Router/RouteCollection.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index e0b556c55929..7dd87701a432 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -112,8 +112,9 @@ class RouteCollection implements RouteCollectionInterface * verb => [ * routeName => [ * 'route' => [ - * routeKey(or from) => handler, - * ] + * routeKey(regex) => handler, + * ], + * 'redirect' => statusCode, * ] * ], * ] @@ -138,7 +139,7 @@ class RouteCollection implements RouteCollectionInterface * * [ * verb => [ - * routeKey(or from) => [ + * routeKey(regex) => [ * key => value, * ] * ], From 62bdbee4be8ae8bb6034a8fb2eeccae6004f34bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jan 2023 15:15:49 +0000 Subject: [PATCH 029/290] chore(deps-dev): update rector/rector requirement from 0.15.5 to 0.15.7 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.5...0.15.7) --- 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 682e3f9c81c4..5f57c60f6781 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.5", + "rector/rector": "0.15.7", "vimeo/psalm": "^5.0" }, "suggest": { From df9c63ab4684e66d45104ea4677dbb940e405123 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 07:08:20 +0900 Subject: [PATCH 030/290] docs: add period --- user_guide_src/source/database/configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 836cd53ec92b..ec05c12991b1 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -125,7 +125,7 @@ Explanation of Values: **pConnect** true/false (boolean) - Whether to use a persistent connection. **DBDebug** true/false (boolean) - Whether to throw exceptions or not when database errors occur. **charset** The character set used in communicating with the database. -**DBCollat** The character collation used in communicating with the database (``MySQLi`` only) +**DBCollat** The character collation used in communicating with the database (``MySQLi`` only). **swapPre** A default table prefix that should be swapped with ``DBPrefix``. This is useful for distributed applications where you might run manually written queries, and need the prefix to still be customizable by the end user. From dd06ddb257d4d32dad5e1514926c0b5cb0ee2280 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 07:12:47 +0900 Subject: [PATCH 031/290] docs: add about FQCN --- system/Database/Database.php | 1 + user_guide_src/source/database/configuration.rst | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/system/Database/Database.php b/system/Database/Database.php index 58d2a22bad9a..df3ad9ae1550 100644 --- a/system/Database/Database.php +++ b/system/Database/Database.php @@ -123,6 +123,7 @@ protected function parseDSN(array $params): array /** * Initialize database driver. * + * @param string $driver Driver name. FQCN can be used. * @param array|object $argument * * @return BaseConnection|BaseUtils|Forge diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index ec05c12991b1..b5a768439ccc 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -118,7 +118,8 @@ Explanation of Values: **database** The name of the database you want to connect to. .. note:: CodeIgniter doesn't support dots (``.``) in the database, table, and column names. -**DBDriver** The database driver name. e.g.,: ``MySQLi``, ``Postgres``, etc. The case must match the driver name +**DBDriver** The database driver name. e.g.,: ``MySQLi``, ``Postgres``, etc. The case must match the driver name. + You can set a fully qualified classname to use your custom driver. **DBPrefix** An optional table prefix which will added to the table name when running :doc:`Query Builder ` queries. This permits multiple CodeIgniter installations to share one database. From 049a378a6059b88ab899ecaf55af83a4a4c6f93b Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 09:07:28 +0900 Subject: [PATCH 032/290] docs: add support for PHP 8.2 --- user_guide_src/source/changelogs/v4.2.11.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/user_guide_src/source/changelogs/v4.2.11.rst b/user_guide_src/source/changelogs/v4.2.11.rst index 98e66a8ad7a0..f32408787327 100644 --- a/user_guide_src/source/changelogs/v4.2.11.rst +++ b/user_guide_src/source/changelogs/v4.2.11.rst @@ -23,6 +23,11 @@ BREAKING :ref:`sessions-memcachedhandler-driver` and :ref:`sessions-redishandler-driver` has changed. See :ref:`Upgrading Guide `. +Enhancements +************ + +- Full support for PHP 8.2. + Bugs Fixed ********** From 8de71cf9189918b1b02c1adeaccbc04e3deccc4f Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 09:59:38 +0900 Subject: [PATCH 033/290] docs: add version in past CHANGELOGs --- changelogs/CHANGELOG_4.0.md | 2 +- changelogs/CHANGELOG_4.1.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelogs/CHANGELOG_4.0.md b/changelogs/CHANGELOG_4.0.md index 228eacaed594..ba2a9a85826d 100644 --- a/changelogs/CHANGELOG_4.0.md +++ b/changelogs/CHANGELOG_4.0.md @@ -1,4 +1,4 @@ -# Changelog +# Changelog 4.0 ## [v4.0.5](https://github.com/codeigniter4/CodeIgniter4/tree/v4.0.5) (2021-01-31) diff --git a/changelogs/CHANGELOG_4.1.md b/changelogs/CHANGELOG_4.1.md index 9cf4efa4cb80..0da26d272274 100644 --- a/changelogs/CHANGELOG_4.1.md +++ b/changelogs/CHANGELOG_4.1.md @@ -1,4 +1,4 @@ -# Changelog +# Changelog 4.1 ## [v4.1.9](https://github.com/codeigniter4/CodeIgniter4/tree/v4.1.9) (2022-02-25) From 995790296cd12d9d4da326f0d1663f8d89edd2a5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 10:01:49 +0900 Subject: [PATCH 034/290] docs: extract CHANGELOG_4.2 --- CHANGELOG.md | 422 +---------------------------------- changelogs/CHANGELOG_4.2.md | 423 ++++++++++++++++++++++++++++++++++++ 2 files changed, 424 insertions(+), 421 deletions(-) create mode 100644 changelogs/CHANGELOG_4.2.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 74b2f56755c3..ff34b8171aa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -125,424 +125,4 @@ * refactor: remove Workaround for Faker deprecation errors in PHP 8.2 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6987 * refactor: to fix psalm error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6999 -## [v4.2.12](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.12) (2023-01-09) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.11...v4.2.12) - -### Fixed Bugs -* docs: fix request.rst by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7014 -* fix: `link_tag()` missing `type="application/rss+xml"` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7022 -* fix: Request::getIPaddress() causes error on CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7030 -* docs: fix upgrade_database.rst by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7036 -* fix: `spark migrate:status` shows incorrect filename when format is `Y_m_d_His_` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7038 -* fix: Model::save() object when useAutoIncrement is disabled by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/7042 -* fix: define of STDOUT in CLI init() method by @jozefrebjak in https://github.com/codeigniter4/CodeIgniter4/pull/7052 -* fix: change `getFile()` function of \CodeIgniter\Events\Events to static. by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/7046 -* fix: [Email] add fallback to use gethostname() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7053 -* Fixing bug with legacy autoRoute when testing by @baycik in https://github.com/codeigniter4/CodeIgniter4/pull/7060 - -### Refactoring -* refactor: RequestTrait by rector by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7006 -* refactor: update sass output by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7026 - -## [v4.2.11](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.11) (2022-12-21) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.10...v4.2.11) - -### SECURITY -* *Attackers may spoof IP address when using proxy* was fixed. See the [Security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-ghw3-5qvm-3mqc) for more information. -* *Potential Session Handlers Vulnerability* was fixed. See the [Security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-6cq5-8cj7-g558) for more information. - -### Fixed Bugs -* fix: Request::getIPAddress() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6820 -* fix: Model cannot insert when $useAutoIncrement is false by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6827 -* fix: View Parser regexp does not support UTF-8 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6835 -* Handle key generation when key is not present in .env by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6839 -* Fix: Controller Test withBody() by @MGatner in https://github.com/codeigniter4/CodeIgniter4/pull/6843 -* fix: body assigned via options array in CURLRequest class by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6854 -* Fix CreateDatabase leaving altered database config in connection by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6856 -* fix: cast to string all values except arrays in Header class by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6862 -* add missing @method Query grouping in Model by @paul45 in https://github.com/codeigniter4/CodeIgniter4/pull/6874 -* fix: `composer update` might cause error "Failed to open directory" by @LeMyst in https://github.com/codeigniter4/CodeIgniter4/pull/6833 -* fix: required PHP extentions by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6897 -* fix: Use Services for the FeatureTestTrait request. by @lonnieezell in https://github.com/codeigniter4/CodeIgniter4/pull/6966 -* fix: FileLocator::locateFile() bug with a similar namespace name by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6964 -* fix: socket connection in RedisHandler class by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6972 -* fix: `spark namespaces` cannot show a namespace with mutilple paths by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6977 -* fix: Undefined constant "CodeIgniter\Debug\VENDORPATH" by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6985 -* fix: large HTTP input crashes framework by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6984 -* fix: empty paths for `rewrite.php` by @datamweb in https://github.com/codeigniter4/CodeIgniter4/pull/6991 -* fix: `PHPStan` $cols not defined in `CLI` by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/6994 -* Fix MigrationRunnerTest for Windows by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6855 -* fix: turn off `Xdebug` note when running phpstan by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/6851 -* Fix ShowTableInfoTest to pass on Windows by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6853 -* Fix MigrateStatusTest for Windows by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6866 -* Fix ShowTableInfoTest when migration records are numerous by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6868 -* Fix CreateDatabaseTest to not leave database by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6867 -* Fix coverage merge warning by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6885 -* fix: replace tabs to spaces by @zl59503020 in https://github.com/codeigniter4/CodeIgniter4/pull/6898 -* fix: slack links by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6907 -* Fix typo in database/queries.rst by @philFernandez in https://github.com/codeigniter4/CodeIgniter4/pull/6920 -* Fix testInsertWithSetAndEscape to make not time dependent by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6974 -* fix: remove unnecessary global variables in rewrite.php by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6973 - -## [v4.2.10](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.10) (2022-11-05) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.9...v4.2.10) - -### Fixed Bugs -* docs: fix PHPDoc types in Session by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6796 -* fix: output "0" at the end of toolbar js when Kint::$enabled_mode is false by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6809 - -### Refactoring -* Refactor assertHeaderEmitted and assertHeaderNotEmitted by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6806 -* fix: variable types for PHPStan 1.9.0 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6810 - -## [v4.2.9](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.9) (2022-10-30) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.8...v4.2.9) - -**Hotfix release to fix PHPUnit errors (see https://github.com/codeigniter4/CodeIgniter4/pull/6794)** - -## [v4.2.8](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.8) (2022-10-30) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.7...v4.2.8) - -### Fixed Bugs -* Fix DotEnv class turning `export` to empty string by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6625 -* Remove unneeded `$logger` property in `Session` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6647 -* fix: Add missing CLIRequest::getCookie() by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6646 -* fix: routes registration bug by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6644 -* Bug: showError in CLI/BaseCommand use hardcoded error view path by @fpoy in https://github.com/codeigniter4/CodeIgniter4/pull/6657 -* fix: getGetPost() and getPostGet() when index is null by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6675 -* fix: add missing methods to BaseConnection by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6712 -* fix: bug that esc() accepts invalid context '0' by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6722 -* fix: [Postgres] reset binds when replace() method is called multiple times in the context by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6728 -* fix: [SQLSRV] _getResult() return object for preparedQuery class by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6718 -* Fix error handler callback by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6724 -* bug: Supply mixin for TestResponse by @MGatner in https://github.com/codeigniter4/CodeIgniter4/pull/6756 -* fix: CodeIgniter::run() doesn't respect $returnResponse by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6737 -* Bug: ResponseTest::testSetLastModifiedWithDateTimeObject depends on time by @fpoy in https://github.com/codeigniter4/CodeIgniter4/pull/6683 -* fix: workaround for Faker deprecation errors in PHP 8.2 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6758 -* Add .gitattributes to framework by @totoprayogo1916 in https://github.com/codeigniter4/CodeIgniter4/pull/6774 -* Delete admin/module directory by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6775 - -## [v4.2.7](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.7) (2022-10-06) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.6...v4.2.7) - -### SECURITY -* *Secure or HttpOnly flag set in Config\Cookie is not reflected in Cookies issued* was fixed. See the [Security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-745p-r637-7vvp) for more information. - -### Breaking Changes -* fix: make Time::__toString() database-compatible on any locale by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6461 -* fix: set_cookie() does not use Config\Cookie values by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6544 -* fix: `required_without` rule logic in `Validation` class. by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/6589 - -### Fixed Bugs -* fix: typos in messages in Language/en/Email.php by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6517 -* fix: table attribute cannot applied on td element by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/6538 -* add: set up "script_name" to handle every request by index.php file. by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/6522 -* fix: CSP autoNonce = false by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6570 -* fix: inconsistent new line view in `date_helper` by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/6582 -* fix: safe_mailto() does not work with CSP by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6604 -* fix: script_tag() does not work with CSP by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6611 -* fix: `$cleanValidationRules` does not work in Model updates by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6588 -* Fixed a bug that URLs with trailing newlines do not become invalid in validation. by @ytetsuro in https://github.com/codeigniter4/CodeIgniter4/pull/6618 -* fix: missing `valid_json` in Validation Language by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/6624 -* fix: default values for Session Redis Handler by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6614 - -### Enhancements -* Update coding-standards version by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6537 -* chore: update ThirdParty Kint to 4.2.2 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6583 - -### Refactoring -* Refactor: CodeIgniter::generateCacheName() by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6498 -* refactor: replace `global $app` with Services by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/6524 -* refactor: small refactoring in view() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6546 -* refactor: replace utf8_encode() with mb_convert_encoding() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6564 -* refactor: make $precision int in View Filter round by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6566 - -## [v4.2.6](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.6) (2022-09-04) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.5...v4.2.6) - -### Fixed Bugs -* fix: AssertionError occurs when using Validation in CLI by @daycry in https://github.com/codeigniter4/CodeIgniter4/pull/6452 -* fix: [Validation] JSON data may cause "Array to string conversion" error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6467 -* Fix fatal error gets turned to `0` severity on shutdown handler by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6472 -* Fix redis cache increment/decrement methods by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6473 -* Fix broken caching system when array of allowed parameters used by @JavaDeveloperKiev in https://github.com/codeigniter4/CodeIgniter4/pull/6475 -* fix: Strict Validation Rules greater_than/less_than by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6492 - -### Refactoring -* refactor: fix PHPStan errors by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6470 -* Bump `friendsofphp/php-cs-fixer` to `~3.11.0` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6471 -* Fix overlooked coding style violations by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6491 - -## [v4.2.5](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.5) (2022-08-28) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.4...v4.2.5) - -### Breaking Changes -* Add $cached param to BaseConnection::tableExists() by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6364 -* Fix validation custom error asterisk field by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/6378 - -### Fixed Bugs -* fix: Email class may not log an error when it fails to send by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6362 -* fix: Response::download() causes TypeError by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6361 -* fix: command usages by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6402 -* Fix: The subquery adds a prefix for the table alias. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6390 -* Fix Sqlite Table::createTable() by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6396 -* docs: add missing `@method` `groupBy()` in Model by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6433 -* fix: CLIRequest Erros in CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6421 -* fix: Call to undefined method CodeIgniter\HTTP\CLIRequest::getLocale() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6442 - -### Enhancements -* chore: update Kint to 4.2.0 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6436 - -### Refactoring -* refactor: add test for DownloadResponse by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6375 -* refactor: ValidationTest by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6382 -* refactor: remove unused `_parent_name` in BaseBuilder::objectToArray() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6427 -* Remove unneeded abstract `handle()` method by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6434 - -## [v4.2.4](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.4) (2022-08-13) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.3...v4.2.4) - -**Hotfix release to fix download errors (see https://github.com/codeigniter4/CodeIgniter4/pull/6361)** - -## [v4.2.3](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.3) (2022-08-06) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.2...v4.2.3) - -* SECURITY: Improve CSRF protection (for Shield CSRF security fix) - -## [v4.2.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.2) (2022-08-05) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.1...v4.2.2) - -### Breaking Changes -* fix: when running on CLI, two Request objects were used in the system by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6089 -* fix: Builder insert()/update() does not accept an object by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6216 -* fix: create table if not exists when indexes already exist by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6249 -* fix: page cache saves Response data before running after filters by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6282 -* fix: random_string('crypto') may return string less than $len or ErrorException by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6334 - -### Fixed Bugs -* Fixed: BaseBuilder increment/decrement do not reset state after a query by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6146 -* fix: SQLite3\Connection\getIndexData() error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6152 -* fix: `is_image` causes PHP 8.1 deprecated error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6157 -* fix: prepared query is executed when using QueryBuilder by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6164 -* fix: Time::getAge() calculation by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6159 -* fix: Session cookies are sent twice with Ajax by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6167 -* fix: QueryBuilder breaks select when escape is false by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5118 -* fix: PHPDoc return type in ControllerTestTrait methods by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6168 -* fix: `$routes->group('/', ...)` creates the route `foo///bar` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6186 -* fix: use lang('HTTP.pageNotFound') on production 404 page by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6202 -* fix: BaseConnection may create dynamic property by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6198 -* fix: Email SMTP may throw Uncaught ErrorException by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6184 -* fix: CSP reportOnly behavior by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6201 -* fix: lang() causes Error on CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6209 -* fix: multiple pagers with models do not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6211 -* fix: tweak empty line output of `spark db:table` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6215 -* fix: custom validation error is cleared when calling setRule() twice by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6241 -* Fix: Validation of fields with a leading asterisk. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6243 -* fix: Call to undefined method CodeIgniter\Pager\PagerRenderer::getDetails() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6251 -* fix: exceptionHandler may cause HTTPException: Unknown HTTP status code by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6254 -* fix: invalid INSERT/DELETE query when Query Builder uses table alias by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5376 -* fix: Add db port entry into env file. by @nalakapws in https://github.com/codeigniter4/CodeIgniter4/pull/6250 -* fix: update `.gitattributes` by @totoprayogo1916 in https://github.com/codeigniter4/CodeIgniter4/pull/6256 -* fix: format_number() can't be used on CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6263 -* fix: add parameter checking for max_size by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6261 -* fix: route name is not displayed in Exception message by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6269 -* fix: `spark routes` shows 404 error when using regex by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6279 -* fix: Entity::hasChanged() returns wrong result to mapped property by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6285 -* fix: unable to add more than one file to FileCollection constructor by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6291 -* fix: Security::derandomize() may cause hex2bin() error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6292 -* fix: use getenv() instead of $_SERVER in detectEnvironment() by @fcosrno in https://github.com/codeigniter4/CodeIgniter4/pull/6257 -* fix: OCI8 uses deprecated Entity by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6323 -* fix: Parse error occurs before PHP version check by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6327 -* fix: 404 page might display Exception message in production environment by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6333 - -### Refactoring -* refactor: replace $e->getMessage() with $e in log_message() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6182 -* refactor: add CompleteDynamicPropertiesRector by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6187 -* refactor: debug toolbar by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6272 -* refactor: Exception exit code by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6286 -* chore: Remove Vagrant by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6314 -* refactor: CSRF protection by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6320 - -## [v4.2.1](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.1) (2022-06-16) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.0...v4.2.1) - -### Breaking Changes -* Fix MIME guessing of extension from type by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6059 -* fix: get_cookie() may not use the cookie prefix by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6082 - -### Fixed Bugs -* fix: get_cookie() does not take Config\Cookie::$prefix by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6080 -* fix: session cookie name bug by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6091 -* fix: Session Handlers do not take Config\Cookie by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6081 -* fix: reverse routing does not work with full classname starting with `\` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6104 -* fix: insert error message in QueryBuilder by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6108 -* fix: `spark routes` shows "ERROR: 404" by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6098 -* fix: Time::setTestNow() does not work with fa Locale by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6116 -* fix: `migrate --all` causes `Class "SQLite3" not found` error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6117 -* fix: event DBQuery is not fired on failed query when DBDebug is true by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6127 -* fix: `Time::humanize()` causes error with ar locale by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6120 -* Fix decorators by @lonnieezell in https://github.com/codeigniter4/CodeIgniter4/pull/6090 -* Fix lost error message by test when after testInsertResultFail. by @ytetsuro in https://github.com/codeigniter4/CodeIgniter4/pull/6113 -* test: fix forgetting to restore DBDebug value by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6115 - -### Refactoring -* Apply AutoRouterImproved::translateURIDashes() by @pjsde in https://github.com/codeigniter4/CodeIgniter4/pull/6084 -* Remove useless catch by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6095 -* Move preload.php example to starter app by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/6088 -* style: compile sass by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6099 - -## [v4.2.0](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.0) (2022-06-03) -[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.1.9...v4.2.0) - -### Breaking Changes -* Validation: support placeholders for anything by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5545 -* Fix: Validation. Error key for field with asterisk by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5609 -* Improve exception logging by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5684 -* fix: spark can't use options on PHP 7.4 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5836 -* fix: [Autoloader] Composer classmap usage by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5850 -* fix: using multiple CLI::color() in CLI::write() outputs strings with wrong color by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5893 -* refactor: [Router] extract a class for auto-routing by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5877 -* feat: Debugbar request microtime by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5958 -* refactor: `system/bootstrap.php` only loads files and registers autoloader by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5972 -* fix: `dot_array_search()` unexpected behavior by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5940 -* feat: QueryBuilder join() raw SQL string support by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5875 -* fix: change BaseService::reset() $initAutoloader to true by default by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6020 - -### Fixed Bugs -* chore: update admin/framework/composer.json Kint by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5531 -* fix: BaseConnection::getConnectDuration() number_format(): Passing null to parameter by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5536 -* Fix: Debug toolbar selectors by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5544 -* Fix: Toolbar. ciDebugBar.showTab() context. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5554 -* Refactor Database Collector display by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5553 -* fix: add missing Migration lang item by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5557 -* feat: add Validation Strict Rules by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5445 -* fix: `Time::createFromTimestamp()` sets incorrect time when specifying timezone by @totoprayogo1916 in https://github.com/codeigniter4/CodeIgniter4/pull/5588 -* fix: Entity's isset() and unset() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5497 -* Fix: Deletion timestamp of the Model is updated when a record that has been soft-deleted is deleted again by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5578 -* Fix: Added alias escaping in subquery by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5601 -* fix: spark migrate:status does not show status with different namespaces by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5605 -* BaseService - Use lowercase key in resetSingle by @najdanovicivan in https://github.com/codeigniter4/CodeIgniter4/pull/5596 -* Fix `array_flatten_with_dots` ignores empty array values by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5606 -* fix: debug toolbar Routes Params output by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5619 -* fix: DownloadResponse memory leak by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5623 -* fix: spark does not show Exception by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5638 -* fix: Config CSRF $redirect does not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5665 -* fix: do not call header() if headers have already been sent by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5680 -* fix: $routes->setDefaultMethod() does not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5682 -* fix: debug toolbar vars response headers includes request headers by @zl59503020 in https://github.com/codeigniter4/CodeIgniter4/pull/5701 -* fix: 404 override controller does not output Response object body by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5703 -* fix: auto routes incorrectly display route filters with GET method by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5712 -* fix: Model::paginate() missing argument $group by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5699 -* Fix options are not passed to Command $params by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5206 -* fix: forceGlobalSecureRequests break URI schemes other than HTTP by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5730 -* fix: TypeError when `$tokenRandomize = true` and no token posted by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5742 -* fix: $builder->ignore()->insertBatch() only ignores on first iteration by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5672 -* fix: app/Config/Routes.php is loaded twice on Windows by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5780 -* fix: table name is double prefixed when LIKE clause by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5778 -* fix: Publisher $restrictions regex to FCPATH by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5793 -* fix: Timer::getElapsedTime() returns incorrect value by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5798 -* bug: Publisher $restrictions regex typo by @MGatner in https://github.com/codeigniter4/CodeIgniter4/pull/5800 -* fix: [Validation] valid_date ErrorException when the field is not sent by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5804 -* fix: [Pager] can't get correct current page from segment by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5803 -* fix: bug that allows dynamic controllers to be used by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5814 -* config: remove App\ and Config\ in autoload.psr-4 in app starter composer.json by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5824 -* fix: failover's DBPrefix not working by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5816 -* fix: Validation returns incorrect errors after Redirect with Input by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5844 -* feat: [Parser] add configs to change conditional delimiters by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5842 -* fix: Commands::discoverCommands() loads incorrect classname by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5849 -* fix: Publisher::discover() loads incorrect classname by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5858 -* fix: validation errors in Model are not cleared when running validation again by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5861 -* fix: Parser fails with `({variable})` in loop by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5840 -* fix: [BaseConfig] string value is set from environment variable even if it should be int/float by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5779 -* fix: add Escaper Exception classes in $coreClassmap by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5891 -* fix: Composer PSR-4 overwrites Config\Autoload::$psr4 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5902 -* fix: Reverse Routing does not take into account the default namespace by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5936 -* fix: [Validation] Fields with an asterisk throws exception by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5938 -* fix: GDHandler::convert() does not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5969 -* fix: Images\Handlers\GDHandler Implicit conversion from float to int loses precision by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5965 -* fix: GDHandler::save() removes transparency by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5971 -* fix: route limit to subdomains does not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5961 -* fix: Model::_call() static analysis by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5970 -* fix: invalid css in error_404.php by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5978 -* Fix: Route placeholder (:any) with {locale} by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6003 -* Changing the subquery builder for the Oracle by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5999 -* fix: CURLRequest request body is not reset on the next request by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6014 -* Bug: The SQLSRV driver ignores the port value from the config. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6036 -* fix: `set_radio()` not working as expected by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6037 -* fix: add config for SQLite3 Foreign Keys by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6050 -* fix: Ignore non-HTML responses in storePreviousURL by @tearoom6 in https://github.com/codeigniter4/CodeIgniter4/pull/6012 -* fix: SQLite3\Table::copyData() does not escape column names by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6055 -* Fix `slash_item()` erroring when property fetched does not exist on `Config\App` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6058 - -### New Features -* Feature Add Oracle driver by @ytetsuro in https://github.com/codeigniter4/CodeIgniter4/pull/2487 -* feat: new improved auto router by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5889 -* feat: new improved auto router `spark routes` command by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5953 -* feat: `db:table` command by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5979 - -### Enhancements -* feat: CSP enhancements by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5516 -* Feature: Subqueries in the FROM section by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5510 -* Added new View Decorators. by @lonnieezell in https://github.com/codeigniter4/CodeIgniter4/pull/5567 -* feat: auto routes listing by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5590 -* Feature: "spark routes" command shows routes with closure. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5651 -* feat: `spark routes` shows filters by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5628 -* Allow calling getQuery() multiple times, and other improvements by @vlakoff in https://github.com/codeigniter4/CodeIgniter4/pull/5127 -* feat: add Controller::validateData() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5639 -* feat: can add route handler as callable by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5713 -* Checking if the subquery uses the same object as the main query by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5743 -* Feature: Subquery for SELECT by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5736 -* Extend Validation from BaseConfig so Registrars can add rules. by @lonnieezell in https://github.com/codeigniter4/CodeIgniter4/pull/5789 -* config: add mime type for webp by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5838 -* feat: add `$includeDir` option to `get_filenames()` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5862 -* feat: throws exception when controller name in routes contains `/` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5885 -* [PHPStan] Prepare for PHPStan 1.6.x-dev by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/5876 -* [Rector] Add back SimplifyUselessVariableRector by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/5911 -* Redirecting Routes. Placeholders. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5916 -* script_tag(): cosmetic for value-less attributes by @xlii-chl in https://github.com/codeigniter4/CodeIgniter4/pull/5884 -* feat: QueryBuilder raw SQL string support by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5817 -* improve Router Exception message by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5984 -* feat: DBForge::addField() `default` value raw SQL string support by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5957 -* Add sample file for preloading by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5974 -* Feature. QueryBuilder. Query union. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6015 -* feat: `getFieldData()` returns nullable data on PostgreSQL by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5981 - -### Refactoring -* refactor: add Factories::models() to suppress PHPStan error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5358 -* Fixed style for PHP7.4 by @ytetsuro in https://github.com/codeigniter4/CodeIgniter4/pull/5581 -* Fix Autoloader::initialize() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5592 -* refactor: CURLRequest and the slow tests by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5593 -* Refactor `if_exist` validation with dot notation by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5607 -* refactor: small changes in Filters and Router by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5627 -* refactor: replace deprecated `getFilterForRoute()` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5624 -* refactor: make BaseController abstract by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5647 -* refactor: move logic to prevent access to initController by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5648 -* refactor: remove migrations routes by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5652 -* refactor: update Kint CSP nonce by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5657 -* Deprecate object implementations of `clean_path()` function by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5681 -* refactor: Session does not use cookies() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5656 -* refactor: replace deprecated Response::getReason() with getReasonPhrase() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5700 -* refactor: isCLI() in CLIRequest and IncomingRequest by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5653 -* refactor: CodeIgniter has context by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5650 -* Forge use statement by @mostafakhudair in https://github.com/codeigniter4/CodeIgniter4/pull/5729 -* refactor: remove `&` before $db by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5726 -* refactor: remove unneeded `&` references in ContentSecurityPolicy.php by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5734 -* Nonce replacement optimization. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5733 -* [Rector] Clean up skip config and re-run Rector by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/5813 -* refactor: DB Session Handler by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5696 -* Rename `Abstact` to `Abstract` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5833 -* refactor: extract RedirectResponse::withErrors() method by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5860 -* Optimizing the RouteCollection::getRoutes() method by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5918 -* refactor: add strtolower() to Request::getMethod() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5963 -* refactor: remove `$_SERVER['HTTP_HOST']` in RouteCollection by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5962 -* refactor: deprecate const `EVENT_PRIORITY_*` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6000 -* fix: replace EVENT_PRIORITY_NORMAL with Events::PRIORITY_NORMAL by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6005 -* Router class optimization. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6004 -* Prefer `is_file()` by @MGatner in https://github.com/codeigniter4/CodeIgniter4/pull/6025 -* refactor: use get_filenames() 4th param in FileLocator by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6026 -* refactor: use get_filenames() 4th param by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6031 -* refactor: CodeIgniter $context check by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6047 -* Small change to improve code reading by @valmorflores in https://github.com/codeigniter4/CodeIgniter4/pull/6051 -* refactor: remove `CodeIgniter\Services` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6053 - -See [CHANGELOG_4.1.md](./changelogs/CHANGELOG_4.1.md) +See [CHANGELOG_4.2.md](./changelogs/CHANGELOG_4.2.md) diff --git a/changelogs/CHANGELOG_4.2.md b/changelogs/CHANGELOG_4.2.md new file mode 100644 index 000000000000..e472b4b87883 --- /dev/null +++ b/changelogs/CHANGELOG_4.2.md @@ -0,0 +1,423 @@ +# Changelog 4.2 + +## [v4.2.12](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.12) (2023-01-09) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.11...v4.2.12) + +### Fixed Bugs +* docs: fix request.rst by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7014 +* fix: `link_tag()` missing `type="application/rss+xml"` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7022 +* fix: Request::getIPaddress() causes error on CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7030 +* docs: fix upgrade_database.rst by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7036 +* fix: `spark migrate:status` shows incorrect filename when format is `Y_m_d_His_` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7038 +* fix: Model::save() object when useAutoIncrement is disabled by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/7042 +* fix: define of STDOUT in CLI init() method by @jozefrebjak in https://github.com/codeigniter4/CodeIgniter4/pull/7052 +* fix: change `getFile()` function of \CodeIgniter\Events\Events to static. by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/7046 +* fix: [Email] add fallback to use gethostname() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7053 +* Fixing bug with legacy autoRoute when testing by @baycik in https://github.com/codeigniter4/CodeIgniter4/pull/7060 + +### Refactoring +* refactor: RequestTrait by rector by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7006 +* refactor: update sass output by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7026 + +## [v4.2.11](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.11) (2022-12-21) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.10...v4.2.11) + +### SECURITY +* *Attackers may spoof IP address when using proxy* was fixed. See the [Security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-ghw3-5qvm-3mqc) for more information. +* *Potential Session Handlers Vulnerability* was fixed. See the [Security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-6cq5-8cj7-g558) for more information. + +### Fixed Bugs +* fix: Request::getIPAddress() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6820 +* fix: Model cannot insert when $useAutoIncrement is false by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6827 +* fix: View Parser regexp does not support UTF-8 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6835 +* Handle key generation when key is not present in .env by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6839 +* Fix: Controller Test withBody() by @MGatner in https://github.com/codeigniter4/CodeIgniter4/pull/6843 +* fix: body assigned via options array in CURLRequest class by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6854 +* Fix CreateDatabase leaving altered database config in connection by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6856 +* fix: cast to string all values except arrays in Header class by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6862 +* add missing @method Query grouping in Model by @paul45 in https://github.com/codeigniter4/CodeIgniter4/pull/6874 +* fix: `composer update` might cause error "Failed to open directory" by @LeMyst in https://github.com/codeigniter4/CodeIgniter4/pull/6833 +* fix: required PHP extentions by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6897 +* fix: Use Services for the FeatureTestTrait request. by @lonnieezell in https://github.com/codeigniter4/CodeIgniter4/pull/6966 +* fix: FileLocator::locateFile() bug with a similar namespace name by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6964 +* fix: socket connection in RedisHandler class by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6972 +* fix: `spark namespaces` cannot show a namespace with mutilple paths by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6977 +* fix: Undefined constant "CodeIgniter\Debug\VENDORPATH" by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6985 +* fix: large HTTP input crashes framework by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6984 +* fix: empty paths for `rewrite.php` by @datamweb in https://github.com/codeigniter4/CodeIgniter4/pull/6991 +* fix: `PHPStan` $cols not defined in `CLI` by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/6994 +* Fix MigrationRunnerTest for Windows by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6855 +* fix: turn off `Xdebug` note when running phpstan by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/6851 +* Fix ShowTableInfoTest to pass on Windows by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6853 +* Fix MigrateStatusTest for Windows by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6866 +* Fix ShowTableInfoTest when migration records are numerous by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6868 +* Fix CreateDatabaseTest to not leave database by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6867 +* Fix coverage merge warning by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6885 +* fix: replace tabs to spaces by @zl59503020 in https://github.com/codeigniter4/CodeIgniter4/pull/6898 +* fix: slack links by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6907 +* Fix typo in database/queries.rst by @philFernandez in https://github.com/codeigniter4/CodeIgniter4/pull/6920 +* Fix testInsertWithSetAndEscape to make not time dependent by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6974 +* fix: remove unnecessary global variables in rewrite.php by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6973 + +## [v4.2.10](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.10) (2022-11-05) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.9...v4.2.10) + +### Fixed Bugs +* docs: fix PHPDoc types in Session by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6796 +* fix: output "0" at the end of toolbar js when Kint::$enabled_mode is false by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6809 + +### Refactoring +* Refactor assertHeaderEmitted and assertHeaderNotEmitted by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6806 +* fix: variable types for PHPStan 1.9.0 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6810 + +## [v4.2.9](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.9) (2022-10-30) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.8...v4.2.9) + +**Hotfix release to fix PHPUnit errors (see https://github.com/codeigniter4/CodeIgniter4/pull/6794)** + +## [v4.2.8](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.8) (2022-10-30) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.7...v4.2.8) + +### Fixed Bugs +* Fix DotEnv class turning `export` to empty string by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6625 +* Remove unneeded `$logger` property in `Session` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6647 +* fix: Add missing CLIRequest::getCookie() by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6646 +* fix: routes registration bug by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6644 +* Bug: showError in CLI/BaseCommand use hardcoded error view path by @fpoy in https://github.com/codeigniter4/CodeIgniter4/pull/6657 +* fix: getGetPost() and getPostGet() when index is null by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6675 +* fix: add missing methods to BaseConnection by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6712 +* fix: bug that esc() accepts invalid context '0' by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6722 +* fix: [Postgres] reset binds when replace() method is called multiple times in the context by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6728 +* fix: [SQLSRV] _getResult() return object for preparedQuery class by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/6718 +* Fix error handler callback by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6724 +* bug: Supply mixin for TestResponse by @MGatner in https://github.com/codeigniter4/CodeIgniter4/pull/6756 +* fix: CodeIgniter::run() doesn't respect $returnResponse by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6737 +* Bug: ResponseTest::testSetLastModifiedWithDateTimeObject depends on time by @fpoy in https://github.com/codeigniter4/CodeIgniter4/pull/6683 +* fix: workaround for Faker deprecation errors in PHP 8.2 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6758 +* Add .gitattributes to framework by @totoprayogo1916 in https://github.com/codeigniter4/CodeIgniter4/pull/6774 +* Delete admin/module directory by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6775 + +## [v4.2.7](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.7) (2022-10-06) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.6...v4.2.7) + +### SECURITY +* *Secure or HttpOnly flag set in Config\Cookie is not reflected in Cookies issued* was fixed. See the [Security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-745p-r637-7vvp) for more information. + +### Breaking Changes +* fix: make Time::__toString() database-compatible on any locale by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6461 +* fix: set_cookie() does not use Config\Cookie values by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6544 +* fix: `required_without` rule logic in `Validation` class. by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/6589 + +### Fixed Bugs +* fix: typos in messages in Language/en/Email.php by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6517 +* fix: table attribute cannot applied on td element by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/6538 +* add: set up "script_name" to handle every request by index.php file. by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/6522 +* fix: CSP autoNonce = false by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6570 +* fix: inconsistent new line view in `date_helper` by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/6582 +* fix: safe_mailto() does not work with CSP by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6604 +* fix: script_tag() does not work with CSP by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6611 +* fix: `$cleanValidationRules` does not work in Model updates by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6588 +* Fixed a bug that URLs with trailing newlines do not become invalid in validation. by @ytetsuro in https://github.com/codeigniter4/CodeIgniter4/pull/6618 +* fix: missing `valid_json` in Validation Language by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/6624 +* fix: default values for Session Redis Handler by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6614 + +### Enhancements +* Update coding-standards version by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6537 +* chore: update ThirdParty Kint to 4.2.2 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6583 + +### Refactoring +* Refactor: CodeIgniter::generateCacheName() by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6498 +* refactor: replace `global $app` with Services by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/6524 +* refactor: small refactoring in view() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6546 +* refactor: replace utf8_encode() with mb_convert_encoding() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6564 +* refactor: make $precision int in View Filter round by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6566 + +## [v4.2.6](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.6) (2022-09-04) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.5...v4.2.6) + +### Fixed Bugs +* fix: AssertionError occurs when using Validation in CLI by @daycry in https://github.com/codeigniter4/CodeIgniter4/pull/6452 +* fix: [Validation] JSON data may cause "Array to string conversion" error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6467 +* Fix fatal error gets turned to `0` severity on shutdown handler by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6472 +* Fix redis cache increment/decrement methods by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6473 +* Fix broken caching system when array of allowed parameters used by @JavaDeveloperKiev in https://github.com/codeigniter4/CodeIgniter4/pull/6475 +* fix: Strict Validation Rules greater_than/less_than by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6492 + +### Refactoring +* refactor: fix PHPStan errors by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6470 +* Bump `friendsofphp/php-cs-fixer` to `~3.11.0` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6471 +* Fix overlooked coding style violations by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6491 + +## [v4.2.5](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.5) (2022-08-28) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.4...v4.2.5) + +### Breaking Changes +* Add $cached param to BaseConnection::tableExists() by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6364 +* Fix validation custom error asterisk field by @ping-yee in https://github.com/codeigniter4/CodeIgniter4/pull/6378 + +### Fixed Bugs +* fix: Email class may not log an error when it fails to send by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6362 +* fix: Response::download() causes TypeError by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6361 +* fix: command usages by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6402 +* Fix: The subquery adds a prefix for the table alias. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6390 +* Fix Sqlite Table::createTable() by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6396 +* docs: add missing `@method` `groupBy()` in Model by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6433 +* fix: CLIRequest Erros in CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6421 +* fix: Call to undefined method CodeIgniter\HTTP\CLIRequest::getLocale() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6442 + +### Enhancements +* chore: update Kint to 4.2.0 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6436 + +### Refactoring +* refactor: add test for DownloadResponse by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6375 +* refactor: ValidationTest by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6382 +* refactor: remove unused `_parent_name` in BaseBuilder::objectToArray() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6427 +* Remove unneeded abstract `handle()` method by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6434 + +## [v4.2.4](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.4) (2022-08-13) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.3...v4.2.4) + +**Hotfix release to fix download errors (see https://github.com/codeigniter4/CodeIgniter4/pull/6361)** + +## [v4.2.3](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.3) (2022-08-06) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.2...v4.2.3) + +* SECURITY: Improve CSRF protection (for Shield CSRF security fix) + +## [v4.2.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.2) (2022-08-05) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.1...v4.2.2) + +### Breaking Changes +* fix: when running on CLI, two Request objects were used in the system by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6089 +* fix: Builder insert()/update() does not accept an object by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6216 +* fix: create table if not exists when indexes already exist by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/6249 +* fix: page cache saves Response data before running after filters by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6282 +* fix: random_string('crypto') may return string less than $len or ErrorException by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6334 + +### Fixed Bugs +* Fixed: BaseBuilder increment/decrement do not reset state after a query by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6146 +* fix: SQLite3\Connection\getIndexData() error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6152 +* fix: `is_image` causes PHP 8.1 deprecated error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6157 +* fix: prepared query is executed when using QueryBuilder by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6164 +* fix: Time::getAge() calculation by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6159 +* fix: Session cookies are sent twice with Ajax by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6167 +* fix: QueryBuilder breaks select when escape is false by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5118 +* fix: PHPDoc return type in ControllerTestTrait methods by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6168 +* fix: `$routes->group('/', ...)` creates the route `foo///bar` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6186 +* fix: use lang('HTTP.pageNotFound') on production 404 page by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6202 +* fix: BaseConnection may create dynamic property by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6198 +* fix: Email SMTP may throw Uncaught ErrorException by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6184 +* fix: CSP reportOnly behavior by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6201 +* fix: lang() causes Error on CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6209 +* fix: multiple pagers with models do not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6211 +* fix: tweak empty line output of `spark db:table` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6215 +* fix: custom validation error is cleared when calling setRule() twice by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6241 +* Fix: Validation of fields with a leading asterisk. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6243 +* fix: Call to undefined method CodeIgniter\Pager\PagerRenderer::getDetails() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6251 +* fix: exceptionHandler may cause HTTPException: Unknown HTTP status code by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6254 +* fix: invalid INSERT/DELETE query when Query Builder uses table alias by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5376 +* fix: Add db port entry into env file. by @nalakapws in https://github.com/codeigniter4/CodeIgniter4/pull/6250 +* fix: update `.gitattributes` by @totoprayogo1916 in https://github.com/codeigniter4/CodeIgniter4/pull/6256 +* fix: format_number() can't be used on CLI by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6263 +* fix: add parameter checking for max_size by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6261 +* fix: route name is not displayed in Exception message by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6269 +* fix: `spark routes` shows 404 error when using regex by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6279 +* fix: Entity::hasChanged() returns wrong result to mapped property by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6285 +* fix: unable to add more than one file to FileCollection constructor by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6291 +* fix: Security::derandomize() may cause hex2bin() error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6292 +* fix: use getenv() instead of $_SERVER in detectEnvironment() by @fcosrno in https://github.com/codeigniter4/CodeIgniter4/pull/6257 +* fix: OCI8 uses deprecated Entity by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6323 +* fix: Parse error occurs before PHP version check by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6327 +* fix: 404 page might display Exception message in production environment by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6333 + +### Refactoring +* refactor: replace $e->getMessage() with $e in log_message() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6182 +* refactor: add CompleteDynamicPropertiesRector by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6187 +* refactor: debug toolbar by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6272 +* refactor: Exception exit code by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6286 +* chore: Remove Vagrant by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6314 +* refactor: CSRF protection by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6320 + +## [v4.2.1](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.1) (2022-06-16) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.2.0...v4.2.1) + +### Breaking Changes +* Fix MIME guessing of extension from type by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6059 +* fix: get_cookie() may not use the cookie prefix by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6082 + +### Fixed Bugs +* fix: get_cookie() does not take Config\Cookie::$prefix by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6080 +* fix: session cookie name bug by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6091 +* fix: Session Handlers do not take Config\Cookie by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6081 +* fix: reverse routing does not work with full classname starting with `\` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6104 +* fix: insert error message in QueryBuilder by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6108 +* fix: `spark routes` shows "ERROR: 404" by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6098 +* fix: Time::setTestNow() does not work with fa Locale by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6116 +* fix: `migrate --all` causes `Class "SQLite3" not found` error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6117 +* fix: event DBQuery is not fired on failed query when DBDebug is true by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6127 +* fix: `Time::humanize()` causes error with ar locale by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6120 +* Fix decorators by @lonnieezell in https://github.com/codeigniter4/CodeIgniter4/pull/6090 +* Fix lost error message by test when after testInsertResultFail. by @ytetsuro in https://github.com/codeigniter4/CodeIgniter4/pull/6113 +* test: fix forgetting to restore DBDebug value by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6115 + +### Refactoring +* Apply AutoRouterImproved::translateURIDashes() by @pjsde in https://github.com/codeigniter4/CodeIgniter4/pull/6084 +* Remove useless catch by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6095 +* Move preload.php example to starter app by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/6088 +* style: compile sass by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6099 + +## [v4.2.0](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.0) (2022-06-03) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.1.9...v4.2.0) + +### Breaking Changes +* Validation: support placeholders for anything by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5545 +* Fix: Validation. Error key for field with asterisk by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5609 +* Improve exception logging by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5684 +* fix: spark can't use options on PHP 7.4 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5836 +* fix: [Autoloader] Composer classmap usage by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5850 +* fix: using multiple CLI::color() in CLI::write() outputs strings with wrong color by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5893 +* refactor: [Router] extract a class for auto-routing by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5877 +* feat: Debugbar request microtime by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5958 +* refactor: `system/bootstrap.php` only loads files and registers autoloader by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5972 +* fix: `dot_array_search()` unexpected behavior by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5940 +* feat: QueryBuilder join() raw SQL string support by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5875 +* fix: change BaseService::reset() $initAutoloader to true by default by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6020 + +### Fixed Bugs +* chore: update admin/framework/composer.json Kint by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5531 +* fix: BaseConnection::getConnectDuration() number_format(): Passing null to parameter by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5536 +* Fix: Debug toolbar selectors by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5544 +* Fix: Toolbar. ciDebugBar.showTab() context. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5554 +* Refactor Database Collector display by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5553 +* fix: add missing Migration lang item by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5557 +* feat: add Validation Strict Rules by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5445 +* fix: `Time::createFromTimestamp()` sets incorrect time when specifying timezone by @totoprayogo1916 in https://github.com/codeigniter4/CodeIgniter4/pull/5588 +* fix: Entity's isset() and unset() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5497 +* Fix: Deletion timestamp of the Model is updated when a record that has been soft-deleted is deleted again by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5578 +* Fix: Added alias escaping in subquery by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5601 +* fix: spark migrate:status does not show status with different namespaces by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5605 +* BaseService - Use lowercase key in resetSingle by @najdanovicivan in https://github.com/codeigniter4/CodeIgniter4/pull/5596 +* Fix `array_flatten_with_dots` ignores empty array values by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5606 +* fix: debug toolbar Routes Params output by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5619 +* fix: DownloadResponse memory leak by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5623 +* fix: spark does not show Exception by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5638 +* fix: Config CSRF $redirect does not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5665 +* fix: do not call header() if headers have already been sent by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5680 +* fix: $routes->setDefaultMethod() does not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5682 +* fix: debug toolbar vars response headers includes request headers by @zl59503020 in https://github.com/codeigniter4/CodeIgniter4/pull/5701 +* fix: 404 override controller does not output Response object body by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5703 +* fix: auto routes incorrectly display route filters with GET method by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5712 +* fix: Model::paginate() missing argument $group by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5699 +* Fix options are not passed to Command $params by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5206 +* fix: forceGlobalSecureRequests break URI schemes other than HTTP by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5730 +* fix: TypeError when `$tokenRandomize = true` and no token posted by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5742 +* fix: $builder->ignore()->insertBatch() only ignores on first iteration by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5672 +* fix: app/Config/Routes.php is loaded twice on Windows by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5780 +* fix: table name is double prefixed when LIKE clause by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5778 +* fix: Publisher $restrictions regex to FCPATH by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5793 +* fix: Timer::getElapsedTime() returns incorrect value by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5798 +* bug: Publisher $restrictions regex typo by @MGatner in https://github.com/codeigniter4/CodeIgniter4/pull/5800 +* fix: [Validation] valid_date ErrorException when the field is not sent by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5804 +* fix: [Pager] can't get correct current page from segment by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5803 +* fix: bug that allows dynamic controllers to be used by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5814 +* config: remove App\ and Config\ in autoload.psr-4 in app starter composer.json by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5824 +* fix: failover's DBPrefix not working by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5816 +* fix: Validation returns incorrect errors after Redirect with Input by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5844 +* feat: [Parser] add configs to change conditional delimiters by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5842 +* fix: Commands::discoverCommands() loads incorrect classname by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5849 +* fix: Publisher::discover() loads incorrect classname by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5858 +* fix: validation errors in Model are not cleared when running validation again by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5861 +* fix: Parser fails with `({variable})` in loop by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5840 +* fix: [BaseConfig] string value is set from environment variable even if it should be int/float by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5779 +* fix: add Escaper Exception classes in $coreClassmap by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5891 +* fix: Composer PSR-4 overwrites Config\Autoload::$psr4 by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5902 +* fix: Reverse Routing does not take into account the default namespace by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5936 +* fix: [Validation] Fields with an asterisk throws exception by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5938 +* fix: GDHandler::convert() does not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5969 +* fix: Images\Handlers\GDHandler Implicit conversion from float to int loses precision by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5965 +* fix: GDHandler::save() removes transparency by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5971 +* fix: route limit to subdomains does not work by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5961 +* fix: Model::_call() static analysis by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5970 +* fix: invalid css in error_404.php by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5978 +* Fix: Route placeholder (:any) with {locale} by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6003 +* Changing the subquery builder for the Oracle by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5999 +* fix: CURLRequest request body is not reset on the next request by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6014 +* Bug: The SQLSRV driver ignores the port value from the config. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6036 +* fix: `set_radio()` not working as expected by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6037 +* fix: add config for SQLite3 Foreign Keys by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6050 +* fix: Ignore non-HTML responses in storePreviousURL by @tearoom6 in https://github.com/codeigniter4/CodeIgniter4/pull/6012 +* fix: SQLite3\Table::copyData() does not escape column names by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6055 +* Fix `slash_item()` erroring when property fetched does not exist on `Config\App` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/6058 + +### New Features +* Feature Add Oracle driver by @ytetsuro in https://github.com/codeigniter4/CodeIgniter4/pull/2487 +* feat: new improved auto router by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5889 +* feat: new improved auto router `spark routes` command by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5953 +* feat: `db:table` command by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5979 + +### Enhancements +* feat: CSP enhancements by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5516 +* Feature: Subqueries in the FROM section by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5510 +* Added new View Decorators. by @lonnieezell in https://github.com/codeigniter4/CodeIgniter4/pull/5567 +* feat: auto routes listing by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5590 +* Feature: "spark routes" command shows routes with closure. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5651 +* feat: `spark routes` shows filters by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5628 +* Allow calling getQuery() multiple times, and other improvements by @vlakoff in https://github.com/codeigniter4/CodeIgniter4/pull/5127 +* feat: add Controller::validateData() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5639 +* feat: can add route handler as callable by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5713 +* Checking if the subquery uses the same object as the main query by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5743 +* Feature: Subquery for SELECT by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5736 +* Extend Validation from BaseConfig so Registrars can add rules. by @lonnieezell in https://github.com/codeigniter4/CodeIgniter4/pull/5789 +* config: add mime type for webp by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5838 +* feat: add `$includeDir` option to `get_filenames()` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5862 +* feat: throws exception when controller name in routes contains `/` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5885 +* [PHPStan] Prepare for PHPStan 1.6.x-dev by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/5876 +* [Rector] Add back SimplifyUselessVariableRector by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/5911 +* Redirecting Routes. Placeholders. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5916 +* script_tag(): cosmetic for value-less attributes by @xlii-chl in https://github.com/codeigniter4/CodeIgniter4/pull/5884 +* feat: QueryBuilder raw SQL string support by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5817 +* improve Router Exception message by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5984 +* feat: DBForge::addField() `default` value raw SQL string support by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5957 +* Add sample file for preloading by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5974 +* Feature. QueryBuilder. Query union. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6015 +* feat: `getFieldData()` returns nullable data on PostgreSQL by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5981 + +### Refactoring +* refactor: add Factories::models() to suppress PHPStan error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5358 +* Fixed style for PHP7.4 by @ytetsuro in https://github.com/codeigniter4/CodeIgniter4/pull/5581 +* Fix Autoloader::initialize() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5592 +* refactor: CURLRequest and the slow tests by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5593 +* Refactor `if_exist` validation with dot notation by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5607 +* refactor: small changes in Filters and Router by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5627 +* refactor: replace deprecated `getFilterForRoute()` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5624 +* refactor: make BaseController abstract by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5647 +* refactor: move logic to prevent access to initController by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5648 +* refactor: remove migrations routes by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5652 +* refactor: update Kint CSP nonce by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5657 +* Deprecate object implementations of `clean_path()` function by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5681 +* refactor: Session does not use cookies() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5656 +* refactor: replace deprecated Response::getReason() with getReasonPhrase() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5700 +* refactor: isCLI() in CLIRequest and IncomingRequest by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5653 +* refactor: CodeIgniter has context by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5650 +* Forge use statement by @mostafakhudair in https://github.com/codeigniter4/CodeIgniter4/pull/5729 +* refactor: remove `&` before $db by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5726 +* refactor: remove unneeded `&` references in ContentSecurityPolicy.php by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5734 +* Nonce replacement optimization. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5733 +* [Rector] Clean up skip config and re-run Rector by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/5813 +* refactor: DB Session Handler by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5696 +* Rename `Abstact` to `Abstract` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/5833 +* refactor: extract RedirectResponse::withErrors() method by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5860 +* Optimizing the RouteCollection::getRoutes() method by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/5918 +* refactor: add strtolower() to Request::getMethod() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5963 +* refactor: remove `$_SERVER['HTTP_HOST']` in RouteCollection by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/5962 +* refactor: deprecate const `EVENT_PRIORITY_*` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6000 +* fix: replace EVENT_PRIORITY_NORMAL with Events::PRIORITY_NORMAL by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6005 +* Router class optimization. by @iRedds in https://github.com/codeigniter4/CodeIgniter4/pull/6004 +* Prefer `is_file()` by @MGatner in https://github.com/codeigniter4/CodeIgniter4/pull/6025 +* refactor: use get_filenames() 4th param in FileLocator by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6026 +* refactor: use get_filenames() 4th param by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6031 +* refactor: CodeIgniter $context check by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6047 +* Small change to improve code reading by @valmorflores in https://github.com/codeigniter4/CodeIgniter4/pull/6051 +* refactor: remove `CodeIgniter\Services` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6053 + +See [CHANGELOG_4.1.md](./changelogs/CHANGELOG_4.1.md) From 284e90bb8a08f27523b8dcab57d6ee1ce5b97eae Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 10:06:39 +0900 Subject: [PATCH 035/290] docs: update/add links to repo's CHANGELOG --- user_guide_src/source/changelogs/v4.2.0.rst | 5 ++++- user_guide_src/source/changelogs/v4.2.1.rst | 7 +++++++ user_guide_src/source/changelogs/v4.2.10.rst | 4 +++- user_guide_src/source/changelogs/v4.2.11.rst | 4 +++- user_guide_src/source/changelogs/v4.2.12.rst | 4 +++- user_guide_src/source/changelogs/v4.2.2.rst | 4 +++- user_guide_src/source/changelogs/v4.2.3.rst | 4 +++- user_guide_src/source/changelogs/v4.2.5.rst | 4 +++- user_guide_src/source/changelogs/v4.2.6.rst | 4 +++- user_guide_src/source/changelogs/v4.2.7.rst | 4 +++- user_guide_src/source/changelogs/v4.2.8.rst | 4 +++- user_guide_src/source/changelogs/v4.2.9.rst | 4 +++- 12 files changed, 41 insertions(+), 11 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.2.0.rst b/user_guide_src/source/changelogs/v4.2.0.rst index 232b7a98fede..861666077934 100644 --- a/user_guide_src/source/changelogs/v4.2.0.rst +++ b/user_guide_src/source/changelogs/v4.2.0.rst @@ -158,6 +158,9 @@ Deprecations Bugs Fixed ********** + - The SQLSRV driver ignores the port value from the config. -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.2.1.rst b/user_guide_src/source/changelogs/v4.2.1.rst index 486197688894..44a16d464c8a 100644 --- a/user_guide_src/source/changelogs/v4.2.1.rst +++ b/user_guide_src/source/changelogs/v4.2.1.rst @@ -17,3 +17,10 @@ Behavior Changes - Guessing the file extension from the MIME type has been changed if the proposed extension is not valid. Previously, the guessing will early terminate and return ``null``. Now, if a proposed extension is given and is invalid, the MIME guessing will continue checking using the mapping of extension to MIME types. - If there is a cookie with a prefixed name and a cookie with the same name without a prefix, the previous ``get_cookie()`` had the tricky behavior of returning the cookie without the prefix. Now the behavior has been fixed as a bug, and has been changed. See :ref:`Upgrading ` for details. + +Bugs Fixed +********** + +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.2.10.rst b/user_guide_src/source/changelogs/v4.2.10.rst index de0d0c231a75..cb753723e158 100644 --- a/user_guide_src/source/changelogs/v4.2.10.rst +++ b/user_guide_src/source/changelogs/v4.2.10.rst @@ -14,4 +14,6 @@ Bugs Fixed - Fixed incorrect PHPDoc types in Session. -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.2.11.rst b/user_guide_src/source/changelogs/v4.2.11.rst index 98e66a8ad7a0..dc4d0b217fce 100644 --- a/user_guide_src/source/changelogs/v4.2.11.rst +++ b/user_guide_src/source/changelogs/v4.2.11.rst @@ -29,4 +29,6 @@ Bugs Fixed - Fixed a ``FileLocator::locateFile()`` bug where a similar namespace name could be replaced by another, causing a failure to find a file that exists. - Fixed a ``RedisHandler`` session class to use the correct config when used with a socket connection. -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.2.12.rst b/user_guide_src/source/changelogs/v4.2.12.rst index d3239378f431..441d19675b74 100644 --- a/user_guide_src/source/changelogs/v4.2.12.rst +++ b/user_guide_src/source/changelogs/v4.2.12.rst @@ -17,4 +17,6 @@ Bugs Fixed - Fixed ``spark migrate:status`` shows incorrect filenames when format is ``Y_m_d_His_``. - Fixed an error when ``Model::save()`` saves an object if ``$useAutoIncrement`` is false. -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.2.2.rst b/user_guide_src/source/changelogs/v4.2.2.rst index 754216ce4102..6b57ba63c9f2 100644 --- a/user_guide_src/source/changelogs/v4.2.2.rst +++ b/user_guide_src/source/changelogs/v4.2.2.rst @@ -42,4 +42,6 @@ Deprecations Bugs Fixed ********** -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.2.3.rst b/user_guide_src/source/changelogs/v4.2.3.rst index 69a2889a810e..e3b2eb0cf140 100644 --- a/user_guide_src/source/changelogs/v4.2.3.rst +++ b/user_guide_src/source/changelogs/v4.2.3.rst @@ -17,4 +17,6 @@ Enhancements Bugs Fixed ********** -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of 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 96908b750843..1f03ac1e041e 100644 --- a/user_guide_src/source/changelogs/v4.2.5.rst +++ b/user_guide_src/source/changelogs/v4.2.5.rst @@ -25,4 +25,6 @@ Bugs Fixed ********** - When using subqueries in the main query, prefixes are added to the table alias. -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.2.6.rst b/user_guide_src/source/changelogs/v4.2.6.rst index 154927470ba7..4e955706b612 100644 --- a/user_guide_src/source/changelogs/v4.2.6.rst +++ b/user_guide_src/source/changelogs/v4.2.6.rst @@ -21,4 +21,6 @@ Many bugs fixed, but notably: - AssertionError occurs when using Validation in CLI `#6452 `_ -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.2.7.rst b/user_guide_src/source/changelogs/v4.2.7.rst index 920ba72761ce..9b30c8385942 100644 --- a/user_guide_src/source/changelogs/v4.2.7.rst +++ b/user_guide_src/source/changelogs/v4.2.7.rst @@ -31,4 +31,6 @@ Message Changes Bugs Fixed ********** -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of 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 4b6d83c98a6a..19f1696ea29d 100644 --- a/user_guide_src/source/changelogs/v4.2.8.rst +++ b/user_guide_src/source/changelogs/v4.2.8.rst @@ -22,4 +22,6 @@ Bugs Fixed - Fixed a bug when the ``CodeIgniter\Database\SQLSRV\PreparedQuery::_getResult()`` was returning the bool value instead of the resource. - Fixed a bug in the error handler where in cases the callback cannot process the error level it does not pass the error to PHP's standard error handler. -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.2.9.rst b/user_guide_src/source/changelogs/v4.2.9.rst index b5d6ecaea143..2e7a0fbacbeb 100644 --- a/user_guide_src/source/changelogs/v4.2.9.rst +++ b/user_guide_src/source/changelogs/v4.2.9.rst @@ -16,4 +16,6 @@ Bugs Fixed - Fixed a bug that causes `PHP Fatal error: Trait "Nexus\PHPUnit\Extension\Expeditable" not found` when running PHPUnit. -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.2.md `_ +for a complete list of bugs fixed. From ef94f3f97a3d7060d9ae98118e6885eb4fae50f4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 10:55:54 +0900 Subject: [PATCH 036/290] fix: remove parameter $relative which does not work --- system/Helpers/url_helper.php | 15 ++++--- .../Helpers/URLHelper/CurrentUrlTest.php | 42 +++---------------- 2 files changed, 12 insertions(+), 45 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 682830ba1e5a..45fd5ad110e6 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -183,15 +183,14 @@ function previous_url(bool $returnObject = false) /** * URL String * - * Returns the path part of the current URL - * - * @param bool $relative Whether the resulting path should be relative to baseURL + * Returns the path part (relative to baseURL) of the current URL */ - function uri_string(bool $relative = false): string + function uri_string(): string { - return $relative - ? ltrim(Services::request()->getPath(), '/') - : Services::request()->getUri()->getPath(); + // The value of Services::request()->getUri()->getPath() is overridden + // by IncomingRequest constructor. If we use it here, the current tests + // in CurrentUrlTest will fail. + return ltrim(Services::request()->getPath(), '/'); } } @@ -583,7 +582,7 @@ function url_is(string $path): bool { // Setup our regex to allow wildcards $path = '/' . trim(str_replace('*', '(\S)*', $path), '/ '); - $currentPath = '/' . trim(uri_string(true), '/ '); + $currentPath = '/' . trim(uri_string(), '/ '); return (bool) preg_match("|^{$path}$|", $currentPath, $matches); } diff --git a/tests/system/Helpers/URLHelper/CurrentUrlTest.php b/tests/system/Helpers/URLHelper/CurrentUrlTest.php index 1caafc192f46..ed48be914321 100644 --- a/tests/system/Helpers/URLHelper/CurrentUrlTest.php +++ b/tests/system/Helpers/URLHelper/CurrentUrlTest.php @@ -163,7 +163,7 @@ public function testCurrentURLWithPortInSubfolder() $this->assertSame(8080, $uri->getPort()); } - public function testUriStringAbsolute() + public function testUriString() { $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['REQUEST_URI'] = '/assets/image.jpg'; @@ -183,18 +183,7 @@ private function setService(string $uri): void Services::injectMock('request', $request); } - public function testUriStringRelative() - { - $_SERVER['HTTP_HOST'] = 'example.com'; - $_SERVER['REQUEST_URI'] = '/assets/image.jpg'; - - $uri = 'http://example.com/assets/image.jpg'; - $this->setService($uri); - - $this->assertSame('assets/image.jpg', uri_string(true)); - } - - public function testUriStringNoTrailingSlashAbsolute() + public function testUriStringNoTrailingSlash() { $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['REQUEST_URI'] = '/assets/image.jpg'; @@ -207,33 +196,12 @@ public function testUriStringNoTrailingSlashAbsolute() $this->assertSame('assets/image.jpg', uri_string()); } - public function testUriStringNoTrailingSlashRelative() - { - $_SERVER['HTTP_HOST'] = 'example.com'; - $_SERVER['REQUEST_URI'] = '/assets/image.jpg'; - - $this->config->baseURL = 'http://example.com'; - - $uri = 'http://example.com/assets/image.jpg'; - $this->setService($uri); - - $this->assertSame('assets/image.jpg', uri_string(true)); - } - - public function testUriStringEmptyAbsolute() + public function testUriStringEmpty() { $uri = 'http://example.com/'; $this->setService($uri); - $this->assertSame('/', uri_string()); - } - - public function testUriStringEmptyRelative() - { - $uri = 'http://example.com/'; - $this->setService($uri); - - $this->assertSame('', uri_string(true)); + $this->assertSame('', uri_string()); } public function testUriStringSubfolderAbsolute() @@ -260,7 +228,7 @@ public function testUriStringSubfolderRelative() $uri = 'http://example.com/subfolder/assets/image.jpg'; $this->setService($uri); - $this->assertSame('assets/image.jpg', uri_string(true)); + $this->assertSame('assets/image.jpg', uri_string()); } public function urlIsProvider() From a32fdd278084165f7afddb39e382e01d28d9d0a4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 10:56:29 +0900 Subject: [PATCH 037/290] docs: update docs --- user_guide_src/source/helpers/url_helper.rst | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst index 2dc337b2335f..8cb19251888d 100644 --- a/user_guide_src/source/helpers/url_helper.rst +++ b/user_guide_src/source/helpers/url_helper.rst @@ -121,27 +121,32 @@ The following functions are available: use a known and trusted source. If the session hasn't been loaded, or is otherwise unavailable, then a sanitized version of HTTP_REFERER will be used. -.. php:function:: uri_string([$relative = false]) +.. php:function:: uri_string() - :param boolean $relative: True if you would like the string relative to baseURL :returns: A URI string - :rtype: string + :rtype: string + + Returns the path part of the current URL relative to baseURL. - Returns the path part of the current URL. - For example, if your URL was this:: + For example, when your baseURL is **http://some-site.com/** and the current URL is:: http://some-site.com/blog/comments/123 The function would return:: - /blog/comments/123 + blog/comments/123 + + When your baseURL is **http://some-site.com/subfolder/** and the current URL is:: - Or with the optional relative parameter:: + http://some-site.com/subfolder/blog/comments/123 + + The function would return:: - app.baseURL = http://some-site.com/subfolder/ + blog/comments/123 - uri_string(); // "/subfolder/blog/comments/123" - uri_string(true); // "blog/comments/123" + .. note:: In previous versions, the parameter ``$relative = false`` was defined. + However, due to a bug, this function always returned a path relative to baseURL. + Since v4.3.2, the parameter has been removed. .. php:function:: index_page([$altConfig = null]) From cee174cf421272f4e97f72a8137b1331b4f5c6bd Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 11:24:55 +0900 Subject: [PATCH 038/290] docs: add changelog --- user_guide_src/source/changelogs/index.rst | 1 + user_guide_src/source/changelogs/v4.3.2.rst | 32 +++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 user_guide_src/source/changelogs/v4.3.2.rst diff --git a/user_guide_src/source/changelogs/index.rst b/user_guide_src/source/changelogs/index.rst index 401d178f285f..9932e8725891 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.2 v4.3.1 v4.3.0 v4.2.12 diff --git a/user_guide_src/source/changelogs/v4.3.2.rst b/user_guide_src/source/changelogs/v4.3.2.rst new file mode 100644 index 000000000000..f1b8e7c5dc72 --- /dev/null +++ b/user_guide_src/source/changelogs/v4.3.2.rst @@ -0,0 +1,32 @@ +Version 4.3.2 +############# + +Release Date: Unreleased + +**4.3.2 release of CodeIgniter4** + +.. contents:: + :local: + :depth: 3 + +BREAKING +******** + +Message Changes +*************** + +Changes +******* + +- The parameter ``$relative`` in :php:func:`uri_string()` was removed. Due to a bug, + the function always returned a path relative to baseURL. No behavior changes. + +Deprecations +************ + +Bugs Fixed +********** + +See the repo's +`CHANGELOG.md `_ +for a complete list of bugs fixed. From 4a9f8ae2e56515bf14c023fae31b04531fa914e1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 12:17:55 +0900 Subject: [PATCH 039/290] docs: remove text decoration --- user_guide_src/source/helpers/form_helper.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst index 0b05d49f2ae6..6faa454252e3 100644 --- a/user_guide_src/source/helpers/form_helper.rst +++ b/user_guide_src/source/helpers/form_helper.rst @@ -12,7 +12,7 @@ forms. Configuration ============= -Since ``v4.3.0``, void HTML elements (e.g. ````) in ``form_helper`` functions have been changed to be HTML5-compatible by default and if you need to be compatible with XHTML, you must set the ``$html5`` property in **app/Config/DocTypes.php** to ``false``. +Since v4.3.0, void HTML elements (e.g. ````) in ``form_helper`` functions have been changed to be HTML5-compatible by default and if you need to be compatible with XHTML, you must set the ``$html5`` property in **app/Config/DocTypes.php** to ``false``. Loading this Helper =================== From 3f5d81cd91db543e0179a5dcb73bc0635c17251a Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 12:18:22 +0900 Subject: [PATCH 040/290] docs: fix XHTML void element tags --- user_guide_src/source/helpers/form_helper.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst index 6faa454252e3..470b5df45f6f 100644 --- a/user_guide_src/source/helpers/form_helper.rst +++ b/user_guide_src/source/helpers/form_helper.rst @@ -37,7 +37,7 @@ Since the above string contains a set of quotes, it will cause the form to break. The :php:func:`esc()` function converts HTML special characters so that it can be used safely:: - + .. note:: If you use any of the form helper functions listed on this page, and you pass values as an associative array, @@ -106,7 +106,7 @@ The following functions are available: will return::
- + .. note:: To use auto-generation of CSRF field, you need to turn CSRF filter on to the form page. In most cases it is requested using the ``GET`` method. @@ -122,8 +122,8 @@ The following functions are available: The above example would create a form similar to this:: - - + + .. php:function:: form_open_multipart([$action = ''[, $attributes = ''[, $hidden = []]]]) @@ -457,7 +457,7 @@ The following functions are available: Example:: - + The above form will show "0" when loaded for the first time. @@ -500,8 +500,8 @@ The following functions are available: Example:: - /> - /> + > + > .. php:function:: set_radio($field[, $value = ''[, $default = false]]) @@ -516,8 +516,8 @@ The following functions are available: Example:: - /> - /> + > + > .. php:function:: validation_errors() From 278f75e83691326b052a3c3420ead729f850d4da Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 13:06:16 +0900 Subject: [PATCH 041/290] docs: fix section level --- user_guide_src/source/helpers/form_helper.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst index 470b5df45f6f..7f1d777850fe 100644 --- a/user_guide_src/source/helpers/form_helper.rst +++ b/user_guide_src/source/helpers/form_helper.rst @@ -9,20 +9,23 @@ forms. :local: :depth: 2 +************* Configuration -============= +************* Since v4.3.0, void HTML elements (e.g. ````) in ``form_helper`` functions have been changed to be HTML5-compatible by default and if you need to be compatible with XHTML, you must set the ``$html5`` property in **app/Config/DocTypes.php** to ``false``. +******************* Loading this Helper -=================== +******************* This helper is loaded using the following code: .. literalinclude:: form_helper/001.php -Escaping field values -===================== +********************* +Escaping Field Values +********************* You may need to use HTML and characters such as quotes within your form elements. In order to do that safely, you'll need to use @@ -45,8 +48,9 @@ characters so that it can be used safely:: to call this function. Use it only if you are creating your own form elements, which you would pass as strings. +******************* Available Functions -=================== +******************* The following functions are available: From 3d19080354da07db7f996a867fa7834e1fd650f0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 13:17:14 +0900 Subject: [PATCH 042/290] docs: add links --- user_guide_src/source/helpers/form_helper.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst index 7f1d777850fe..cb60013843cc 100644 --- a/user_guide_src/source/helpers/form_helper.rst +++ b/user_guide_src/source/helpers/form_helper.rst @@ -30,7 +30,7 @@ Escaping Field Values You may need to use HTML and characters such as quotes within your form elements. In order to do that safely, you'll need to use :doc:`common function <../general/common_functions>` -:func:`esc()`. +:php:func:`esc()`. Consider the following example: @@ -103,7 +103,7 @@ The following functions are available: - If CSRF filter is turned on ``form_open()`` will generate CSRF field at the beginning of the form. You can specify ID of this field by passing csrf_id as one of the ``$attribute`` array: + If :ref:`CSRF ` filter is turned on ``form_open()`` will generate CSRF field at the beginning of the form. You can specify ID of this field by passing csrf_id as one of the ``$attribute`` array: .. literalinclude:: form_helper/007.php From 4e39c33083f3bc8174ae0a4040a193d62baf3759 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 13:19:50 +0900 Subject: [PATCH 043/290] docs: use Request::is() instead of getMethod() --- user_guide_src/source/libraries/security.rst | 8 ++++++-- user_guide_src/source/libraries/validation.rst | 4 ++++ user_guide_src/source/libraries/validation/001.php | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst index 4ab3978ad76f..970e5be45c41 100644 --- a/user_guide_src/source/libraries/security.rst +++ b/user_guide_src/source/libraries/security.rst @@ -44,10 +44,14 @@ Do one of the following: E.g.:: - if (strtolower($this->request->getMethod()) !== 'post') { + if (! $this->request->is('post')) { return $this->response->setStatusCode(405)->setBody('Method Not Allowed'); } +.. note:: The :ref:`$this->request->is() ` method can be used since v4.3.0. + In previous versions, you need to use + ``if (strtolower($this->request->getMethod()) !== 'post')``. + When Auto-Routing is Enabled ---------------------------- @@ -55,7 +59,7 @@ When Auto-Routing is Enabled E.g.:: - if (strtolower($this->request->getMethod()) !== 'post') { + if (! $this->request->is('post')) { return $this->response->setStatusCode(405)->setBody('Method Not Allowed'); } diff --git a/user_guide_src/source/libraries/validation.rst b/user_guide_src/source/libraries/validation.rst index 8a7644502e53..045abc4604c1 100644 --- a/user_guide_src/source/libraries/validation.rst +++ b/user_guide_src/source/libraries/validation.rst @@ -121,6 +121,10 @@ this code and save it to your **app/Controllers/** folder: .. literalinclude:: validation/001.php +.. note:: The :ref:`$this->request->is() ` method can be used since v4.3.0. + In previous versions, you need to use + ``if (strtolower($this->request->getMethod()) !== 'post')``. + The Routes ========== diff --git a/user_guide_src/source/libraries/validation/001.php b/user_guide_src/source/libraries/validation/001.php index c3f0d2b35baa..af2acb754a7b 100644 --- a/user_guide_src/source/libraries/validation/001.php +++ b/user_guide_src/source/libraries/validation/001.php @@ -10,7 +10,7 @@ class Form extends BaseController public function index() { - if (strtolower($this->request->getMethod()) !== 'post') { + if (! $this->request->is('post')) { return view('signup'); } From c63f4d16a8ceaed31636b846fdfe767618f26c0c Mon Sep 17 00:00:00 2001 From: Lonnie Ezell Date: Mon, 16 Jan 2023 23:22:08 -0600 Subject: [PATCH 044/290] feat: link Shield to the HTML docs. (#7138) --- user_guide_src/source/libraries/official_packages.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/official_packages.rst b/user_guide_src/source/libraries/official_packages.rst index 6fc077f279c3..b1ac417fe2cb 100644 --- a/user_guide_src/source/libraries/official_packages.rst +++ b/user_guide_src/source/libraries/official_packages.rst @@ -17,7 +17,7 @@ additional functionality that not every site will need or want. Shield ****** -`CodeIgniter Shield `_ is an authentication +`CodeIgniter Shield `_ is an authentication and authorization framework for CodeIgniter 4. It is designed to be secure, flexible, and easily extendable to meet the needs of many different types of websites. Among the many features, it includes: From 3c47ad36eebaa79084ed29fbf15e88dcea710597 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 16:08:21 +0900 Subject: [PATCH 045/290] docs: fix out of dated sample command --- user_guide_src/source/general/modules.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/general/modules.rst b/user_guide_src/source/general/modules.rst index 5785d99ad00d..6c3eb08f792c 100644 --- a/user_guide_src/source/general/modules.rst +++ b/user_guide_src/source/general/modules.rst @@ -208,7 +208,7 @@ Seeds Seed files can be used from both the CLI and called from within other seed files as long as the full namespace is provided. If calling on the CLI, you will need to provide double backslashes:: - > php public/index.php migrations seed Acme\\Blog\\Database\\Seeds\\TestPostSeeder + > php spark db:seed Acme\\Blog\\Database\\Seeds\\TestPostSeeder Helpers ======= From 0cd7861c61c6854dddad3de37a7e8081433a6d99 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 16:11:07 +0900 Subject: [PATCH 046/290] docs: fix namespace in cli option 'Acme\Blog' is not wrong, but it is used only here. --- user_guide_src/source/dbmgmt/migration.rst | 2 +- user_guide_src/source/dbmgmt/seeds.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/dbmgmt/migration.rst b/user_guide_src/source/dbmgmt/migration.rst index c918d92d6ffc..bf43be4b6199 100644 --- a/user_guide_src/source/dbmgmt/migration.rst +++ b/user_guide_src/source/dbmgmt/migration.rst @@ -128,7 +128,7 @@ You can use (migrate) with the following options: This example will migrate ``Acme\Blog`` namespace with any new migrations on the test database group:: - > php spark migrate -g test -n 'Acme\Blog' + > php spark migrate -g test -n Acme\\Blog When using the ``--all`` option, it will scan through all namespaces attempting to find any migrations that have not been run. These will all be collected and then sorted as a group by date created. This should help diff --git a/user_guide_src/source/dbmgmt/seeds.rst b/user_guide_src/source/dbmgmt/seeds.rst index 3ed29914159f..9eb9ee4396f9 100644 --- a/user_guide_src/source/dbmgmt/seeds.rst +++ b/user_guide_src/source/dbmgmt/seeds.rst @@ -54,7 +54,7 @@ Using the command line, you can easily generate seed files. You can supply the **root** namespace where the seed file will be stored by supplying the ``--namespace`` option:: - > php spark make:seeder MySeeder --namespace Acme\Blog + > php spark make:seeder MySeeder --namespace Acme\\Blog If ``Acme\Blog`` is mapped to ``app/Blog`` directory, then this command will generate ``MySeeder.php`` at ``app/Blog/Database/Seeds`` directory. From e335e79de2059f6851f7f613bdae920e6bfea30d Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 17:40:31 +0900 Subject: [PATCH 047/290] test: fix template value A space is missing. --- tests/system/View/ParserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/View/ParserTest.php b/tests/system/View/ParserTest.php index 9b969f08972d..e04991146f98 100644 --- a/tests/system/View/ParserTest.php +++ b/tests/system/View/ParserTest.php @@ -600,7 +600,7 @@ public function testParserNoEscape() 'title' => '', ]; - $template = '{! title!}'; + $template = '{! title !}'; $this->parser->setData($data); $this->assertSame('', $this->parser->renderString($template)); } From 43d3f8d2c73195a1394266785e1fa3d670064a65 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 17:41:44 +0900 Subject: [PATCH 048/290] docs: add test case --- tests/system/View/ParserTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/system/View/ParserTest.php b/tests/system/View/ParserTest.php index e04991146f98..cfa2ab1e81e8 100644 --- a/tests/system/View/ParserTest.php +++ b/tests/system/View/ParserTest.php @@ -605,6 +605,19 @@ public function testParserNoEscape() $this->assertSame('', $this->parser->renderString($template)); } + public function testParserNoEscapeAndDelimiterChange() + { + $this->parser->setDelimiters('{{', '}}'); + + $data = [ + 'title' => '', + ]; + $this->parser->setData($data); + + $template = '{{! title !}}'; + $this->assertSame('', $this->parser->renderString($template)); + } + public function testIgnoresComments() { $data = [ From 8451f913b3fd80b540c05b5200d0b454228ab183 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 17:42:05 +0900 Subject: [PATCH 049/290] style: break long line --- system/View/Parser.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/View/Parser.php b/system/View/Parser.php index 8d0331a9e1cf..7f483183b1ab 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -257,7 +257,9 @@ protected function parse(string $template, array $data = [], ?array $options = n */ protected function parseSingle(string $key, string $val): array { - $pattern = '#' . $this->leftDelimiter . '!?\s*' . preg_quote($key, '#') . '(?(?=\s*\|\s*)(\s*\|*\s*([|\w<>=\(\),:.\-\s\+\\\\/]+)*\s*))(\s*)!?' . $this->rightDelimiter . '#ums'; + $pattern = '#' . $this->leftDelimiter . '!?\s*' . preg_quote($key, '#') + . '(?(?=\s*\|\s*)(\s*\|*\s*([|\w<>=\(\),:.\-\s\+\\\\/]+)*\s*))(\s*)!?' + . $this->rightDelimiter . '#ums'; return [$pattern => $val]; } From a5bce2ff9c5af0c8fa733c5915ca76efd6639dcc Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 17:43:23 +0900 Subject: [PATCH 050/290] fix: ! for no escape does not work if delimiter is changed --- system/View/Parser.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/system/View/Parser.php b/system/View/Parser.php index 7f483183b1ab..b9abf91edb5f 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -508,7 +508,10 @@ protected function replaceSingle($pattern, $content, $template, bool $escape = f // Replace the content in the template return preg_replace_callback($pattern, function ($matches) use ($content, $escape) { // Check for {! !} syntax to not escape this one. - if (strpos($matches[0], '{!') === 0 && substr($matches[0], -2) === '!}') { + if ( + strpos($matches[0], $this->leftDelimiter . '!') === 0 + && substr($matches[0], -1 - strlen($this->rightDelimiter)) === '!' . $this->rightDelimiter + ) { $escape = false; } From 238517bdad454ce14f19641f4e39bd44d84cf78c Mon Sep 17 00:00:00 2001 From: Toto Date: Tue, 17 Jan 2023 18:09:02 +0700 Subject: [PATCH 051/290] add `application/vnd.microsoft.portable-executable` and `application/x-dosexec` --- app/Config/Mimes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Config/Mimes.php b/app/Config/Mimes.php index 6b06c4e3a3f5..99d28e5f8f86 100644 --- a/app/Config/Mimes.php +++ b/app/Config/Mimes.php @@ -53,6 +53,8 @@ class Mimes 'lzh' => 'application/octet-stream', 'exe' => [ 'application/octet-stream', + 'application/vnd.microsoft.portable-executable', + 'application/x-dosexec', 'application/x-msdownload', ], 'class' => 'application/octet-stream', From 4e5cf20b70bbeb8dadf11ed7c3975a2ac75ff75d Mon Sep 17 00:00:00 2001 From: sclubricants Date: Tue, 17 Jan 2023 12:35:25 -0800 Subject: [PATCH 052/290] Fix logic for RawSql Allow RawSql for both key and value. When key only and value is null then we treat a little different. --- system/Database/BaseBuilder.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 9e2c634cb7f2..3eb0aaaadc86 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -728,9 +728,16 @@ public function orWhere($key, $value = null, ?bool $escape = null) */ protected function whereHaving(string $qbKey, $key, $value = null, string $type = 'AND ', ?bool $escape = null) { + $rawSqlOnly = false; + if ($key instanceof RawSql) { - $keyValue = [(string) $key => $key]; - $escape = false; + if ($value === null) { + $keyValue = [(string) $key => $key]; + $rawSqlOnly = true; + } else { + $keyValue = [(string) $key => $value]; + } + $escape = false; } elseif (! is_array($key)) { $keyValue = [$key => $value]; } else { @@ -745,7 +752,7 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type foreach ($keyValue as $k => $v) { $prefix = empty($this->{$qbKey}) ? $this->groupGetType('') : $this->groupGetType($type); - if ($v instanceof RawSql) { + if ($rawSqlOnly === true) { $k = ''; $op = ''; } elseif ($v !== null) { From 2a267ea09ac16be5c3fa80d1a450d6d3832325e2 Mon Sep 17 00:00:00 2001 From: sclubricants Date: Tue, 17 Jan 2023 12:36:04 -0800 Subject: [PATCH 053/290] Add test for different uses of RawSql --- tests/system/Database/Builder/WhereTest.php | 45 +++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/system/Database/Builder/WhereTest.php b/tests/system/Database/Builder/WhereTest.php index 4d5884dc05a0..9a5b412adc99 100644 --- a/tests/system/Database/Builder/WhereTest.php +++ b/tests/system/Database/Builder/WhereTest.php @@ -174,6 +174,51 @@ public function testWhereRawSql() $this->assertSame($expectedBinds, $builder->getBinds()); } + public function testWhereValueRawSql() + { + $sql = $this->db->table('auth_bearer') + ->select('*') + ->where('expires', new RawSql('DATE_ADD(NOW(), INTERVAL 2 HOUR)')) + ->getCompiledSelect(true); + + $expected = <<<'SQL' + SELECT * + FROM "auth_bearer" + WHERE "expires" = DATE_ADD(NOW(), INTERVAL 2 HOUR) + SQL; + $this->assertSame($expected, $sql); + } + + public function testWhereKeyAndValueRawSql() + { + $sql = $this->db->table('auth_bearer') + ->select('*') + ->where(new RawSql('CURRENT_TIMESTAMP()'), new RawSql('DATE_ADD(column, INTERVAL 2 HOUR)')) + ->getCompiledSelect(true); + + $expected = <<<'SQL' + SELECT * + FROM "auth_bearer" + WHERE CURRENT_TIMESTAMP() = DATE_ADD(column, INTERVAL 2 HOUR) + SQL; + $this->assertSame($expected, $sql); + } + + public function testWhereKeyAndValueRawSqlWithOperator() + { + $sql = $this->db->table('auth_bearer') + ->select('*') + ->where(new RawSql('CURRENT_TIMESTAMP() >='), new RawSql('DATE_ADD(column, INTERVAL 2 HOUR)')) + ->getCompiledSelect(true); + + $expected = <<<'SQL' + SELECT * + FROM "auth_bearer" + WHERE CURRENT_TIMESTAMP() >= DATE_ADD(column, INTERVAL 2 HOUR) + SQL; + $this->assertSame($expected, $sql); + } + public function testWhereValueSubQuery() { $expectedSQL = 'SELECT * FROM "neworder" WHERE "advance_amount" < (SELECT MAX(advance_amount) FROM "orders" WHERE "id" > 2)'; From c12600cbb75bbbc1c0da391722271d180341fb94 Mon Sep 17 00:00:00 2001 From: sclubricants Date: Tue, 17 Jan 2023 12:44:25 -0800 Subject: [PATCH 054/290] Remove Escape RawSql already avoids escape. This was removed for instances where key is RawSql and value isn't --- system/Database/BaseBuilder.php | 1 - 1 file changed, 1 deletion(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 3eb0aaaadc86..a7aabc7b97c8 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -737,7 +737,6 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type } else { $keyValue = [(string) $key => $value]; } - $escape = false; } elseif (! is_array($key)) { $keyValue = [$key => $value]; } else { From a79f8b3261ee9ede3b91ac997d8607cb769d7366 Mon Sep 17 00:00:00 2001 From: sclubricants Date: Tue, 17 Jan 2023 12:46:00 -0800 Subject: [PATCH 055/290] Revert prior commit escape is being set false here not to true. --- system/Database/BaseBuilder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index a7aabc7b97c8..3eb0aaaadc86 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -737,6 +737,7 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type } else { $keyValue = [(string) $key => $value]; } + $escape = false; } elseif (! is_array($key)) { $keyValue = [$key => $value]; } else { From 8d0e216853541656d6e51ebe92602aed2ae46062 Mon Sep 17 00:00:00 2001 From: sclubricants Date: Tue, 17 Jan 2023 16:00:40 -0800 Subject: [PATCH 056/290] Removed $escape = false; again Added another test where this makes a difference. --- system/Database/BaseBuilder.php | 1 - tests/system/Database/Builder/WhereTest.php | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 3eb0aaaadc86..a7aabc7b97c8 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -737,7 +737,6 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type } else { $keyValue = [(string) $key => $value]; } - $escape = false; } elseif (! is_array($key)) { $keyValue = [$key => $value]; } else { diff --git a/tests/system/Database/Builder/WhereTest.php b/tests/system/Database/Builder/WhereTest.php index 9a5b412adc99..a4b592ffd28c 100644 --- a/tests/system/Database/Builder/WhereTest.php +++ b/tests/system/Database/Builder/WhereTest.php @@ -189,6 +189,21 @@ public function testWhereValueRawSql() $this->assertSame($expected, $sql); } + public function testWhereKeyOnlyRawSql() + { + $sql = $this->db->table('auth_bearer') + ->select('*') + ->where(new RawSql('DATE_ADD(NOW(), INTERVAL 2 HOUR)'), '2023-01-01') + ->getCompiledSelect(true); + + $expected = <<<'SQL' + SELECT * + FROM "auth_bearer" + WHERE DATE_ADD(NOW(), INTERVAL 2 HOUR) = '2023-01-01' + SQL; + $this->assertSame($expected, $sql); + } + public function testWhereKeyAndValueRawSql() { $sql = $this->db->table('auth_bearer') From 11e6d1a6e982ade5a4dbf2823878a1118cef16f6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 18 Jan 2023 10:04:51 +0900 Subject: [PATCH 057/290] fix: RawSql disappear without error Throws an exception. --- system/Database/BaseBuilder.php | 4 ++++ tests/system/Database/Builder/InsertTest.php | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 9e2c634cb7f2..7331cc85c75e 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -3209,6 +3209,10 @@ protected function objectToArray($object) return $object; } + if ($object instanceof RawSql) { + throw new InvalidArgumentException('RawSql "' . $object . '" cannot be used here.'); + } + $array = []; foreach (get_object_vars($object) as $key => $val) { diff --git a/tests/system/Database/Builder/InsertTest.php b/tests/system/Database/Builder/InsertTest.php index 6601c6847366..b0fc3890cc3c 100644 --- a/tests/system/Database/Builder/InsertTest.php +++ b/tests/system/Database/Builder/InsertTest.php @@ -16,6 +16,7 @@ use CodeIgniter\Database\RawSql; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\Mock\MockConnection; +use InvalidArgumentException; /** * @internal @@ -279,4 +280,22 @@ public function testInsertBatchThrowsExceptionOnEmptyData() $this->expectExceptionMessage('insertBatch() has no data.'); $builder->insertBatch([]); } + + public function testSetIncorrectRawSqlUsage() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage( + 'RawSql "expires = DATE_ADD(NOW(), INTERVAL 2 HOUR)" cannot be used here.' + ); + + $builder = $this->db->table('auth_bearer'); + + $builder->testMode() + ->set([ + 'jti' => 'jti', + 'proctorID' => '12', + ]) + ->set(new RawSql('expires = DATE_ADD(NOW(), INTERVAL 2 HOUR)')) + ->insert(); + } } From 9f35ec5dd10784bf4f3808ded1f8e275c9516188 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Wed, 18 Jan 2023 09:05:53 +0700 Subject: [PATCH 058/290] fix: ordering validation show error by call set rule --- system/Validation/Validation.php | 2 +- tests/system/Validation/ValidationTest.php | 47 ++++++++++++++++++++-- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index 41aaa4a098fb..c22f38ae2413 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -443,7 +443,7 @@ public function setRule(string $field, ?string $label, $rules, array $errors = [ $ruleSet[$field]['errors'] = $errors; } - $this->setRules($ruleSet + $this->getRules(), $this->customErrors); + $this->setRules(array_merge($this->getRules(), $ruleSet), $this->customErrors); return $this; } diff --git a/tests/system/Validation/ValidationTest.php b/tests/system/Validation/ValidationTest.php index 6597866b3f88..2c6d52337fe9 100644 --- a/tests/system/Validation/ValidationTest.php +++ b/tests/system/Validation/ValidationTest.php @@ -102,6 +102,27 @@ public function testSetRuleStoresRule() ], $this->validation->getRules()); } + public function testSetRuleMultipleWithIndividual() + { + $this->validation->setRule('username', 'Username', 'required|min_length[3]'); + $this->validation->setRule('password', 'Password', ['required', 'min_length[8]', 'alpha_numeric_punct']); + + $this->assertSame([ + 'username' => [ + 'label' => 'Username', + 'rules' => 'required|min_length[3]', + ], + 'password' => [ + 'label' => 'Password', + 'rules' => [ + 'required', + 'min_length[8]', + 'alpha_numeric_punct', + ], + ], + ], $this->validation->getRules()); + } + public function testSetRuleAddsRule() { $this->validation->setRules([ @@ -113,14 +134,14 @@ public function testSetRuleAddsRule() $this->validation->setRule('foo', null, 'foo|foz'); $this->assertSame([ - 'foo' => [ - 'label' => null, - 'rules' => 'foo|foz', - ], 'bar' => [ 'label' => null, 'rules' => 'bar|baz', ], + 'foo' => [ + 'label' => null, + 'rules' => 'foo|foz', + ], ], $this->validation->getRules()); } @@ -142,6 +163,24 @@ public function testSetRuleOverwritesRule() ], $this->validation->getRules()); } + public function testSetRuleOverwritesRuleReverse() + { + $this->validation->setRule('foo', null, 'foo|foz'); + $this->validation->setRules([ + 'foo' => [ + 'label' => null, + 'rules' => 'bar|baz', + ], + ]); + + $this->assertSame([ + 'foo' => [ + 'label' => null, + 'rules' => 'bar|baz', + ], + ], $this->validation->getRules()); + } + /** * @dataProvider setRuleRulesFormatCaseProvider * From 4e2a8505ba3545647ce98c3cb2bb7e0e095ce581 Mon Sep 17 00:00:00 2001 From: totoprayogo1916 Date: Wed, 18 Jan 2023 05:42:12 +0700 Subject: [PATCH 059/290] update close-pull-request.yml - add types for pull_request_target - add permission - use GitHub CLI --- .../.github/workflows/close-pull-request.yml | 14 ++++++++++---- .../.github/workflows/close-pull-request.yml | 14 ++++++++++---- .../.github/workflows/close-pull-request.yml | 14 ++++++++++---- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/admin/framework/.github/workflows/close-pull-request.yml b/admin/framework/.github/workflows/close-pull-request.yml index 4e01f30f5138..7106224836f6 100644 --- a/admin/framework/.github/workflows/close-pull-request.yml +++ b/admin/framework/.github/workflows/close-pull-request.yml @@ -2,17 +2,23 @@ name: Close Pull Request on: pull_request_target: - types: [opened] + types: [opened, reopened] + +permissions: + pull-requests: write jobs: main: runs-on: ubuntu-latest steps: - name: Close PR with nice message - uses: superbrothers/close-pull-request@v3 - with: - comment: > + run: gh pr close ${{ env.ISSUE }} -c "${{ env.COMMENT }}" + working-directory: ${{ github.workspace }} + env: + COMMENT: > Thank you for your pull request. However, you have submitted your PR on a read-only split of `codeigniter4/CodeIgniter4`. This repository, unfortunately, does not accept PRs. Please submit your PR at https://github.com/codeigniter4/CodeIgniter4 repository.

Thank you. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE: ${{ github.event.pull_request.html_url }} diff --git a/admin/starter/.github/workflows/close-pull-request.yml b/admin/starter/.github/workflows/close-pull-request.yml index 4e01f30f5138..7106224836f6 100644 --- a/admin/starter/.github/workflows/close-pull-request.yml +++ b/admin/starter/.github/workflows/close-pull-request.yml @@ -2,17 +2,23 @@ name: Close Pull Request on: pull_request_target: - types: [opened] + types: [opened, reopened] + +permissions: + pull-requests: write jobs: main: runs-on: ubuntu-latest steps: - name: Close PR with nice message - uses: superbrothers/close-pull-request@v3 - with: - comment: > + run: gh pr close ${{ env.ISSUE }} -c "${{ env.COMMENT }}" + working-directory: ${{ github.workspace }} + env: + COMMENT: > Thank you for your pull request. However, you have submitted your PR on a read-only split of `codeigniter4/CodeIgniter4`. This repository, unfortunately, does not accept PRs. Please submit your PR at https://github.com/codeigniter4/CodeIgniter4 repository.

Thank you. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE: ${{ github.event.pull_request.html_url }} diff --git a/admin/userguide/.github/workflows/close-pull-request.yml b/admin/userguide/.github/workflows/close-pull-request.yml index 4e01f30f5138..7106224836f6 100644 --- a/admin/userguide/.github/workflows/close-pull-request.yml +++ b/admin/userguide/.github/workflows/close-pull-request.yml @@ -2,17 +2,23 @@ name: Close Pull Request on: pull_request_target: - types: [opened] + types: [opened, reopened] + +permissions: + pull-requests: write jobs: main: runs-on: ubuntu-latest steps: - name: Close PR with nice message - uses: superbrothers/close-pull-request@v3 - with: - comment: > + run: gh pr close ${{ env.ISSUE }} -c "${{ env.COMMENT }}" + working-directory: ${{ github.workspace }} + env: + COMMENT: > Thank you for your pull request. However, you have submitted your PR on a read-only split of `codeigniter4/CodeIgniter4`. This repository, unfortunately, does not accept PRs. Please submit your PR at https://github.com/codeigniter4/CodeIgniter4 repository.

Thank you. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE: ${{ github.event.pull_request.html_url }} From 4908a4712806e143f7b6cdbf0f18bc4af4301993 Mon Sep 17 00:00:00 2001 From: totoprayogo1916 Date: Wed, 18 Jan 2023 11:33:56 +0700 Subject: [PATCH 060/290] add tag `code` --- admin/framework/.github/workflows/close-pull-request.yml | 2 +- admin/starter/.github/workflows/close-pull-request.yml | 2 +- admin/userguide/.github/workflows/close-pull-request.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/framework/.github/workflows/close-pull-request.yml b/admin/framework/.github/workflows/close-pull-request.yml index 4e01f30f5138..3a7d2769c88b 100644 --- a/admin/framework/.github/workflows/close-pull-request.yml +++ b/admin/framework/.github/workflows/close-pull-request.yml @@ -13,6 +13,6 @@ jobs: with: comment: > Thank you for your pull request. However, you have submitted your PR on a read-only - split of `codeigniter4/CodeIgniter4`. This repository, unfortunately, does + split of codeigniter4/CodeIgniter4. This repository, unfortunately, does not accept PRs. Please submit your PR at https://github.com/codeigniter4/CodeIgniter4 repository.

Thank you. diff --git a/admin/starter/.github/workflows/close-pull-request.yml b/admin/starter/.github/workflows/close-pull-request.yml index 4e01f30f5138..3a7d2769c88b 100644 --- a/admin/starter/.github/workflows/close-pull-request.yml +++ b/admin/starter/.github/workflows/close-pull-request.yml @@ -13,6 +13,6 @@ jobs: with: comment: > Thank you for your pull request. However, you have submitted your PR on a read-only - split of `codeigniter4/CodeIgniter4`. This repository, unfortunately, does + split of codeigniter4/CodeIgniter4. This repository, unfortunately, does not accept PRs. Please submit your PR at https://github.com/codeigniter4/CodeIgniter4 repository.

Thank you. diff --git a/admin/userguide/.github/workflows/close-pull-request.yml b/admin/userguide/.github/workflows/close-pull-request.yml index 4e01f30f5138..3a7d2769c88b 100644 --- a/admin/userguide/.github/workflows/close-pull-request.yml +++ b/admin/userguide/.github/workflows/close-pull-request.yml @@ -13,6 +13,6 @@ jobs: with: comment: > Thank you for your pull request. However, you have submitted your PR on a read-only - split of `codeigniter4/CodeIgniter4`. This repository, unfortunately, does + split of codeigniter4/CodeIgniter4. This repository, unfortunately, does not accept PRs. Please submit your PR at https://github.com/codeigniter4/CodeIgniter4 repository.

Thank you. From d5f03cd10d46980a90caccaa0276fd7e99f26fba Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 18 Jan 2023 20:35:02 +0900 Subject: [PATCH 061/290] docs: add section titles --- user_guide_src/source/database/queries.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst index cefc49c705f5..4efa3ffe7791 100644 --- a/user_guide_src/source/database/queries.rst +++ b/user_guide_src/source/database/queries.rst @@ -56,17 +56,26 @@ fetchable results. Working with Database Prefixes Manually *************************************** +$db->prefixTable() +================== + If you have configured a database prefix and would like to prepend it to a table name for use in a native SQL query for example, then you can use the following: .. literalinclude:: queries/004.php +$db->setPrefix() +================ + If for any reason you would like to change the prefix programmatically without needing to create a new connection you can use this method: .. literalinclude:: queries/005.php +$db->getPrefix() +================ + You can get the current prefix any time with this method: .. literalinclude:: queries/006.php @@ -75,6 +84,9 @@ You can get the current prefix any time with this method: Protecting Identifiers ********************** +$db->protectIdentifiers() +========================= + In many databases, it is advisable to protect table and field names - for example with backticks in MySQL. **Query Builder queries are automatically protected**, but if you need to manually protect an From 2e80e28570dabb47d53d58683050f14d168d265b Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 18 Jan 2023 20:35:26 +0900 Subject: [PATCH 062/290] docs: improve section titles --- user_guide_src/source/database/queries.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst index 4efa3ffe7791..67480a5ac17d 100644 --- a/user_guide_src/source/database/queries.rst +++ b/user_guide_src/source/database/queries.rst @@ -269,8 +269,10 @@ hasError() Returns boolean true/false if the last ``execute()`` call created any errors. -getErrorCode() getErrorMessage() --------------------------------- +getErrorCode() +-------------- +getErrorMessage() +----------------- If any errors were encountered these methods can be used to retrieve the error code and string. @@ -283,8 +285,8 @@ Internally, all queries are processed and stored as instances of the parameters, otherwise preparing the query, and storing performance data about its query. -getLastQuery() -============== +$db->getLastQuery() +=================== When you just need to retrieve the last Query object, use the ``getLastQuery()`` method: From 4a9158c665efa0ec3eb17e230cedb77dbb592fea Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 18 Jan 2023 20:36:00 +0900 Subject: [PATCH 063/290] docs: add empty lines I don't know why, but without these empty lines, PhpStorm's Structure window does not show correct structure. --- user_guide_src/source/database/queries.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst index 67480a5ac17d..35d8c5ad08df 100644 --- a/user_guide_src/source/database/queries.rst +++ b/user_guide_src/source/database/queries.rst @@ -80,6 +80,7 @@ You can get the current prefix any time with this method: .. literalinclude:: queries/006.php + ********************** Protecting Identifiers ********************** @@ -105,6 +106,7 @@ prefixing set ``true`` (boolean) via the second parameter: .. literalinclude:: queries/008.php + *************** Escaping Values *************** @@ -196,6 +198,7 @@ example: .. literalinclude:: queries/015.php + **************** Prepared Queries **************** From c82a4c7209d84fe0ace91b0fb9888bbbd8edfaa6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 18 Jan 2023 20:38:34 +0900 Subject: [PATCH 064/290] docs: remove line break --- user_guide_src/source/database/queries/011.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/user_guide_src/source/database/queries/011.php b/user_guide_src/source/database/queries/011.php index e3b1f9033bc9..484bf11e0f76 100644 --- a/user_guide_src/source/database/queries/011.php +++ b/user_guide_src/source/database/queries/011.php @@ -1,5 +1,4 @@ escapeLikeString($search) . "%' ESCAPE '!'"; +$sql = "SELECT id FROM table WHERE column LIKE '%" . $db->escapeLikeString($search) . "%' ESCAPE '!'"; From 9734da61912d04979226ed2d791676945e6816cb Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 09:45:04 +0900 Subject: [PATCH 065/290] docs: fix section title for consistency --- user_guide_src/source/changelogs/v4.1.4.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.1.4.rst b/user_guide_src/source/changelogs/v4.1.4.rst index 60a4a9c21432..08f83142a273 100644 --- a/user_guide_src/source/changelogs/v4.1.4.rst +++ b/user_guide_src/source/changelogs/v4.1.4.rst @@ -12,8 +12,8 @@ Release Date: September 6, 2021 This release focuses on code style. All changes (except those noted below) are cosmetic to bring the code in line with the new `CodeIgniter Coding Standard `_ (based on PSR-12). -Breaking Changes ----------------- +BREAKING +-------- - The following methods were changed from "public" to "protected" to match their parent class methods and better align with their uses: From 00f4400162c5cc1ddbda62d01c5c3306ce04ff8d Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 09:46:10 +0900 Subject: [PATCH 066/290] docs: move section for consistency --- user_guide_src/source/changelogs/v4.0.5.rst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.0.5.rst b/user_guide_src/source/changelogs/v4.0.5.rst index 4c2fd34dabaf..12e2e215e357 100644 --- a/user_guide_src/source/changelogs/v4.0.5.rst +++ b/user_guide_src/source/changelogs/v4.0.5.rst @@ -26,13 +26,6 @@ Changes - System messages defined in **system/Language/en/** are now strictly for internal framework use and are not covered by backwards compatibility (BC) promise. Users may use these messages in their applications but at their own risks. -Bugs Fixed ----------- - -- Fixed a bug in ``Entity`` class where declaring class parameters was preventing data propagation to the ``attributes`` array. -- Handling for the environment variable ``encryption.key`` has changed. Previously, explicit function calls, like ``getenv('encryption.key')`` or ``env('encryption.key')`` where the value has the special prefix ``hex2bin:`` returns an automatically converted binary string. This is now changed to just return the character string with the prefix. This change was due to incompatibility with handling binary strings in environment variables on Windows platforms. However, accessing ``$key`` using ``Encryption`` class config remains unchanged and still returns a binary string. -- ``Config\Services`` (in **app/Config/Services.php**) now extends ``CodeIgniter\Config\BaseService`` to allow proper discovery of third-party services. - Deprecations ------------ @@ -55,3 +48,11 @@ Deprecations - Deprecated ``CodeIgniter\HTTP\Message::getHeader()`` in favor of ``header()`` to prepare for PSR-7 - Deprecated ``CodeIgniter\HTTP\Message::getHeaders()`` in favor of ``headers()`` to prepare for PSR-7 - Deprecated ``Config\Cache::$storePath`` in favor of ``Config\Cache::$file['storePath']`` + +Bugs Fixed +---------- + +- Fixed a bug in ``Entity`` class where declaring class parameters was preventing data propagation to the ``attributes`` array. +- Handling for the environment variable ``encryption.key`` has changed. Previously, explicit function calls, like ``getenv('encryption.key')`` or ``env('encryption.key')`` where the value has the special prefix ``hex2bin:`` returns an automatically converted binary string. This is now changed to just return the character string with the prefix. This change was due to incompatibility with handling binary strings in environment variables on Windows platforms. However, accessing ``$key`` using ``Encryption`` class config remains unchanged and still returns a binary string. +- ``Config\Services`` (in **app/Config/Services.php**) now extends ``CodeIgniter\Config\BaseService`` to allow proper discovery of third-party services. + From 8a9d7817219cfdb195d63497199917fb06fe112e Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 17 Jan 2023 09:46:40 +0900 Subject: [PATCH 067/290] docs: add or update links to repo's CHANGELOG --- user_guide_src/source/changelogs/v4.0.3.rst | 4 ++++ user_guide_src/source/changelogs/v4.0.4.rst | 4 ++++ user_guide_src/source/changelogs/v4.0.5.rst | 3 +++ user_guide_src/source/changelogs/v4.1.0.rst | 7 +++++++ user_guide_src/source/changelogs/v4.1.1.rst | 4 ++++ user_guide_src/source/changelogs/v4.1.2.rst | 6 ++++-- user_guide_src/source/changelogs/v4.1.3.rst | 4 ++++ user_guide_src/source/changelogs/v4.1.4.rst | 4 ++++ user_guide_src/source/changelogs/v4.1.5.rst | 4 +++- user_guide_src/source/changelogs/v4.1.6.rst | 4 +++- user_guide_src/source/changelogs/v4.1.7.rst | 4 +++- 11 files changed, 43 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.0.3.rst b/user_guide_src/source/changelogs/v4.0.3.rst index 80a93c3100cf..126f01cc06e0 100644 --- a/user_guide_src/source/changelogs/v4.0.3.rst +++ b/user_guide_src/source/changelogs/v4.0.3.rst @@ -31,3 +31,7 @@ Bugs Fixed - Default pagination templates fixed to use the correct locale. - Lots of tweaks and corrections in the user guide. - Fixed locating files in custom namespaces that were occassionally not found. Primarily affected console commands. + +See the repo's +`CHANGELOG_4.0.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.0.4.rst b/user_guide_src/source/changelogs/v4.0.4.rst index 90dddc804c5a..1e8a85c50277 100644 --- a/user_guide_src/source/changelogs/v4.0.4.rst +++ b/user_guide_src/source/changelogs/v4.0.4.rst @@ -65,3 +65,7 @@ Bugs Fixed - Ensure get translation output logic work on selected locale, dashed locale, and fallback "en". - Fix ``is_unique``/``is_not_unique`` validation called on POST/PUT via API in PostgreSQL. - Fixed a bug where filter arguments were not passed to ``after()``. + +See the repo's +`CHANGELOG_4.0.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.0.5.rst b/user_guide_src/source/changelogs/v4.0.5.rst index 12e2e215e357..777e2fd1193b 100644 --- a/user_guide_src/source/changelogs/v4.0.5.rst +++ b/user_guide_src/source/changelogs/v4.0.5.rst @@ -56,3 +56,6 @@ Bugs Fixed - Handling for the environment variable ``encryption.key`` has changed. Previously, explicit function calls, like ``getenv('encryption.key')`` or ``env('encryption.key')`` where the value has the special prefix ``hex2bin:`` returns an automatically converted binary string. This is now changed to just return the character string with the prefix. This change was due to incompatibility with handling binary strings in environment variables on Windows platforms. However, accessing ``$key`` using ``Encryption`` class config remains unchanged and still returns a binary string. - ``Config\Services`` (in **app/Config/Services.php**) now extends ``CodeIgniter\Config\BaseService`` to allow proper discovery of third-party services. +See the repo's +`CHANGELOG_4.0.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.1.0.rst b/user_guide_src/source/changelogs/v4.1.0.rst index 25fa9a5f6726..eee8abfddc28 100644 --- a/user_guide_src/source/changelogs/v4.1.0.rst +++ b/user_guide_src/source/changelogs/v4.1.0.rst @@ -23,3 +23,10 @@ Deprecations ************ - Deprecated ``Model::fillPlaceholders()`` method, use ``Validation::fillPlaceholders()`` instead. + +Bugs Fixed +********** + +See the repo's +`CHANGELOG_4.1.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.1.1.rst b/user_guide_src/source/changelogs/v4.1.1.rst index a99fb24d3770..aeccef6e3c41 100644 --- a/user_guide_src/source/changelogs/v4.1.1.rst +++ b/user_guide_src/source/changelogs/v4.1.1.rst @@ -15,3 +15,7 @@ Bugs Fixed - Fixed an issue where ``.gitattributes`` was preventing framework downloads. Note that this fix was also applied retroactively to ``4.0.5`` on the **framework** repo. + +See the repo's +`CHANGELOG_4.1.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.1.2.rst b/user_guide_src/source/changelogs/v4.1.2.rst index 572188e6ff94..c25cb11f32b7 100644 --- a/user_guide_src/source/changelogs/v4.1.2.rst +++ b/user_guide_src/source/changelogs/v4.1.2.rst @@ -64,6 +64,8 @@ Deprecations Bugs Fixed ---------- -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. - - ``BaseConnection::query()`` now returns ``false`` for failed queries (unless ``DBDebug==true``, in which case an exception will be thrown) and returns boolean values for write-type queries as specified in the docs. + +See the repo's +`CHANGELOG_4.1.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.1.3.rst b/user_guide_src/source/changelogs/v4.1.3.rst index 36eb4230d51b..73ae4a4a8380 100644 --- a/user_guide_src/source/changelogs/v4.1.3.rst +++ b/user_guide_src/source/changelogs/v4.1.3.rst @@ -30,3 +30,7 @@ Bugs Fixed - Fixed a bug where CLI mode was not detected under ``cgi-fcgi`` - Fixed a logic bug in Cookie construction - Fixed numerous issues in SQLite3's ``Forge`` class related to an incorrect attribute name + +See the repo's +`CHANGELOG_4.1.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.1.4.rst b/user_guide_src/source/changelogs/v4.1.4.rst index 08f83142a273..b3fad8dd8b53 100644 --- a/user_guide_src/source/changelogs/v4.1.4.rst +++ b/user_guide_src/source/changelogs/v4.1.4.rst @@ -57,3 +57,7 @@ BREAKING * ``CodeIgniter\Session\Handlers\FileHandler`` * ``CodeIgniter\Session\Handlers\MemcachedHandler`` * ``CodeIgniter\Session\Handlers\RedisHandler`` + +See the repo's +`CHANGELOG_4.1.md `_ +for a complete list of changes. diff --git a/user_guide_src/source/changelogs/v4.1.5.rst b/user_guide_src/source/changelogs/v4.1.5.rst index 960d29b8a4f9..02393424dacb 100644 --- a/user_guide_src/source/changelogs/v4.1.5.rst +++ b/user_guide_src/source/changelogs/v4.1.5.rst @@ -45,4 +45,6 @@ Deprecations Bugs Fixed ========== -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.1.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.1.6.rst b/user_guide_src/source/changelogs/v4.1.6.rst index 84e4f9f7d39e..14e43d0adc84 100644 --- a/user_guide_src/source/changelogs/v4.1.6.rst +++ b/user_guide_src/source/changelogs/v4.1.6.rst @@ -68,4 +68,6 @@ And the following methods are deprecated: Bugs Fixed ********** -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.1.md `_ +for a complete list of bugs fixed. diff --git a/user_guide_src/source/changelogs/v4.1.7.rst b/user_guide_src/source/changelogs/v4.1.7.rst index 5c9d07357858..592358514b09 100644 --- a/user_guide_src/source/changelogs/v4.1.7.rst +++ b/user_guide_src/source/changelogs/v4.1.7.rst @@ -32,4 +32,6 @@ none. Bugs Fixed ********** -See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. +See the repo's +`CHANGELOG_4.1.md `_ +for a complete list of bugs fixed. From 77467afaf62199ee0953ec3960547a10b1f47012 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 19 Jan 2023 17:07:02 +0900 Subject: [PATCH 068/290] docs: add versionadded --- user_guide_src/source/database/query_builder.rst | 8 ++++++++ user_guide_src/source/dbmgmt/forge.rst | 3 ++- user_guide_src/source/general/errors.rst | 4 ++++ user_guide_src/source/incoming/controllers.rst | 2 ++ user_guide_src/source/incoming/incomingrequest.rst | 2 +- user_guide_src/source/incoming/routing.rst | 8 ++++++++ user_guide_src/source/libraries/encryption.rst | 2 ++ 7 files changed, 27 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index a53ecc65415c..709e55838941 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -148,6 +148,8 @@ escaping of fields may break them. RawSql ^^^^^^ +.. versionadded:: 4.2.0 + Since v4.2.0, ``$builder->select()`` accepts a ``CodeIgniter\Database\RawSql`` instance, which expresses raw SQL strings. .. literalinclude:: query_builder/099.php @@ -265,6 +267,8 @@ outer``, and ``right outer``. RawSql ^^^^^^ +.. versionadded:: 4.2.0 + Since v4.2.0, ``$builder->join()`` accepts a ``CodeIgniter\Database\RawSql`` instance, which expresses raw SQL strings. .. literalinclude:: query_builder/102.php @@ -335,6 +339,8 @@ methods: 5. RawSql ^^^^^^^^^ + .. versionadded:: 4.2.0 + Since v4.2.0, ``$builder->where()`` accepts a ``CodeIgniter\Database\RawSql`` instance, which expresses raw SQL strings. .. literalinclude:: query_builder/100.php @@ -450,6 +456,8 @@ searches. 3. RawSql ^^^^^^^^^ + .. versionadded:: 4.2.0 + Since v4.2.0, ``$builder->like()`` accepts a ``CodeIgniter\Database\RawSql`` instance, which expresses raw SQL strings. .. literalinclude:: query_builder/101.php diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index ee5731d85064..3de1c8d4924c 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -122,8 +122,9 @@ The add fields method will accept the above array. Raw Sql Strings as Default Values --------------------------------- -Since v4.2.0, ``$forge->addField()`` accepts a ``CodeIgniter\Database\RawSql`` instance, which expresses raw SQL strings. +.. versionadded:: 4.2.0 +Since v4.2.0, ``$forge->addField()`` accepts a ``CodeIgniter\Database\RawSql`` instance, which expresses raw SQL strings. .. literalinclude:: forge/027.php diff --git a/user_guide_src/source/general/errors.rst b/user_guide_src/source/general/errors.rst index ee3c09e8c64a..c46aed6572ce 100644 --- a/user_guide_src/source/general/errors.rst +++ b/user_guide_src/source/general/errors.rst @@ -119,6 +119,8 @@ redirect code to use instead of the default (``302``, "temporary redirect"): Specify HTTP Status Code in Your Exception ========================================== +.. versionadded:: 4.3.0 + Since v4.3.0, you can specify the HTTP status code for your Exception class to implement ``HTTPExceptionInterface``. @@ -129,6 +131,8 @@ When an exception implementing ``HTTPExceptionInterface`` is caught by CodeIgnit Specify Exit Code in Your Exception =================================== +.. versionadded:: 4.3.0 + Since v4.3.0, you can specify the exit code for your Exception class to implement ``HasExitCodeInterface``. diff --git a/user_guide_src/source/incoming/controllers.rst b/user_guide_src/source/incoming/controllers.rst index cc9482384089..cd7023653b55 100644 --- a/user_guide_src/source/incoming/controllers.rst +++ b/user_guide_src/source/incoming/controllers.rst @@ -153,6 +153,8 @@ Auto-routing also will not work. Auto Routing (Improved) ************************ +.. versionadded:: 4.2.0 + Since v4.2.0, the new more secure Auto Routing has been introduced. .. note:: If you are familiar with Auto Routing, which was enabled by default diff --git a/user_guide_src/source/incoming/incomingrequest.rst b/user_guide_src/source/incoming/incomingrequest.rst index dbb5c664a734..163a0b46b68a 100644 --- a/user_guide_src/source/incoming/incomingrequest.rst +++ b/user_guide_src/source/incoming/incomingrequest.rst @@ -45,7 +45,7 @@ be checked with the ``isAJAX()`` and ``isCLI()`` methods: is() ==== - .. versionadded:: 4.3.0 +.. versionadded:: 4.3.0 Since v4.3.0, you can use the ``is()`` method. It returns boolean. diff --git a/user_guide_src/source/incoming/routing.rst b/user_guide_src/source/incoming/routing.rst index be01d92d3d51..9dbe274b0a0f 100644 --- a/user_guide_src/source/incoming/routing.rst +++ b/user_guide_src/source/incoming/routing.rst @@ -151,6 +151,8 @@ will only match **product/123** and generate 404 errors for other example. Array Callable Syntax ===================== +.. versionadded:: 4.2.0 + Since v4.2.0, you can use array callable syntax to specify the controller: .. literalinclude:: routing/013.php @@ -427,6 +429,8 @@ You may also supply arguments to be passed to the alias filter's ``before()`` an Classname Filter ^^^^^^^^^^^^^^^^ +.. versionadded:: 4.1.5 + You specify a filter classname for the filter value: .. literalinclude:: routing/036.php @@ -434,6 +438,8 @@ You specify a filter classname for the filter value: Multiple Filters ^^^^^^^^^^^^^^^^ +.. versionadded:: 4.1.5 + .. important:: *Multiple filters* is disabled by default. Because it breaks backward compatibility. If you want to use it, you need to configure. See :ref:`upgrade-415-multiple-filters-for-a-route` for the details. You specify an array for the filter value: @@ -604,6 +610,8 @@ For an example use of lowering the priority see :ref:`routing-priority`: Auto Routing (Improved) *********************** +.. versionadded:: 4.2.0 + Since v4.2.0, the new more secure Auto Routing has been introduced. .. note:: If you are familiar with Auto Routing, which was enabled by default diff --git a/user_guide_src/source/libraries/encryption.rst b/user_guide_src/source/libraries/encryption.rst index 15086cf69857..86fbbb32eb6f 100644 --- a/user_guide_src/source/libraries/encryption.rst +++ b/user_guide_src/source/libraries/encryption.rst @@ -84,6 +84,8 @@ an instance of the ``Config\Encryption`` class. Configuration to Maintain Compatibility with CI3 ------------------------------------------------ +.. versionadded:: 4.3.0 + Since v4.3.0, you can decrypt data encrypted with CI3's Encryption. If you need to decrypt such data, use the following settings to maintain compatibility. From ce8942456ae28e8f6f5768fb2dac587abc8bbb0c Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 21:33:18 +0900 Subject: [PATCH 069/290] docs: update PHPDoc --- system/Common.php | 4 ++-- system/Helpers/url_helper.php | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/system/Common.php b/system/Common.php index ab148e5d66d1..1b36545ee3f2 100644 --- a/system/Common.php +++ b/system/Common.php @@ -941,14 +941,14 @@ function response(): ResponseInterface if (! function_exists('route_to')) { /** - * Given a controller/method string and any params, + * Given a route name or controller/method string and any params, * will attempt to build the relative URL to the * matching route. * * NOTE: This requires the controller/method to * have a route defined in the routes Config file. * - * @param string $method Named route or Controller::method + * @param string $method Route name or Controller::method * @param int|string ...$params One or more parameters to be passed to the route. * The last parameter allows you to set the locale. * diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 45fd5ad110e6..45addcc1fb22 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -542,14 +542,15 @@ function mb_url_title(string $str, string $separator = '-', bool $lowercase = fa if (! function_exists('url_to')) { /** - * Get the full, absolute URL to a controller method + * Get the full, absolute URL to a route named or controller method * (with additional arguments) * * NOTE: This requires the controller/method to * have a route defined in the routes Config file. * - * @param string $controller Named route or Controller::method - * @param int|string ...$args One or more parameters to be passed to the route + * @param string $controller Route name or Controller::method + * @param int|string ...$args One or more parameters to be passed to the route. + * The last parameter allows you to set the locale. * * @throws RouterException */ From e91af1cfbe2bc450c5aaab2a7044f3096ed7e921 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 21:42:18 +0900 Subject: [PATCH 070/290] test: add test for url_to() with locale --- tests/system/Helpers/URLHelper/MiscUrlTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/system/Helpers/URLHelper/MiscUrlTest.php b/tests/system/Helpers/URLHelper/MiscUrlTest.php index fb949f2e9ecc..7f5d9667501a 100644 --- a/tests/system/Helpers/URLHelper/MiscUrlTest.php +++ b/tests/system/Helpers/URLHelper/MiscUrlTest.php @@ -884,4 +884,20 @@ public function urlToMissingRoutesProvider() ], ]; } + + public function testUrlToWithSupportedLocaleInRoute() + { + Services::createRequest(new App()); + $routes = service('routes'); + $routes->add( + '{locale}/path/(:segment)/to/(:num)', + 'myController::goto/$1/$2', + ['as' => 'path-to'] + ); + + $this->assertSame( + 'http://example.com/index.php/en/path/string/to/13', + url_to('path-to', 'string', 13, 'en') + ); + } } From e145c197c2ca932416b6072a8a5fd2b3bb83a5a5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 21:43:07 +0900 Subject: [PATCH 071/290] docs: update user guide --- user_guide_src/source/general/common_functions.rst | 8 +++++--- user_guide_src/source/helpers/url_helper.rst | 8 ++++++-- user_guide_src/source/helpers/url_helper/025.php | 13 +++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 user_guide_src/source/helpers/url_helper/025.php diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index 02cc8c5924a1..2c358b89fb51 100755 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -367,8 +367,10 @@ Miscellaneous Functions .. php:function:: route_to($method[, ...$params]) - :param string $method: The named route alias, or name of the controller/method to match. - :param int|string $params: One or more parameters to be passed to be matched in the route. The last parameter allows you to set the locale. + :param string $method: Route name or Controller::method + :param int|string ...$params: One or more parameters to be passed to the route. The last parameter allows you to set the locale. + :returns: a route (URI path) + :rtype: string .. note:: This function requires the controller/method to have a route defined in **app/Config/routes.php**. @@ -376,7 +378,7 @@ Miscellaneous Functions .. literalinclude:: common_functions/009.php - Generates a route for you based on a named route alias. + Generates a route for you based on a route name. .. literalinclude:: common_functions/010.php diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst index 8cb19251888d..7607610d64a5 100644 --- a/user_guide_src/source/helpers/url_helper.rst +++ b/user_guide_src/source/helpers/url_helper.rst @@ -361,8 +361,8 @@ The following functions are available: .. php:function:: url_to($controller[, ...$args]) - :param string $controller: Named route or Controller::method - :param mixed ...$args: One or more parameters to be passed to the route + :param string $controller: Route name or Controller::method + :param mixed ...$args: One or more parameters to be passed to the route. The last parameter allows you to set the locale. :returns: Absolute URL :rtype: string @@ -380,6 +380,10 @@ The following functions are available: This is useful because you can still change your routes after putting links into your views. + Since v4.3.0, when you use ``{locale}`` in your route, you can optionally specify the locale value as the last parameter. + + .. literalinclude:: url_helper/025.php + For full details, see the :ref:`reverse-routing` and :ref:`using-named-routes`. .. php:function:: url_is($path) diff --git a/user_guide_src/source/helpers/url_helper/025.php b/user_guide_src/source/helpers/url_helper/025.php new file mode 100644 index 000000000000..6cabfff15bc1 --- /dev/null +++ b/user_guide_src/source/helpers/url_helper/025.php @@ -0,0 +1,13 @@ +add( + '{locale}/users/(:num)/gallery/(:num)', + 'Galleries::showUserGallery/$1/$2', + ['as' => 'user_gallery'] +); + +?> + +View Gallery + From e9778bcae0205885482bfe68a08e2a321d603389 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 21:44:46 +0900 Subject: [PATCH 072/290] docs: fix sample code / was missing. (:any) matches multiple URI segments, so (:num) is better in this case. --- user_guide_src/source/general/common_functions/009.php | 2 +- user_guide_src/source/general/common_functions/010.php | 2 +- user_guide_src/source/general/common_functions/011.php | 2 +- user_guide_src/source/incoming/routing/029.php | 2 +- user_guide_src/source/incoming/routing/030.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/general/common_functions/009.php b/user_guide_src/source/general/common_functions/009.php index 41c725478d3f..5b8f7ff505d9 100644 --- a/user_guide_src/source/general/common_functions/009.php +++ b/user_guide_src/source/general/common_functions/009.php @@ -1,7 +1,7 @@ get('users/(:num)/gallery(:any)', 'Galleries::showUserGallery/$1/$2'); +$routes->get('users/(:num)/gallery/(:num)', 'Galleries::showUserGallery/$1/$2'); ?> diff --git a/user_guide_src/source/general/common_functions/010.php b/user_guide_src/source/general/common_functions/010.php index 82df6a7dd714..16280ab7b9a9 100644 --- a/user_guide_src/source/general/common_functions/010.php +++ b/user_guide_src/source/general/common_functions/010.php @@ -1,7 +1,7 @@ get('users/(:num)/gallery(:any)', 'Galleries::showUserGallery/$1/$2', ['as' => 'user_gallery']); +$routes->get('users/(:num)/gallery/(:num)', 'Galleries::showUserGallery/$1/$2', ['as' => 'user_gallery']); ?> diff --git a/user_guide_src/source/general/common_functions/011.php b/user_guide_src/source/general/common_functions/011.php index 3d354cec2533..0bea6d6d3293 100644 --- a/user_guide_src/source/general/common_functions/011.php +++ b/user_guide_src/source/general/common_functions/011.php @@ -2,7 +2,7 @@ // The route is defined as: $routes->add( - '{locale}/users/(:num)/gallery(:any)', + '{locale}/users/(:num)/gallery/(:num)', 'Galleries::showUserGallery/$1/$2', ['as' => 'user_gallery'] ); diff --git a/user_guide_src/source/incoming/routing/029.php b/user_guide_src/source/incoming/routing/029.php index 58a0e81e25f3..793a93588475 100644 --- a/user_guide_src/source/incoming/routing/029.php +++ b/user_guide_src/source/incoming/routing/029.php @@ -1,7 +1,7 @@ get('users/(:num)/gallery(:any)', 'Galleries::showUserGallery/$1/$2'); +$routes->get('users/(:num)/gallery/(:num)', 'Galleries::showUserGallery/$1/$2'); ?> diff --git a/user_guide_src/source/incoming/routing/030.php b/user_guide_src/source/incoming/routing/030.php index b17465e4f88b..e98bdef8e441 100644 --- a/user_guide_src/source/incoming/routing/030.php +++ b/user_guide_src/source/incoming/routing/030.php @@ -1,7 +1,7 @@ get('users/(:num)/gallery(:any)', 'Galleries::showUserGallery/$1/$2', ['as' => 'user_gallery']); +$routes->get('users/(:num)/gallery/(:num)', 'Galleries::showUserGallery/$1/$2', ['as' => 'user_gallery']); ?> From 6ed8314dd2ef185172f56e5bd3a1f581f1ff6601 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 21:46:09 +0900 Subject: [PATCH 073/290] docs: make a function name linkable --- user_guide_src/source/incoming/routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/incoming/routing.rst b/user_guide_src/source/incoming/routing.rst index 9dbe274b0a0f..efd3f82313db 100644 --- a/user_guide_src/source/incoming/routing.rst +++ b/user_guide_src/source/incoming/routing.rst @@ -316,7 +316,7 @@ Reverse routing allows you to define the controller and method, as well as any p to, and have the router lookup the current route to it. This allows route definitions to change without you having to update your application code. This is typically used within views to create links. -For example, if you have a route to a photo gallery that you want to link to, you can use the ``url_to()`` helper +For example, if you have a route to a photo gallery that you want to link to, you can use the :php:func:`url_to()` helper function to get the route that should be used. The first parameter is the fully qualified Controller and method, separated by a double colon (``::``), much like you would use when writing the initial route itself. Any parameters that should be passed to the route are passed in next: From e5a3bb936611b1c1e693a05d10f05ef806245026 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 11 Jan 2023 21:46:31 +0900 Subject: [PATCH 074/290] docs: fix function name --- user_guide_src/source/incoming/routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/incoming/routing.rst b/user_guide_src/source/incoming/routing.rst index efd3f82313db..fffa5cb1bdb8 100644 --- a/user_guide_src/source/incoming/routing.rst +++ b/user_guide_src/source/incoming/routing.rst @@ -329,7 +329,7 @@ Using Named Routes ================== You can name routes to make your application less fragile. This applies a name to a route that can be called -later, and even if the route definition changes, all of the links in your application built with ``route_to()`` +later, and even if the route definition changes, all of the links in your application built with :php:func:`url_to()` will still work without you having to make any changes. A route is named by passing in the ``as`` option with the name of the route: From c9552e4ef0dd9f96e765c3f108e2443f185a566e Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 14 Jan 2023 09:13:37 +0900 Subject: [PATCH 075/290] docs: make Note more prominent --- user_guide_src/source/general/common_functions.rst | 9 +++++---- user_guide_src/source/general/urls.rst | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index 2c358b89fb51..b63ee020d380 100755 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -374,6 +374,11 @@ Miscellaneous Functions .. note:: This function requires the controller/method to have a route defined in **app/Config/routes.php**. + .. important:: ``route_to()`` returns a *route*, not a full URI path for your site. + If your **baseURL** contains sub folders, the return value is not the same + as the URI to link. In that case, just use :php:func:`url_to()` instead. + See also :ref:`urls-url-structure`. + Generates a route for you based on a controller::method combination. Will take parameters into effect, if provided. .. literalinclude:: common_functions/009.php @@ -386,10 +391,6 @@ Miscellaneous Functions .. literalinclude:: common_functions/011.php - .. note:: ``route_to()`` returns a route, not a full URI path for your site. - If your **baseURL** contains sub folders, the return value is not the same - as the URI to link. In that case, just use :php:func:`url_to()` instead. - .. php:function:: service($name[, ...$params]) :param string $name: The name of the service to load diff --git a/user_guide_src/source/general/urls.rst b/user_guide_src/source/general/urls.rst index 25d7b577d977..965328ce817c 100644 --- a/user_guide_src/source/general/urls.rst +++ b/user_guide_src/source/general/urls.rst @@ -15,6 +15,8 @@ Your URLs can be defined using the :doc:`URI Routing ` featur The :doc:`URI Library <../libraries/uri>` and the :doc:`URL Helper <../helpers/url_helper>` contain functions that make it easy to work with your URI data. +.. _urls-url-structure: + URL Structure ============= From 56ef12181fcdd67b85081ec39128455c8a419216 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 20 Jan 2023 11:30:24 +0900 Subject: [PATCH 076/290] docs: replace SCRIPT_NAME with baseURL It is easier to understand. --- system/HTTP/IncomingRequest.php | 8 ++++---- system/HTTP/URI.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index ef69a08996f6..3304f4664a76 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -62,8 +62,8 @@ class IncomingRequest extends Request * * Note: This WILL NOT match the actual URL in the browser since for * everything this cares about (and the router, etc) is the portion - * AFTER the script name. So, if hosted in a sub-folder this will - * appear different than actual URL. If you need that use getPath(). + * AFTER the baseURL. So, if hosted in a sub-folder this will + * appear different than actual URI path. If you need that use getPath(). * * @deprecated Will be protected. Use getUri() instead. * @@ -72,7 +72,7 @@ class IncomingRequest extends Request public $uri; /** - * The detected path (relative to SCRIPT_NAME). + * The detected URI path (relative to the baseURL). * * Note: current_url() uses this to build its URI, * so this becomes the source for the "current URL" @@ -511,7 +511,7 @@ private function determineHost(App $config, string $baseURL): string } /** - * Returns the path relative to SCRIPT_NAME, + * Returns the URI path relative to baseURL, * running detection as necessary. */ public function getPath(): string diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index 23227e98d0f2..009bfdea0f1a 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -90,7 +90,7 @@ class URI * * Note: The constructor of the IncomingRequest class changes the path of * the URI object held by the IncomingRequest class to a path relative - * to the SCRIPT_NAME. If the baseURL contains subfolders, this value + * to the baseURL. If the baseURL contains subfolders, this value * will be different from the current URI path. * * @var string From c455f5e084eb4c5320c3bd725f522de848541dfd Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 20 Jan 2023 11:32:09 +0900 Subject: [PATCH 077/290] docs: add @return explanations --- system/Common.php | 2 +- system/Router/RouteCollection.php | 2 +- system/Router/RouteCollectionInterface.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/Common.php b/system/Common.php index 1b36545ee3f2..f73a4d4d78d8 100644 --- a/system/Common.php +++ b/system/Common.php @@ -952,7 +952,7 @@ function response(): ResponseInterface * @param int|string ...$params One or more parameters to be passed to the route. * The last parameter allows you to set the locale. * - * @return false|string + * @return false|string The route (URI path relative to baseURL) or false if not found. */ function route_to(string $method, ...$params) { diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 30be78a2bce5..9df41b0a8588 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1044,7 +1044,7 @@ public function environment(string $env, Closure $callback): RouteCollectionInte * @param int|string ...$params One or more parameters to be passed to the route. * The last parameter allows you to set the locale. * - * @return false|string + * @return false|string The route (URI path relative to baseURL) or false if not found. */ public function reverseRoute(string $search, ...$params) { diff --git a/system/Router/RouteCollectionInterface.php b/system/Router/RouteCollectionInterface.php index 7044459899c2..00ac88f4b7e2 100644 --- a/system/Router/RouteCollectionInterface.php +++ b/system/Router/RouteCollectionInterface.php @@ -172,7 +172,7 @@ public function getHTTPVerb(); * @param string $search Named route or Controller::method * @param int|string ...$params * - * @return false|string + * @return false|string The route (URI path relative to baseURL) or false if not found. */ public function reverseRoute(string $search, ...$params); From 76d53d631e57cb4f1623ffe05c7115ae2921addb Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 20 Jan 2023 11:32:54 +0900 Subject: [PATCH 078/290] docs: fix typo --- system/Helpers/url_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 45addcc1fb22..1a3b78de5c91 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -542,7 +542,7 @@ function mb_url_title(string $str, string $separator = '-', bool $lowercase = fa if (! function_exists('url_to')) { /** - * Get the full, absolute URL to a route named or controller method + * Get the full, absolute URL to a route name or controller method * (with additional arguments) * * NOTE: This requires the controller/method to From 243531150004820dd27cb8d0440228ad7de61614 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 20 Jan 2023 11:37:41 +0900 Subject: [PATCH 079/290] docs: replace SCRIPT_NAME with baseURL --- user_guide_src/source/incoming/incomingrequest.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/incoming/incomingrequest.rst b/user_guide_src/source/incoming/incomingrequest.rst index 163a0b46b68a..f54b1f9ff741 100644 --- a/user_guide_src/source/incoming/incomingrequest.rst +++ b/user_guide_src/source/incoming/incomingrequest.rst @@ -473,7 +473,7 @@ The methods provided by the parent classes that are available are: .. php:method:: getPath() - :returns: The current URI path relative to ``$_SERVER['SCRIPT_NAME']`` + :returns: The current URI path relative to baseURL :rtype: string This is the safest method to determine the "current URI", since ``IncomingRequest::$uri`` From af781c9dde78cfedfb4203c66c6a3dd52d8581d0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 20 Jan 2023 13:05:09 +0900 Subject: [PATCH 080/290] refactor: do not reassign --- system/HTTP/URI.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index 23227e98d0f2..b3ac598c2cde 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -1089,9 +1089,9 @@ protected function parseStr(string $query): array ), $query); $params = implode('&', $params); - parse_str($params, $params); + parse_str($params, $result); - foreach ($params as $key => $value) { + foreach ($result as $key => $value) { $return[hex2bin($key)] = $value; } From 7cdc8332d3cd44eba52bbb2fc7b00ae1fb8a4aba Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 20 Jan 2023 13:05:33 +0900 Subject: [PATCH 081/290] refactor: remove unnecessary assignment --- system/HTTP/URI.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index b3ac598c2cde..93500b58fb42 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -1095,8 +1095,6 @@ protected function parseStr(string $query): array $return[hex2bin($key)] = $value; } - $query = $params = null; - return $return; } } From 8a9b3c3b47857ff0aad6a0f1d123ad8597f8e186 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 20 Jan 2023 17:34:44 +0900 Subject: [PATCH 082/290] test: add tests --- tests/system/Database/Builder/WhereTest.php | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/system/Database/Builder/WhereTest.php b/tests/system/Database/Builder/WhereTest.php index a4b592ffd28c..b4a1b90a59f4 100644 --- a/tests/system/Database/Builder/WhereTest.php +++ b/tests/system/Database/Builder/WhereTest.php @@ -160,6 +160,53 @@ public function testWhereCustomString() $this->assertSame($expectedBinds, $builder->getBinds()); } + public function testWhereCustomStringWithOperatorEscapeFalse() + { + $builder = $this->db->table('jobs'); + + $where = 'CURRENT_TIMESTAMP() = DATE_ADD(column, INTERVAL 2 HOUR)'; + $builder->where($where, null, false); + + $expectedSQL = 'SELECT * FROM "jobs" WHERE CURRENT_TIMESTAMP() = DATE_ADD(column, INTERVAL 2 HOUR)'; + $this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect())); + + $expectedBinds = []; + $this->assertSame($expectedBinds, $builder->getBinds()); + } + + public function testWhereCustomStringWithoutOperatorEscapeFalse() + { + $builder = $this->db->table('jobs'); + + $where = "REPLACE(column, 'somestring', '')"; + $builder->where($where, "''", false); + + $expectedSQL = "SELECT * FROM \"jobs\" WHERE REPLACE(column, 'somestring', '') = ''"; + $this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect())); + + $expectedBinds = [ + "REPLACE(column, 'somestring', '')" => [ + 0 => "''", + 1 => false, + ], + ]; + $this->assertSame($expectedBinds, $builder->getBinds()); + } + + public function testWhereCustomStringWithBetweenEscapeFalse() + { + $builder = $this->db->table('jobs'); + + $where = "created_on BETWEEN '2022-07-01 00:00:00' AND '2022-12-31 23:59:59'"; + $builder->where($where, null, false); + + $expectedSQL = "SELECT * FROM \"jobs\" WHERE created_on BETWEEN '2022-07-01 00:00:00' AND '2022-12-31 23:59:59'"; + $this->assertSame($expectedSQL, str_replace("\n", ' ', $builder->getCompiledSelect())); + + $expectedBinds = []; + $this->assertSame($expectedBinds, $builder->getBinds()); + } + public function testWhereRawSql() { $builder = $this->db->table('jobs'); From aed3ad65c47e3a94cca1d045ede77dea22a2905b Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 20 Jan 2023 18:57:18 +0900 Subject: [PATCH 083/290] style: break long line --- system/Database/BaseBuilder.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index a7aabc7b97c8..a96bbc6c862b 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -783,7 +783,15 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type } elseif (! $this->hasOperator($k) && $qbKey !== 'QBHaving') { // value appears not to have been set, assign the test to IS NULL $op = ' IS NULL'; - } elseif (preg_match('/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE)) { + } elseif ( + // The key ends with !=, =, <>, IS, IS NOT + preg_match( + '/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i', + $k, + $match, + PREG_OFFSET_CAPTURE + ) + ) { $k = substr($k, 0, $match[0][1]); $op = $match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL'; } else { From d333c7bd54f7e1e0aa00ce8b2294597c88970315 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 20 Jan 2023 18:57:45 +0900 Subject: [PATCH 084/290] docs: add comment --- system/Database/BaseBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index a96bbc6c862b..4e483a6119b1 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -761,9 +761,9 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type $k = trim($k); end($op); - $op = trim(current($op)); + // Does the key end with operator? if (substr($k, -strlen($op)) === $op) { $k = rtrim(substr($k, 0, -strlen($op))); $op = " {$op}"; From 6ecbc309f087278c8ce310cc0ed847078b10d87c Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 20 Jan 2023 19:02:25 +0900 Subject: [PATCH 085/290] fix: BaseBuilder::getOperatorFromWhereKey() misses operator EXISTS, BETWEEN --- system/Database/BaseBuilder.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 4e483a6119b1..727637c3c0b3 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -3413,13 +3413,17 @@ private function getOperatorFromWhereKey(string $whereKey) $whereKey = trim($whereKey); $pregOperators = [ - '\s*(?:<|>|!)?=', // =, <=, >=, != - '\s*<>?', // <, <> - '\s*>', // > - '\s+IS NULL', // IS NULL - '\s+IS NOT NULL', // IS NOT NULL - '\s+LIKE', // LIKE - '\s+NOT LIKE', // NOT LIKE + '\s*(?:<|>|!)?=', // =, <=, >=, != + '\s*<>?', // <, <> + '\s*>', // > + '\s+IS NULL', // IS NULL + '\s+IS NOT NULL', // IS NOT NULL + '\s+EXISTS\s*\(.*\)', // EXISTS (sql) + '\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS (sql) + '\s+BETWEEN\s+', // BETWEEN value AND value + '\s+IN\s*\(.*\)', // IN (list) + '\s+LIKE', // LIKE + '\s+NOT LIKE', // NOT LIKE ]; return preg_match_all( From bc2d692dd91f1abd09c639cd69d261547479e4b9 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Jan 2023 08:48:49 +0900 Subject: [PATCH 086/290] docs: align comments --- system/Database/BaseBuilder.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 727637c3c0b3..f6fd1daff6cc 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -3381,16 +3381,16 @@ protected function getOperator(string $str, bool $list = false) : ''; $this->pregOperators = [ '\s*(?:<|>|!)?=\s*', // =, <=, >=, != - '\s*<>?\s*', // <, <> - '\s*>\s*', // > - '\s+IS NULL', // IS NULL - '\s+IS NOT NULL', // IS NOT NULL - '\s+EXISTS\s*\(.*\)', // EXISTS(sql) + '\s*<>?\s*', // <, <> + '\s*>\s*', // >å + '\s+IS NULL', // IS NULL + '\s+IS NOT NULL', // IS NOT NULL + '\s+EXISTS\s*\(.*\)', // EXISTS (sql) '\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS(sql) - '\s+BETWEEN\s+', // BETWEEN value AND value - '\s+IN\s*\(.*\)', // IN(list) - '\s+NOT IN\s*\(.*\)', // NOT IN (list) - '\s+LIKE\s+\S.*(' . $_les . ')?', // LIKE 'expr'[ ESCAPE '%s'] + '\s+BETWEEN\s+', // BETWEEN value AND value + '\s+IN\s*\(.*\)', // IN (list) + '\s+NOT IN\s*\(.*\)', // NOT IN (list) + '\s+LIKE\s+\S.*(' . $_les . ')?', // LIKE 'expr'[ ESCAPE '%s'] '\s+NOT LIKE\s+\S.*(' . $_les . ')?', // NOT LIKE 'expr'[ ESCAPE '%s'] ]; } From 83f026d3cd0c1948c86d5325690f9ecb9190f8d5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Jan 2023 09:30:46 +0900 Subject: [PATCH 087/290] test: add test --- tests/system/View/ParserFilterTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/system/View/ParserFilterTest.php b/tests/system/View/ParserFilterTest.php index 696a16d2a19a..063c97acd972 100644 --- a/tests/system/View/ParserFilterTest.php +++ b/tests/system/View/ParserFilterTest.php @@ -396,6 +396,20 @@ public function testLocalCurrency() $this->assertSame("1.234.567,89\u{a0}€", $parser->renderString($template)); } + public function testLocalCurrencyWithoutFraction() + { + $parser = new Parser($this->config, $this->viewsDir, $this->loader); + + $data = [ + 'mynum' => 1_234_567.8912346, + ]; + + $template = '{ mynum|local_currency(EUR,de_DE) }'; + + $parser->setData($data); + $this->assertSame("1.234.568\u{a0}€", $parser->renderString($template)); + } + public function testParsePairWithAbs() { $parser = new Parser($this->config, $this->viewsDir, $this->loader); From 309ec2f6006a75f296cc71c1f8b854eccb9655ac Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Jan 2023 09:31:17 +0900 Subject: [PATCH 088/290] fix: Passing null to parameter error ErrorException: NumberFormatter::setAttribute(): Passing null to parameter #2 ($value) of type int|float is deprecated --- system/View/Filters.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/View/Filters.php b/system/View/Filters.php index 336a0d08a67c..65dfe6dff943 100644 --- a/system/View/Filters.php +++ b/system/View/Filters.php @@ -171,6 +171,8 @@ public static function local_currency($value, string $currency, ?string $locale { helper('number'); + $fraction ??= 0; + $options = [ 'type' => NumberFormatter::CURRENCY, 'currency' => $currency, From 49e7c040ca90acb53f58227228af3a58439a8357 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Jan 2023 09:38:43 +0900 Subject: [PATCH 089/290] docs: fix docs --- user_guide_src/source/outgoing/view_parser.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/outgoing/view_parser.rst b/user_guide_src/source/outgoing/view_parser.rst index b6083ba7054e..206cebdd2698 100644 --- a/user_guide_src/source/outgoing/view_parser.rst +++ b/user_guide_src/source/outgoing/view_parser.rst @@ -389,8 +389,9 @@ limit_chars limit Limits the number of characters to $limit. limit_words limit Limits the number of words to $limit. { v|limit_words(20) } -local_currency currency, locale Displays a localized version of a currency. "currency" { v|local_currency(EUR,en_US) } - valueis any 3-letter ISO 4217 currency code. +local_currency currency, Displays a localized version of a currency. "currency" { v|local_currency(EUR,en_US) } + locale, valueis any 3-letter ISO 4217 currency code. + fraction local_number type, precision, Displays a localized version of a number. "type" can be { v|local_number(decimal,2,en_US) } locale one of: decimal, currency, percent, scientific, spellout, From 27cc9c9bbd8c6c72b77aeee3425f09fbf16787eb Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Jan 2023 13:08:43 +0900 Subject: [PATCH 090/290] docs: update Controller code --- user_guide_src/source/outgoing/views/002.php | 4 +--- user_guide_src/source/outgoing/views/009.php | 4 +--- user_guide_src/source/outgoing/views/011.php | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/user_guide_src/source/outgoing/views/002.php b/user_guide_src/source/outgoing/views/002.php index dda8dc67f363..bb44fed77919 100644 --- a/user_guide_src/source/outgoing/views/002.php +++ b/user_guide_src/source/outgoing/views/002.php @@ -2,9 +2,7 @@ namespace App\Controllers; -use CodeIgniter\Controller; - -class Blog extends Controller +class Blog extends BaseController { public function index() { diff --git a/user_guide_src/source/outgoing/views/009.php b/user_guide_src/source/outgoing/views/009.php index 008d1cf85d26..3cb2e017aad9 100644 --- a/user_guide_src/source/outgoing/views/009.php +++ b/user_guide_src/source/outgoing/views/009.php @@ -2,9 +2,7 @@ namespace App\Controllers; -use CodeIgniter\Controller; - -class Blog extends Controller +class Blog extends BaseController { public function index() { diff --git a/user_guide_src/source/outgoing/views/011.php b/user_guide_src/source/outgoing/views/011.php index bb1a5fc21725..a74b670c3e49 100644 --- a/user_guide_src/source/outgoing/views/011.php +++ b/user_guide_src/source/outgoing/views/011.php @@ -2,9 +2,7 @@ namespace App\Controllers; -use CodeIgniter\Controller; - -class Blog extends Controller +class Blog extends BaseController { public function index() { From 55b610dfcbc87d1ed0d814056c2200f693e0f9d3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Jan 2023 13:09:07 +0900 Subject: [PATCH 091/290] docs: fix header level in HTML sample --- user_guide_src/source/outgoing/views/012.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/outgoing/views/012.php b/user_guide_src/source/outgoing/views/012.php index 5a3781fe6720..509b548a1813 100644 --- a/user_guide_src/source/outgoing/views/012.php +++ b/user_guide_src/source/outgoing/views/012.php @@ -5,7 +5,7 @@

-

My Todo List

+

My Todo List

    From 24e82dc635d2a05a2bc31d899a211b62312b5c66 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Jan 2023 13:10:33 +0900 Subject: [PATCH 092/290] docs: fix text decoration --- user_guide_src/source/outgoing/views.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/outgoing/views.rst b/user_guide_src/source/outgoing/views.rst index 3eb80427fc2a..342223bee842 100644 --- a/user_guide_src/source/outgoing/views.rst +++ b/user_guide_src/source/outgoing/views.rst @@ -19,7 +19,7 @@ Using the example controller you created in the controller page, let's add a vie Creating a View =============== -Using your text editor, create a file called ``blog_view.php`` and put this in it:: +Using your text editor, create a file called **blog_view.php** and put this in it:: @@ -136,7 +136,7 @@ into the ``$option`` array in the third parameter. .. literalinclude:: views/010.php Additionally, if you would like the default functionality of the ``view()`` function to be that it does clear the data -between calls, you can set ``$saveData`` to **false** in **app/Config/Views.php**. +between calls, you can set ``$saveData`` to ``false`` in **app/Config/Views.php**. Creating Loops ============== From 5e762b43b30717e96a87f0256970fd185db3e822 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Jan 2023 13:11:20 +0900 Subject: [PATCH 093/290] docs: update views.rst content --- user_guide_src/source/outgoing/views.rst | 33 +++++++++++++++----- user_guide_src/source/outgoing/views/013.php | 5 +++ 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 user_guide_src/source/outgoing/views/013.php diff --git a/user_guide_src/source/outgoing/views.rst b/user_guide_src/source/outgoing/views.rst index 342223bee842..70bbadcc7504 100644 --- a/user_guide_src/source/outgoing/views.rst +++ b/user_guide_src/source/outgoing/views.rst @@ -10,7 +10,9 @@ A view is simply a web page, or a page fragment, like a header, footer, sidebar, views can flexibly be embedded within other views (within other views, etc.) if you need this type of hierarchy. -Views are never called directly, they must be loaded by a controller. Remember that in an MVC framework, +Views are never called directly, they must be loaded by a controller or :ref:`view route `. + +Remember that in an MVC framework, the Controller acts as the traffic cop, so it is responsible for fetching a particular view. If you have not read the :doc:`Controllers ` page, you should do so before continuing. @@ -35,19 +37,27 @@ Then save the file in your **app/Views** directory. Displaying a View ================= -To load and display a particular view file you will use the following function: +To load and display a particular view file you will use the following code in your controller: .. literalinclude:: views/001.php + :lines: 2- Where *name* is the name of your view file. -.. important:: If the file extension is omitted, then the views are expected to end with the .php extension. +.. important:: If the file extension is omitted, then the views are expected to end with the **.php** extension. -Now, open the controller file you made earlier called ``Blog.php``, and replace the echo statement with the view function: +Now, create a file called **Blog.php** in the **app/Controllers** directory, +and put this in it: .. literalinclude:: views/002.php -If you visit your site using the URL you did earlier you should see your new view. The URL was similar to this:: +Open the routing file located at **app/Config/Routes.php**, and look for the "Route Definitions". +Add the following code: + +.. literalinclude:: views/013.php + :lines: 2- + +If you visit your site, you should see your new view. The URL was similar to this:: example.com/index.php/blog/ @@ -69,6 +79,7 @@ Your view files can also be stored within sub-directories if you prefer that typ When doing so you will need to include the directory name loading the view. Example: .. literalinclude:: views/004.php + :lines: 2- Namespaced Views ================ @@ -77,8 +88,10 @@ You can store views under a **View** directory that is namespaced, and load that PHP does not support loading non-class files from a namespace, CodeIgniter provides this feature to make it possible to package your views together in a module-like fashion for easy re-use or distribution. -If you have ``example/blog`` directory that has a PSR-4 mapping set up in the :doc:`Autoloader ` living -under the namespace ``Example\Blog``, you could retrieve view files as if they were namespaced also. Following this +If you have **example/blog** directory that has a PSR-4 mapping set up in the :doc:`Autoloader ` living +under the namespace ``Example\Blog``, you could retrieve view files as if they were namespaced also. + +Following this example, you could load the **blog_view.php** file from **example/blog/Views** by prepending the namespace to the view name: .. literalinclude:: views/005.php @@ -88,15 +101,17 @@ example, you could load the **blog_view.php** file from **example/blog/Views** b Caching Views ============= -You can cache a view with the ``view`` command by passing a ``cache`` option with the number of seconds to cache +You can cache a view with the ``view()`` function by passing a ``cache`` option with the number of seconds to cache the view for, in the third parameter: .. literalinclude:: views/006.php + :lines: 2- By default, the view will be cached using the same name as the view file itself. You can customize this by passing along ``cache_name`` and the cache ID you wish to use: .. literalinclude:: views/007.php + :lines: 2- Adding Dynamic Data to the View =============================== @@ -105,6 +120,7 @@ Data is passed from the controller to the view by way of an array in the second Here's an example: .. literalinclude:: views/008.php + :lines: 2- Let's try it with your controller file. Open it and add this code: @@ -134,6 +150,7 @@ other views, potentially causing issues. If you would prefer to clean the data a into the ``$option`` array in the third parameter. .. literalinclude:: views/010.php + :lines: 2- Additionally, if you would like the default functionality of the ``view()`` function to be that it does clear the data between calls, you can set ``$saveData`` to ``false`` in **app/Config/Views.php**. diff --git a/user_guide_src/source/outgoing/views/013.php b/user_guide_src/source/outgoing/views/013.php new file mode 100644 index 000000000000..2868ed564dba --- /dev/null +++ b/user_guide_src/source/outgoing/views/013.php @@ -0,0 +1,5 @@ +get('blog', [Blog::class, 'index']); From ff10390204b7287136fc8649184d7024fdc505c4 Mon Sep 17 00:00:00 2001 From: Christian Rumpf Date: Sat, 21 Jan 2023 18:35:09 +0100 Subject: [PATCH 094/290] Throttler::tokenTime fix, use cases --- system/Throttle/Throttler.php | 2 +- tests/system/Throttle/ThrottleTest.php | 132 +++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 1 deletion(-) diff --git a/system/Throttle/Throttler.php b/system/Throttle/Throttler.php index bdca42ed8e9f..dc0844fa4cb8 100644 --- a/system/Throttle/Throttler.php +++ b/system/Throttle/Throttler.php @@ -139,7 +139,7 @@ public function check(string $key, int $capacity, int $seconds, int $cost = 1): // How many seconds till a new token is available. // We must have a minimum wait of 1 second for a new token. // Primarily stored to allow devs to report back to users. - $newTokenAvailable = (int) ($refresh - $elapsed - $refresh * $tokens); + $newTokenAvailable = (int) round((1 - $tokens) * $refresh); $this->tokenTime = max(1, $newTokenAvailable); return false; diff --git a/tests/system/Throttle/ThrottleTest.php b/tests/system/Throttle/ThrottleTest.php index 4bff58c01f51..2cfa9680b552 100644 --- a/tests/system/Throttle/ThrottleTest.php +++ b/tests/system/Throttle/ThrottleTest.php @@ -187,4 +187,136 @@ public function testFlooding() $this->assertTrue($throttler->check('127.0.0.1', $rate, MINUTE, 0)); $this->assertSame(10.0, round($this->cache->get('throttler_127.0.0.1'))); } + + /** + * @dataProvider tokenTimeUsecases + */ + public function testTokenTimeCalculationUCs(int $capacity, int $seconds, array $checkInputs): void { + $key = 'testkey'; + $throttler = new Throttler($this->cache); + + // clear $key before test start + $throttler->remove($key); + + foreach ($checkInputs as $index => $checkInput) { + $throttler->setTestTime($checkInput['testTime']); + $checkResult = $throttler->check($key, $capacity, $seconds, $checkInput['cost']); + + $this->assertEquals($checkInput['expectedCheckResult'], $checkResult, "Input#$index: Wrong check() result"); + $this->assertEquals($checkInput['expectedTokenTime'], $throttler->getTokenTime(), "Input#$index: Wrong tokenTime"); + } + } + + public function tokenTimeUsecases(): array { + return [ + '2 capacity / 200 seconds (100s refresh, 0.01 tokens/s) -> 5 checks, 1 cost each' => [ + 'capacity' => 2, + 'seconds' => 200, + 'checkInputs' => [ + [ // 2 -> 1 + 'testTime' => 0, + 'cost' => 1, + 'expectedCheckResult' => true, + 'expectedTokenTime' => 0 + ], + [ // +3s / 1.03 -> 0.03 + 'testTime' => 3, + 'cost' => 1, + 'expectedCheckResult' => true, + 'expectedTokenTime' => 0 + ], + [ // +0s / 0.03 -> 0.03 / (1 - 0.03) * 100 = 97 + 'testTime' => 3, + 'cost' => 1, + 'expectedCheckResult' => false, + 'expectedTokenTime' => 97 + ], + [ // +1m 32s / 0.95 -> 0.95 / (1 - 0.95) * 100 = 5 + 'testTime' => 95, + 'cost' => 1, + 'expectedCheckResult' => false, + 'expectedTokenTime' => 5 + ], + [ // +7s / 1.02 -> 0.02 + 'testTime' => 102, + 'cost' => 1, + 'expectedCheckResult' => true, + 'expectedTokenTime' => 0 + ], + [ // +13s / 0.15 / (1 - 0.15) * 100 = 85 + 'testTime' => 115, + 'cost' => 1, + 'expectedCheckResult' => false, + 'expectedTokenTime' => 85 + ] + ] + ], + '1 capacity / 3600 seconds (3600s refresh, 2.77e-4 tokens/s) -> 2 checks with 1 cost each' => [ + 'capacity' => 1, + 'seconds' => 3600, + 'checkInputs' => [ + [ // 1 -> 0 + 'testTime' => 0, + 'cost' => 1, + 'expectedCheckResult' => true, + 'expectedTokenTime' => 0 + ], + [ // +6m / 0.1 -> 0.1 / (1 - 0.1) * 3600 = 3240 + 'testTime' => 360, + 'cost' => 1, + 'expectedCheckResult' => false, + 'expectedTokenTime' => 3240 + ] + ] + ], + '10 capacity / 200 seconds (20s refresh, 0.05 tokens/s) -> 7 checks with different costs (RNG)' => [ + 'capacity' => 10, + 'seconds' => 200, + 'checkInputs' => [ + [ // -2t / 10 -> 8 + 'testTime' => 0, + 'cost' => 2, + 'expectedCheckResult' => true, + 'expectedTokenTime' => 0 + ], + [ // +19s -2t / 8.95 -> 6.95 + 'testTime' => 19, + 'cost' => 2, + 'expectedCheckResult' => true, + 'expectedTokenTime' => 0 + ], + [ // +16s -3t / 7.75 -> 4.75 + 'testTime' => 35, + 'cost' => 3, + 'expectedCheckResult' => true, + 'expectedTokenTime' => 0 + ], + [ // +4s -2t / 4.95 -> 2.95 + 'testTime' => 39, + 'cost' => 2, + 'expectedCheckResult' => true, + 'expectedTokenTime' => 0 + ], + [ // +13s -5t / 3.6 -> -1.4 (blow allowed) + 'testTime' => 52, + 'cost' => 5, + 'expectedCheckResult' => true, + 'expectedTokenTime' => 0 + ], + [ // +2s -2t / -1.3 -> -1.3 / (1 - (-1.3)) * 20 = 46 + 'testTime' => 54, + 'cost' => 2, + 'expectedCheckResult' => false, + 'expectedTokenTime' => 46 + ], + [ // +7s -2t / -0.95 - -0.95 / (1 - (-0.95)) * 20 = 39 + 'testTime' => 61, + 'cost' => 2, + 'expectedCheckResult' => false, + 'expectedTokenTime' => 39 + ] + ] + ] + ]; + } } From 55626fc140c9e896d5ea4dc60896dab36ee9a9d7 Mon Sep 17 00:00:00 2001 From: Christian Rumpf Date: Sat, 21 Jan 2023 19:06:49 +0100 Subject: [PATCH 095/290] Fixing coding standard --- tests/system/Throttle/ThrottleTest.php | 126 +++++++++++++------------ 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/tests/system/Throttle/ThrottleTest.php b/tests/system/Throttle/ThrottleTest.php index 2cfa9680b552..c9256a6cf28a 100644 --- a/tests/system/Throttle/ThrottleTest.php +++ b/tests/system/Throttle/ThrottleTest.php @@ -191,7 +191,8 @@ public function testFlooding() /** * @dataProvider tokenTimeUsecases */ - public function testTokenTimeCalculationUCs(int $capacity, int $seconds, array $checkInputs): void { + public function testTokenTimeCalculationUCs(int $capacity, int $seconds, array $checkInputs): void + { $key = 'testkey'; $throttler = new Throttler($this->cache); @@ -202,121 +203,122 @@ public function testTokenTimeCalculationUCs(int $capacity, int $seconds, array $ $throttler->setTestTime($checkInput['testTime']); $checkResult = $throttler->check($key, $capacity, $seconds, $checkInput['cost']); - $this->assertEquals($checkInput['expectedCheckResult'], $checkResult, "Input#$index: Wrong check() result"); - $this->assertEquals($checkInput['expectedTokenTime'], $throttler->getTokenTime(), "Input#$index: Wrong tokenTime"); + $this->assertEquals($checkInput['expectedCheckResult'], $checkResult, "Input#{$index}: Wrong check() result"); + $this->assertEquals($checkInput['expectedTokenTime'], $throttler->getTokenTime(), "Input#{$index}: Wrong tokenTime"); } } - public function tokenTimeUsecases(): array { + public function tokenTimeUsecases(): array + { return [ '2 capacity / 200 seconds (100s refresh, 0.01 tokens/s) -> 5 checks, 1 cost each' => [ - 'capacity' => 2, - 'seconds' => 200, + 'capacity' => 2, + 'seconds' => 200, 'checkInputs' => [ [ // 2 -> 1 - 'testTime' => 0, - 'cost' => 1, + 'testTime' => 0, + 'cost' => 1, 'expectedCheckResult' => true, - 'expectedTokenTime' => 0 + 'expectedTokenTime' => 0, ], [ // +3s / 1.03 -> 0.03 - 'testTime' => 3, - 'cost' => 1, + 'testTime' => 3, + 'cost' => 1, 'expectedCheckResult' => true, - 'expectedTokenTime' => 0 + 'expectedTokenTime' => 0, ], [ // +0s / 0.03 -> 0.03 / (1 - 0.03) * 100 = 97 - 'testTime' => 3, - 'cost' => 1, + 'testTime' => 3, + 'cost' => 1, 'expectedCheckResult' => false, - 'expectedTokenTime' => 97 + 'expectedTokenTime' => 97, ], [ // +1m 32s / 0.95 -> 0.95 / (1 - 0.95) * 100 = 5 - 'testTime' => 95, - 'cost' => 1, + 'testTime' => 95, + 'cost' => 1, 'expectedCheckResult' => false, - 'expectedTokenTime' => 5 + 'expectedTokenTime' => 5, ], [ // +7s / 1.02 -> 0.02 - 'testTime' => 102, - 'cost' => 1, + 'testTime' => 102, + 'cost' => 1, 'expectedCheckResult' => true, - 'expectedTokenTime' => 0 + 'expectedTokenTime' => 0, ], [ // +13s / 0.15 / (1 - 0.15) * 100 = 85 - 'testTime' => 115, - 'cost' => 1, + 'testTime' => 115, + 'cost' => 1, 'expectedCheckResult' => false, - 'expectedTokenTime' => 85 - ] - ] + 'expectedTokenTime' => 85, + ], + ], ], '1 capacity / 3600 seconds (3600s refresh, 2.77e-4 tokens/s) -> 2 checks with 1 cost each' => [ - 'capacity' => 1, - 'seconds' => 3600, + 'capacity' => 1, + 'seconds' => 3600, 'checkInputs' => [ [ // 1 -> 0 - 'testTime' => 0, - 'cost' => 1, + 'testTime' => 0, + 'cost' => 1, 'expectedCheckResult' => true, - 'expectedTokenTime' => 0 + 'expectedTokenTime' => 0, ], [ // +6m / 0.1 -> 0.1 / (1 - 0.1) * 3600 = 3240 - 'testTime' => 360, - 'cost' => 1, + 'testTime' => 360, + 'cost' => 1, 'expectedCheckResult' => false, - 'expectedTokenTime' => 3240 - ] - ] + 'expectedTokenTime' => 3240, + ], + ], ], '10 capacity / 200 seconds (20s refresh, 0.05 tokens/s) -> 7 checks with different costs (RNG)' => [ - 'capacity' => 10, - 'seconds' => 200, + 'capacity' => 10, + 'seconds' => 200, 'checkInputs' => [ [ // -2t / 10 -> 8 - 'testTime' => 0, - 'cost' => 2, + 'testTime' => 0, + 'cost' => 2, 'expectedCheckResult' => true, - 'expectedTokenTime' => 0 + 'expectedTokenTime' => 0, ], [ // +19s -2t / 8.95 -> 6.95 - 'testTime' => 19, - 'cost' => 2, + 'testTime' => 19, + 'cost' => 2, 'expectedCheckResult' => true, - 'expectedTokenTime' => 0 + 'expectedTokenTime' => 0, ], [ // +16s -3t / 7.75 -> 4.75 - 'testTime' => 35, - 'cost' => 3, + 'testTime' => 35, + 'cost' => 3, 'expectedCheckResult' => true, - 'expectedTokenTime' => 0 + 'expectedTokenTime' => 0, ], [ // +4s -2t / 4.95 -> 2.95 - 'testTime' => 39, - 'cost' => 2, + 'testTime' => 39, + 'cost' => 2, 'expectedCheckResult' => true, - 'expectedTokenTime' => 0 + 'expectedTokenTime' => 0, ], [ // +13s -5t / 3.6 -> -1.4 (blow allowed) - 'testTime' => 52, - 'cost' => 5, + 'testTime' => 52, + 'cost' => 5, 'expectedCheckResult' => true, - 'expectedTokenTime' => 0 + 'expectedTokenTime' => 0, ], [ // +2s -2t / -1.3 -> -1.3 / (1 - (-1.3)) * 20 = 46 - 'testTime' => 54, - 'cost' => 2, + 'testTime' => 54, + 'cost' => 2, 'expectedCheckResult' => false, - 'expectedTokenTime' => 46 + 'expectedTokenTime' => 46, ], [ // +7s -2t / -0.95 - -0.95 / (1 - (-0.95)) * 20 = 39 - 'testTime' => 61, - 'cost' => 2, + 'testTime' => 61, + 'cost' => 2, 'expectedCheckResult' => false, - 'expectedTokenTime' => 39 - ] - ] - ] + 'expectedTokenTime' => 39, + ], + ], + ], ]; } } From 30df4501e7b9b85bc68fd8098f5678755d962e90 Mon Sep 17 00:00:00 2001 From: Christian Rumpf Date: Sat, 21 Jan 2023 19:39:35 +0100 Subject: [PATCH 096/290] More CS fixes --- tests/system/Throttle/ThrottleTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/system/Throttle/ThrottleTest.php b/tests/system/Throttle/ThrottleTest.php index c9256a6cf28a..2121636baefa 100644 --- a/tests/system/Throttle/ThrottleTest.php +++ b/tests/system/Throttle/ThrottleTest.php @@ -193,7 +193,7 @@ public function testFlooding() */ public function testTokenTimeCalculationUCs(int $capacity, int $seconds, array $checkInputs): void { - $key = 'testkey'; + $key = 'testkey'; $throttler = new Throttler($this->cache); // clear $key before test start @@ -203,8 +203,8 @@ public function testTokenTimeCalculationUCs(int $capacity, int $seconds, array $ $throttler->setTestTime($checkInput['testTime']); $checkResult = $throttler->check($key, $capacity, $seconds, $checkInput['cost']); - $this->assertEquals($checkInput['expectedCheckResult'], $checkResult, "Input#{$index}: Wrong check() result"); - $this->assertEquals($checkInput['expectedTokenTime'], $throttler->getTokenTime(), "Input#{$index}: Wrong tokenTime"); + $this->assertSame($checkInput['expectedCheckResult'], $checkResult, "Input#{$index}: Wrong check() result"); + $this->assertSame($checkInput['expectedTokenTime'], $throttler->getTokenTime(), "Input#{$index}: Wrong tokenTime"); } } From 7f9e28e8848d8a53d6782a40d2dca2ef4741043d Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 22 Jan 2023 11:27:06 +0900 Subject: [PATCH 097/290] chore: update version in API docs --- phpdoc.dist.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml index 157b02055990..b64ce2899051 100644 --- a/phpdoc.dist.xml +++ b/phpdoc.dist.xml @@ -5,12 +5,12 @@ xmlns="https://www.phpdoc.org" xsi:noNamespaceSchemaLocation="https://docs.phpdoc.org/latest/phpdoc.xsd" > - CodeIgniter v4.0.0 API + CodeIgniter v4.3 API api/build/ api/cache/ - + system From 33aa7f08d31b0d3e1fe7ffa55d83d0fc1b2ff0e2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 22 Jan 2023 17:23:15 +0900 Subject: [PATCH 098/290] docs: reorganize sections --- user_guide_src/source/dbmgmt/forge.rst | 35 ++++++++++++++++---------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index 3de1c8d4924c..93143ee1d244 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -77,9 +77,9 @@ for the file where the database will be created using the ``--ext`` option. Vali produce a success message but no database file is created. This is because SQLite3 will just use an in-memory database. -**************************** -Creating and Dropping Tables -**************************** +*************** +Creating Tables +*************** There are several things you may wish to do when creating tables. Add fields, add keys to the table, alter columns. CodeIgniter provides a @@ -176,10 +176,6 @@ and unique keys with specific methods: .. note:: When you add a primary key, MySQL and SQLite will assume the name ``PRIMARY`` even if a name is provided. -You may add keys to an existing table by using ``processIndexes()``: - -.. literalinclude:: forge/029.php - .. _adding-foreign-keys: Adding Foreign Keys @@ -216,6 +212,10 @@ You could also pass optional table attributes, such as MySQL's ``ENGINE``: ``createTable()`` will always add them with your configured *charset* and *DBCollat* values, as long as they are not empty (MySQL only). +*************** +Dropping Tables +*************** + Dropping a Table ================ @@ -228,6 +228,10 @@ drivers to handle removal of tables with foreign keys. .. literalinclude:: forge/018.php +**************** +Modifying Tables +**************** + Dropping a Foreign Key ====================== @@ -236,7 +240,7 @@ Execute a DROP FOREIGN KEY. .. literalinclude:: forge/019.php Dropping a Key -====================== +=============== Execute a DROP KEY. @@ -260,10 +264,6 @@ Executes a TABLE rename .. literalinclude:: forge/021.php -**************** -Modifying Tables -**************** - Adding a Column to a Table ========================== @@ -284,7 +284,7 @@ Examples: .. literalinclude:: forge/023.php Dropping Columns From a Table -============================== +============================= .. _db-forge-dropColumn: @@ -311,6 +311,15 @@ change the name, you can add a "name" key into the field defining array. .. literalinclude:: forge/026.php +Adding Keys to a Table +====================== + +.. versionadded:: 4.3.0 + +You may add keys to an existing table by using ``processIndexes()``: + +.. literalinclude:: forge/029.php + *************** Class Reference *************** From e0bdb5302f62e1cfb29386ba440cefa1ed07a0fc Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 22 Jan 2023 17:28:18 +0900 Subject: [PATCH 099/290] docs: change section order --- user_guide_src/source/dbmgmt/forge.rst | 64 +++++++++++++------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index 93143ee1d244..43d542b7816d 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -232,38 +232,6 @@ drivers to handle removal of tables with foreign keys. Modifying Tables **************** -Dropping a Foreign Key -====================== - -Execute a DROP FOREIGN KEY. - -.. literalinclude:: forge/019.php - -Dropping a Key -=============== - -Execute a DROP KEY. - -.. literalinclude:: forge/020.php - -.. _dropping-a-primary-key: - -Dropping a Primary Key -====================== - -.. versionadded:: 4.3.0 - -Execute a DROP PRIMARY KEY. - -.. literalinclude:: forge/028.php - -Renaming a Table -================ - -Executes a TABLE rename - -.. literalinclude:: forge/021.php - Adding a Column to a Table ========================== @@ -320,6 +288,38 @@ You may add keys to an existing table by using ``processIndexes()``: .. literalinclude:: forge/029.php +Dropping a Primary Key +====================== + +.. versionadded:: 4.3.0 + +Execute a DROP PRIMARY KEY. + +.. literalinclude:: forge/028.php + +Dropping a Key +=============== + +Execute a DROP KEY. + +.. literalinclude:: forge/020.php + +.. _dropping-a-primary-key: + +Dropping a Foreign Key +====================== + +Execute a DROP FOREIGN KEY. + +.. literalinclude:: forge/019.php + +Renaming a Table +================ + +Executes a TABLE rename + +.. literalinclude:: forge/021.php + *************** Class Reference *************** From 671efc1bf99daac99c3884977ccab1f6ccdbd80f Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 22 Jan 2023 17:58:03 +0900 Subject: [PATCH 100/290] docs: fix label position --- user_guide_src/source/dbmgmt/forge.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index 43d542b7816d..52750ae5ad0a 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -288,6 +288,8 @@ You may add keys to an existing table by using ``processIndexes()``: .. literalinclude:: forge/029.php +.. _dropping-a-primary-key: + Dropping a Primary Key ====================== @@ -304,8 +306,6 @@ Execute a DROP KEY. .. literalinclude:: forge/020.php -.. _dropping-a-primary-key: - Dropping a Foreign Key ====================== From 12883f0ab0397577fd41d5e6e656fe6f32a86f81 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 22 Jan 2023 18:00:35 +0900 Subject: [PATCH 101/290] docs: replace "column" in titles with "field" --- user_guide_src/source/dbmgmt/forge.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index 52750ae5ad0a..b8da792be9a5 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -232,8 +232,8 @@ drivers to handle removal of tables with foreign keys. Modifying Tables **************** -Adding a Column to a Table -========================== +Adding a Field to a Table +========================= $forge->addColumn() ------------------- @@ -251,8 +251,8 @@ Examples: .. literalinclude:: forge/023.php -Dropping Columns From a Table -============================= +Dropping Fields From a Table +============================ .. _db-forge-dropColumn: @@ -267,8 +267,8 @@ Used to remove multiple columns from a table. .. literalinclude:: forge/025.php -Modifying a Column in a Table -============================= +Modifying a Field in a Table +============================ $forge->modifyColumn() ---------------------- @@ -335,7 +335,7 @@ Class Reference :returns: true on success, false on failure :rtype: bool - Adds a column to a table. Usage: See `Adding a Column to a Table`_. + Adds a column to a table. Usage: See `Adding a Field to a Table`_. .. php:method:: addField($field) @@ -423,7 +423,7 @@ Class Reference :returns: true on success, false on failure :rtype: bool - Drops single or multiple columns from a table. Usage: See `Dropping Columns From a Table`_. + Drops single or multiple columns from a table. Usage: See `Dropping Fields From a Table`_. .. php:method:: dropDatabase($dbName) @@ -481,7 +481,7 @@ Class Reference :returns: true on success, false on failure :rtype: bool - Modifies a table column. Usage: See `Modifying a Column in a Table`_. + Modifies a table column. Usage: See `Modifying a Field in a Table`_. .. php:method:: renameTable($table_name, $new_table_name) From d60a0f7785839fedfac13d02e3cd5781385bdcba Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 22 Jan 2023 18:01:47 +0900 Subject: [PATCH 102/290] docs: improve docs --- user_guide_src/source/changelogs/v4.3.0.rst | 2 +- user_guide_src/source/dbmgmt/forge.rst | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.3.0.rst b/user_guide_src/source/changelogs/v4.3.0.rst index 5911f1686568..d70b9dc66963 100644 --- a/user_guide_src/source/changelogs/v4.3.0.rst +++ b/user_guide_src/source/changelogs/v4.3.0.rst @@ -240,7 +240,7 @@ Query Builder Forge ----- -- Added ``Forge::processIndexes()`` allowing the creation of indexes on an existing table. See :ref:`adding-keys` for the details. +- Added ``Forge::processIndexes()`` allowing the creation of indexes on an existing table. See :ref:`db-forge-adding-keys-to-a-table` for the details. - Added the ability to manually set index names. These methods include: ``Forge::addKey()``, ``Forge::addPrimaryKey()``, and ``Forge::addUniqueKey()`` - The new method ``Forge::dropPrimaryKey()`` allows dropping the primary key on a table. See :ref:`dropping-a-primary-key`. - Fixed ``Forge::dropKey()`` to allow dropping unique indexes. This required the ``DROP CONSTRAINT`` SQL command. diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index b8da792be9a5..88cf7562c642 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -1,3 +1,4 @@ +#################### Database Forge Class #################### @@ -142,7 +143,7 @@ string into the field definitions with ``addField()``: .. note:: Multiple calls to ``addField()`` are cumulative. -Creating an id field +Creating an id Field -------------------- There is a special exception for creating id fields. A field with type @@ -156,6 +157,9 @@ Primary Key. Adding Keys =========== +$forge->addKey() +---------------- + Generally speaking, you'll want your table to have Keys. This is accomplished with ``$forge->addKey('field')``. The optional second parameter set to true will make it a primary key and the third @@ -169,6 +173,12 @@ below is for MySQL. .. literalinclude:: forge/010.php +$forge->addPrimaryKey() +----------------------- + +$forge->addUniqueKey() +---------------------- + To make code reading more objective it is also possible to add primary and unique keys with specific methods: @@ -279,12 +289,15 @@ change the name, you can add a "name" key into the field defining array. .. literalinclude:: forge/026.php +.. _db-forge-adding-keys-to-a-table: + Adding Keys to a Table ====================== .. versionadded:: 4.3.0 -You may add keys to an existing table by using ``processIndexes()``: +You may add keys to an existing table by using ``addKey()``, ``addPrimaryKey()``, +``addUniqueKey()`` or ``addForeignKey()`` and ``processIndexes()``: .. literalinclude:: forge/029.php @@ -467,12 +480,15 @@ Class Reference .. php:method:: processIndexes($table) + .. versionadded:: 4.3.0 + :param string $table: Name of the table to add indexes to :returns: true on success, false on failure :rtype: bool Used following ``addKey()``, ``addPrimaryKey()``, ``addUniqueKey()``, and ``addForeignKey()`` to add indexes to an existing table. + See `Adding Keys to a Table`_. .. php:method:: modifyColumn($table, $field) From 837fc23afa8d2b46523f2bb4716e36afcd79f89b Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 22 Jan 2023 18:08:48 +0900 Subject: [PATCH 103/290] docs: fix indent --- user_guide_src/source/dbmgmt/forge.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index 88cf7562c642..8e80188a1b69 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -356,7 +356,7 @@ Class Reference :returns: \CodeIgniter\Database\Forge instance (method chaining) :rtype: \CodeIgniter\Database\Forge - Adds a field to the set that will be used to create a table. Usage: See `Adding Fields`_. + Adds a field to the set that will be used to create a table. Usage: See `Adding Fields`_. .. php:method:: addForeignKey($fieldName, $tableName, $tableField[, $onUpdate = '', $onDelete = '', $fkName = '']) From 0bcaf145d2330fa21c5235c679541394e5c6f600 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 22 Jan 2023 18:09:09 +0900 Subject: [PATCH 104/290] docs: remove duplicate note --- user_guide_src/source/dbmgmt/forge.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index 8e80188a1b69..a3b74e979966 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -369,8 +369,6 @@ Class Reference :returns: \CodeIgniter\Database\Forge instance (method chaining) :rtype: \CodeIgniter\Database\Forge - .. note:: ``$fkName`` can be used since v4.3.0. - Adds a foreign key to the set that will be used to create a table. Usage: See `Adding Foreign Keys`_. .. note:: ``$fkName`` can be used since v4.3.0. From 7217843456883e29e95f2f12c23941c73c803e41 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 22 Jan 2023 22:22:51 +0900 Subject: [PATCH 105/290] docs: fix link --- changelogs/CHANGELOG_4.2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/CHANGELOG_4.2.md b/changelogs/CHANGELOG_4.2.md index e472b4b87883..a6eae8a48637 100644 --- a/changelogs/CHANGELOG_4.2.md +++ b/changelogs/CHANGELOG_4.2.md @@ -420,4 +420,4 @@ * Small change to improve code reading by @valmorflores in https://github.com/codeigniter4/CodeIgniter4/pull/6051 * refactor: remove `CodeIgniter\Services` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/6053 -See [CHANGELOG_4.1.md](./changelogs/CHANGELOG_4.1.md) +See [CHANGELOG_4.1.md](./CHANGELOG_4.1.md) From 214cf1fcf1958d87d79ed03c6bbade3bd79aee7a Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 08:31:37 +0900 Subject: [PATCH 106/290] docs: change link to the official user guide codeigniter.com/user_guide/ --- user_guide_src/source/installation/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/index.rst b/user_guide_src/source/installation/index.rst index 4807b9a06620..3be12a637dcc 100644 --- a/user_guide_src/source/installation/index.rst +++ b/user_guide_src/source/installation/index.rst @@ -11,7 +11,7 @@ Which is right for you? is known for, choose the manual installation. However you choose to install and run CodeIgniter4, the -`user guide `_ is accessible online. +`user guide `_ is accessible online. .. note:: Before using CodeIgniter 4, make sure that your server meets the :doc:`requirements `, in particular the PHP From cb857030707f8512784b52a424dd0b522a5048d3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 08:40:34 +0900 Subject: [PATCH 107/290] docs: add note --- user_guide_src/source/installation/installing_composer.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user_guide_src/source/installation/installing_composer.rst b/user_guide_src/source/installation/installing_composer.rst index 97c39b34a19b..f415c895cab7 100644 --- a/user_guide_src/source/installation/installing_composer.rst +++ b/user_guide_src/source/installation/installing_composer.rst @@ -9,6 +9,9 @@ Composer can be used in several ways to install CodeIgniter4 on your system. .. important:: CodeIgniter4 requires Composer 2.0.14 or later. +.. note:: If you are not familiar with Composer, we recommend you read + `Basic usage `_ first. + 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 From 6faf52c9c99124ff7f70dd7e4fe11100c9b7fa30 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 08:52:21 +0900 Subject: [PATCH 108/290] docs: change file decoration --- .../source/installation/installing_composer.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/installation/installing_composer.rst b/user_guide_src/source/installation/installing_composer.rst index f415c895cab7..8f8c0f167c52 100644 --- a/user_guide_src/source/installation/installing_composer.rst +++ b/user_guide_src/source/installation/installing_composer.rst @@ -18,7 +18,7 @@ The second technique described below lets you add CodeIgniter4 to an existing webapp, .. note:: If you are using a Git repository to store your code, or for - collaboration with others, then the ``vendor`` folder would normally + collaboration with others, then the **vendor** folder would normally be "git ignored". In such a case, you will need to do a ``composer update`` when you clone the repository to a new system. @@ -39,7 +39,7 @@ In the folder above your project root:: > composer create-project codeigniter4/appstarter project-root -The command above will create a "project-root" folder. +The command above will create a **project-root** folder. If you omit the "project-root" argument, the command will create an "appstarter" folder, which can be renamed as appropriate. @@ -137,8 +137,8 @@ In your project root:: Setting Up ---------- - 1. Copy the ``app``, ``public``, ``tests`` and ``writable`` folders from ``vendor/codeigniter4/framework`` to your project root - 2. Copy the ``env``, ``phpunit.xml.dist`` and ``spark`` files, from ``vendor/codeigniter4/framework`` to your project root + 1. Copy the **app**, **public**, **tests** and **writable** folders from **vendor/codeigniter4/framework** to your project root + 2. Copy the **env**, **phpunit.xml.dist** and **spark** files, from **vendor/codeigniter4/framework** to your project root 3. You will have to adjust the ``$systemDirectory`` property in **app/Config/Paths.php** to refer to the vendor one, e.g., ``ROOTPATH . '/vendor/codeigniter4/framework/system'``. Initial Configuration From 535254cced2e4f31a916d078776e8eb65a33b32c Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 08:56:05 +0900 Subject: [PATCH 109/290] docs: add note for --no-dev when deploying Remove "composer create-project codeigniter4/appstarter --no-dev", because it is not so important. --- .../installation/installing_composer.rst | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/user_guide_src/source/installation/installing_composer.rst b/user_guide_src/source/installation/installing_composer.rst index 8f8c0f167c52..713fbd22df99 100644 --- a/user_guide_src/source/installation/installing_composer.rst +++ b/user_guide_src/source/installation/installing_composer.rst @@ -48,14 +48,14 @@ If you omit the "project-root" argument, the command will create an The symbols that can be used are ``/``, ``_``, ``.``, ``:``, ``\`` and space. So if you install CodeIgniter under the folder that contains the special characters like ``(``, ``)``, etc., CodeIgniter won't work. -If you don't need or want phpunit installed, and all of its composer -dependencies, then add the ``--no-dev`` option to the end of the above -command line. That will result in only the framework, and the three -trusted dependencies that we bundle, being composer-installed. +.. important:: When you deploy to your production server, don't forget to run the + following command:: -A sample such installation command, using the default project-root "appstarter":: + > composer install --no-dev - > composer create-project codeigniter4/appstarter --no-dev + The above command will removes the Composer packages only for development + that are not needed in the production environment. This will greatly reduce + the folder size. Initial Configuration --------------------- @@ -134,6 +134,15 @@ In your project root:: > composer require codeigniter4/framework +.. important:: When you deploy to your production server, don't forget to run the + following command:: + + > composer install --no-dev + + The above command will removes the Composer packages only for development + that are not needed in the production environment. This will greatly reduce + the folder size. + Setting Up ---------- From e293c6472cf7d9c4df4b92cf74cd93a43777bb77 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 09:17:29 +0900 Subject: [PATCH 110/290] chore: add missing items The items in composer.json in main repository. --- admin/framework/composer.json | 5 +++++ admin/starter/composer.json | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/admin/framework/composer.json b/admin/framework/composer.json index f4f974c6d635..2cf6c1c76de2 100644 --- a/admin/framework/composer.json +++ b/admin/framework/composer.json @@ -42,6 +42,11 @@ "ext-fileinfo": "Improves mime type detection for files", "ext-readline": "Improves CLI::input() usability" }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, "autoload": { "psr-4": { "CodeIgniter\\": "system/" diff --git a/admin/starter/composer.json b/admin/starter/composer.json index e52218478b04..524cae392d27 100644 --- a/admin/starter/composer.json +++ b/admin/starter/composer.json @@ -14,7 +14,29 @@ "phpunit/phpunit": "^9.1" }, "suggest": { - "ext-fileinfo": "Improves mime type detection for files" + "ext-curl": "If you use CURLRequest class", + "ext-imagick": "If you use Image class ImageMagickHandler", + "ext-gd": "If you use Image class GDHandler", + "ext-exif": "If you run Image class tests", + "ext-simplexml": "If you format XML", + "ext-mysqli": "If you use MySQL", + "ext-oci8": "If you use Oracle Database", + "ext-pgsql": "If you use PostgreSQL", + "ext-sqlsrv": "If you use SQL Server", + "ext-sqlite3": "If you use SQLite3", + "ext-memcache": "If you use Cache class MemcachedHandler with Memcache", + "ext-memcached": "If you use Cache class MemcachedHandler with Memcached", + "ext-redis": "If you use Cache class RedisHandler", + "ext-dom": "If you use TestResponse", + "ext-libxml": "If you use TestResponse", + "ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()", + "ext-fileinfo": "Improves mime type detection for files", + "ext-readline": "Improves CLI::input() usability" + }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true }, "autoload": { "exclude-from-classmap": [ From 57d72d7d847ffa731b873825f88e2fe9dad88569 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 09:30:46 +0900 Subject: [PATCH 111/290] test: add tests --- tests/system/AutoReview/ComposerJsonTest.php | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/system/AutoReview/ComposerJsonTest.php b/tests/system/AutoReview/ComposerJsonTest.php index 80ebcaeeb172..dcf2d9487db7 100644 --- a/tests/system/AutoReview/ComposerJsonTest.php +++ b/tests/system/AutoReview/ComposerJsonTest.php @@ -27,6 +27,7 @@ final class ComposerJsonTest extends TestCase { private array $devComposer; private array $frameworkComposer; + private array $starterComposer; protected function setUp(): void { @@ -34,6 +35,7 @@ protected function setUp(): void $this->devComposer = $this->getComposerJson(dirname(__DIR__, 3) . '/composer.json'); $this->frameworkComposer = $this->getComposerJson(dirname(__DIR__, 3) . '/admin/framework/composer.json'); + $this->starterComposer = $this->getComposerJson(dirname(__DIR__, 3) . '/admin/starter/composer.json'); } public function testFrameworkRequireIsTheSameWithDevRequire(): void @@ -77,6 +79,33 @@ public function testFrameworkSuggestIsTheSameWithDevSuggest(): void ); } + public function testStarterSuggestIsTheSameWithDevSuggest(): void + { + $this->assertSame( + $this->devComposer['suggest'], + $this->starterComposer['suggest'], + 'The starter\'s "suggest" section is not updated with the main composer.json.' + ); + } + + public function testFrameworkConfigIsTheSameWithDevSuggest(): void + { + $this->assertSame( + $this->devComposer['config'], + $this->frameworkComposer['config'], + 'The framework\'s "config" section is not updated with the main composer.json.' + ); + } + + public function testStarterConfigIsTheSameWithDevSuggest(): void + { + $this->assertSame( + $this->devComposer['config'], + $this->starterComposer['config'], + 'The starter\'s "config" section is not updated with the main composer.json.' + ); + } + private function getComposerJson(string $path): array { try { From 8281b11f3cec3303328b7eb8f3278a4fe749d5e3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 09:36:16 +0900 Subject: [PATCH 112/290] test: refactor --- tests/system/AutoReview/ComposerJsonTest.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/system/AutoReview/ComposerJsonTest.php b/tests/system/AutoReview/ComposerJsonTest.php index dcf2d9487db7..5a7ae9ba2d34 100644 --- a/tests/system/AutoReview/ComposerJsonTest.php +++ b/tests/system/AutoReview/ComposerJsonTest.php @@ -81,11 +81,7 @@ public function testFrameworkSuggestIsTheSameWithDevSuggest(): void public function testStarterSuggestIsTheSameWithDevSuggest(): void { - $this->assertSame( - $this->devComposer['suggest'], - $this->starterComposer['suggest'], - 'The starter\'s "suggest" section is not updated with the main composer.json.' - ); + $this->checkStarter('suggest'); } public function testFrameworkConfigIsTheSameWithDevSuggest(): void @@ -98,11 +94,16 @@ public function testFrameworkConfigIsTheSameWithDevSuggest(): void } public function testStarterConfigIsTheSameWithDevSuggest(): void + { + $this->checkStarter('config'); + } + + private function checkStarter(string $section): void { $this->assertSame( - $this->devComposer['config'], - $this->starterComposer['config'], - 'The starter\'s "config" section is not updated with the main composer.json.' + $this->devComposer[$section], + $this->starterComposer[$section], + 'The starter\'s "' . $section . '" section is not updated with the main composer.json.' ); } From ed783e10d10ed0388ce0ec8dffc48ee40b8b3af1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 09:45:12 +0900 Subject: [PATCH 113/290] test: refactor --- tests/system/AutoReview/ComposerJsonTest.php | 27 +++++++++----------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/system/AutoReview/ComposerJsonTest.php b/tests/system/AutoReview/ComposerJsonTest.php index 5a7ae9ba2d34..c078487adade 100644 --- a/tests/system/AutoReview/ComposerJsonTest.php +++ b/tests/system/AutoReview/ComposerJsonTest.php @@ -40,11 +40,7 @@ protected function setUp(): void public function testFrameworkRequireIsTheSameWithDevRequire(): void { - $this->assertSame( - $this->devComposer['require'], - $this->frameworkComposer['require'], - 'The framework\'s "require" section is not updated with the main composer.json.' - ); + $this->checkFramework('require'); } public function testFrameworkRequireDevIsTheSameWithDevRequireDev(): void @@ -72,11 +68,7 @@ public function testFrameworkRequireDevIsTheSameWithDevRequireDev(): void public function testFrameworkSuggestIsTheSameWithDevSuggest(): void { - $this->assertSame( - $this->devComposer['suggest'], - $this->frameworkComposer['suggest'], - 'The framework\'s "suggest" section is not updated with the main composer.json.' - ); + $this->checkFramework('suggest'); } public function testStarterSuggestIsTheSameWithDevSuggest(): void @@ -86,11 +78,7 @@ public function testStarterSuggestIsTheSameWithDevSuggest(): void public function testFrameworkConfigIsTheSameWithDevSuggest(): void { - $this->assertSame( - $this->devComposer['config'], - $this->frameworkComposer['config'], - 'The framework\'s "config" section is not updated with the main composer.json.' - ); + $this->checkFramework('config'); } public function testStarterConfigIsTheSameWithDevSuggest(): void @@ -98,6 +86,15 @@ public function testStarterConfigIsTheSameWithDevSuggest(): void $this->checkStarter('config'); } + private function checkFramework(string $section): void + { + $this->assertSame( + $this->devComposer[$section], + $this->frameworkComposer[$section], + 'The framework\'s "' . $section . '" section is not updated with the main composer.json.' + ); + } + private function checkStarter(string $section): void { $this->assertSame( From c160153f64816a010284d26278039cd63dc15ca0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Jan 2023 09:13:06 +0900 Subject: [PATCH 114/290] fix: add missing NOT IN --- system/Database/BaseBuilder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index f6fd1daff6cc..bd8c5004b4a6 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -3382,7 +3382,7 @@ protected function getOperator(string $str, bool $list = false) $this->pregOperators = [ '\s*(?:<|>|!)?=\s*', // =, <=, >=, != '\s*<>?\s*', // <, <> - '\s*>\s*', // >å + '\s*>\s*', // > '\s+IS NULL', // IS NULL '\s+IS NOT NULL', // IS NOT NULL '\s+EXISTS\s*\(.*\)', // EXISTS (sql) @@ -3422,6 +3422,7 @@ private function getOperatorFromWhereKey(string $whereKey) '\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS (sql) '\s+BETWEEN\s+', // BETWEEN value AND value '\s+IN\s*\(.*\)', // IN (list) + '\s+NOT IN\s*\(.*\)', // NOT IN (list) '\s+LIKE', // LIKE '\s+NOT LIKE', // NOT LIKE ]; From 12f7ea0a06752c86314070b71ca6dbf794660a6e Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 12:31:18 +0900 Subject: [PATCH 115/290] docs: folder size -> vendor folder size --- user_guide_src/source/installation/installing_composer.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/installation/installing_composer.rst b/user_guide_src/source/installation/installing_composer.rst index 713fbd22df99..1a37329b4936 100644 --- a/user_guide_src/source/installation/installing_composer.rst +++ b/user_guide_src/source/installation/installing_composer.rst @@ -55,7 +55,7 @@ If you omit the "project-root" argument, the command will create an The above command will removes the Composer packages only for development that are not needed in the production environment. This will greatly reduce - the folder size. + the vendor folder size. Initial Configuration --------------------- @@ -141,7 +141,7 @@ In your project root:: The above command will removes the Composer packages only for development that are not needed in the production environment. This will greatly reduce - the folder size. + the vendor folder size. Setting Up ---------- From 0130b06b4fa7b79b552ae2a76bdd2a4be8ebb43f Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 12:47:51 +0900 Subject: [PATCH 116/290] chore: remove suggest in starter If you run `composer suggest`, it shows framework's. --- admin/starter/composer.json | 20 -------------------- tests/system/AutoReview/ComposerJsonTest.php | 5 ----- 2 files changed, 25 deletions(-) diff --git a/admin/starter/composer.json b/admin/starter/composer.json index 524cae392d27..cec23ba1987e 100644 --- a/admin/starter/composer.json +++ b/admin/starter/composer.json @@ -13,26 +13,6 @@ "mikey179/vfsstream": "^1.6", "phpunit/phpunit": "^9.1" }, - "suggest": { - "ext-curl": "If you use CURLRequest class", - "ext-imagick": "If you use Image class ImageMagickHandler", - "ext-gd": "If you use Image class GDHandler", - "ext-exif": "If you run Image class tests", - "ext-simplexml": "If you format XML", - "ext-mysqli": "If you use MySQL", - "ext-oci8": "If you use Oracle Database", - "ext-pgsql": "If you use PostgreSQL", - "ext-sqlsrv": "If you use SQL Server", - "ext-sqlite3": "If you use SQLite3", - "ext-memcache": "If you use Cache class MemcachedHandler with Memcache", - "ext-memcached": "If you use Cache class MemcachedHandler with Memcached", - "ext-redis": "If you use Cache class RedisHandler", - "ext-dom": "If you use TestResponse", - "ext-libxml": "If you use TestResponse", - "ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()", - "ext-fileinfo": "Improves mime type detection for files", - "ext-readline": "Improves CLI::input() usability" - }, "config": { "optimize-autoloader": true, "preferred-install": "dist", diff --git a/tests/system/AutoReview/ComposerJsonTest.php b/tests/system/AutoReview/ComposerJsonTest.php index c078487adade..dc9ad26b9ef8 100644 --- a/tests/system/AutoReview/ComposerJsonTest.php +++ b/tests/system/AutoReview/ComposerJsonTest.php @@ -71,11 +71,6 @@ public function testFrameworkSuggestIsTheSameWithDevSuggest(): void $this->checkFramework('suggest'); } - public function testStarterSuggestIsTheSameWithDevSuggest(): void - { - $this->checkStarter('suggest'); - } - public function testFrameworkConfigIsTheSameWithDevSuggest(): void { $this->checkFramework('config'); From 3d251685d2e7f9d6d96cc91efef60fff196f5d49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Jan 2023 15:01:49 +0000 Subject: [PATCH 117/290] chore(deps-dev): update rector/rector requirement from 0.15.7 to 0.15.10 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.7...0.15.10) --- 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 5f57c60f6781..60144c6ecb61 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.7", + "rector/rector": "0.15.10", "vimeo/psalm": "^5.0" }, "suggest": { From 299c76e619539c525ad176fe0e947fff0b4c8208 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 24 Jan 2023 09:02:06 +0900 Subject: [PATCH 118/290] refactor: remove unneeded code --- app/Views/errors/html/error_exception.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/app/Views/errors/html/error_exception.php b/app/Views/errors/html/error_exception.php index ae46d3056e89..c40f3ac55b7c 100644 --- a/app/Views/errors/html/error_exception.php +++ b/app/Views/errors/html/error_exception.php @@ -283,21 +283,11 @@ - - - - - getName(), 'html') ?> - getValueLine(), 'html') ?> - - + + + getName(), 'html') ?> + getValueLine(), 'html') ?> + @@ -332,7 +322,7 @@ - $value) : ?> + $header) : ?> getHeaderLine($name), 'html') ?> From 8ce15e50be8a4498b6d356c39259857e776a21f3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 24 Jan 2023 11:20:32 +0900 Subject: [PATCH 119/290] docs: add about removal of deprecated Config items --- .../source/installation/backward_compatibility_notes.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/installation/backward_compatibility_notes.rst b/user_guide_src/source/installation/backward_compatibility_notes.rst index 65d1f9179ebd..e265d5a34968 100644 --- a/user_guide_src/source/installation/backward_compatibility_notes.rst +++ b/user_guide_src/source/installation/backward_compatibility_notes.rst @@ -13,5 +13,7 @@ However, the code is not mature and bug fixes may break compatibility in minor r What are not Breaking Changes ***************************** +- The deprecated Config items are not covered by backwards compatibility (BC) promise. It may be removed in the next + **minor** version or later. - System messages defined in **system/Language/en/** are strictly for internal framework use and are not covered by backwards compatibility (BC) promise. If developers are relying on language string output they should be checking it against the function call (``lang('...')``), not the content. - `Named arguments `_ are not covered by backwards compatibility (BC) promise. We may choose to rename method/function parameter names when necessary in order to improve the codebase. From ad93e936f043b8d328fece2d3a98f72a795b2a19 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 24 Jan 2023 16:09:47 +0900 Subject: [PATCH 120/290] fix: Event collector does not collect Timeline data --- phpstan-baseline.neon.dist | 5 ---- system/Debug/Toolbar/Collectors/Events.php | 28 ++++------------------ 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/phpstan-baseline.neon.dist b/phpstan-baseline.neon.dist index af189e08b8b1..4259df0cc3ef 100644 --- a/phpstan-baseline.neon.dist +++ b/phpstan-baseline.neon.dist @@ -100,11 +100,6 @@ parameters: count: 13 path: system/Database/SQLSRV/Forge.php - - - message: "#^Call to an undefined method CodeIgniter\\\\View\\\\RendererInterface\\:\\:getPerformanceData\\(\\)\\.$#" - count: 1 - path: system/Debug/Toolbar/Collectors/Events.php - - message: "#^Property CodeIgniter\\\\Log\\\\Logger\\:\\:\\$logCache \\(array\\) on left side of \\?\\? is not nullable\\.$#" count: 1 diff --git a/system/Debug/Toolbar/Collectors/Events.php b/system/Debug/Toolbar/Collectors/Events.php index a8a7e7aa4c35..178a886644a5 100644 --- a/system/Debug/Toolbar/Collectors/Events.php +++ b/system/Debug/Toolbar/Collectors/Events.php @@ -11,11 +11,8 @@ namespace CodeIgniter\Debug\Toolbar\Collectors; -use CodeIgniter\View\RendererInterface; -use Config\Services; - /** - * Views collector + * Events collector */ class Events extends BaseCollector { @@ -25,7 +22,7 @@ class Events extends BaseCollector * * @var bool */ - protected $hasTimeline = false; + protected $hasTimeline = true; /** * Whether this collector needs to display @@ -51,21 +48,6 @@ class Events extends BaseCollector */ protected $title = 'Events'; - /** - * Instance of the Renderer service - * - * @var RendererInterface - */ - protected $viewer; - - /** - * Constructor. - */ - public function __construct() - { - $this->viewer = Services::renderer(); - } - /** * Child classes should implement this to return the timeline data * formatted for correct usage. @@ -74,12 +56,12 @@ protected function formatTimelineData(): array { $data = []; - $rows = $this->viewer->getPerformanceData(); + $rows = \CodeIgniter\Events\Events::getPerformanceLogs(); foreach ($rows as $info) { $data[] = [ - 'name' => 'View: ' . $info['view'], - 'component' => 'Views', + 'name' => 'Event: ' . $info['event'], + 'component' => 'Events', 'start' => $info['start'], 'duration' => $info['end'] - $info['start'], ]; From 0afa8a43d51af8022dda751993710ebfff358f36 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 24 Jan 2023 16:11:43 +0900 Subject: [PATCH 121/290] fix: DebugBar initializes shared renderer instance A dev cannot create shared renderer instance. --- system/Debug/Toolbar/Collectors/Views.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/system/Debug/Toolbar/Collectors/Views.php b/system/Debug/Toolbar/Collectors/Views.php index fae3385fffbc..2e036ff19c85 100644 --- a/system/Debug/Toolbar/Collectors/Views.php +++ b/system/Debug/Toolbar/Collectors/Views.php @@ -60,9 +60,9 @@ class Views extends BaseCollector protected $title = 'Views'; /** - * Instance of the Renderer service + * Instance of the shared Renderer service * - * @var RendererInterface + * @var RendererInterface|null */ protected $viewer; @@ -73,12 +73,9 @@ class Views extends BaseCollector */ protected $views = []; - /** - * Constructor. - */ - public function __construct() + private function getViewer(): void { - $this->viewer = Services::renderer(); + $this->viewer ??= Services::renderer(); } /** @@ -87,6 +84,8 @@ public function __construct() */ protected function formatTimelineData(): array { + $this->getViewer(); + $data = []; $rows = $this->viewer->getPerformanceData(); @@ -121,8 +120,9 @@ protected function formatTimelineData(): array */ public function getVarData(): array { - return [ + $this->getViewer(); + return [ 'View Data' => $this->viewer->getData(), ]; } @@ -132,6 +132,8 @@ public function getVarData(): array */ public function getBadgeValue(): int { + $this->getViewer(); + return count($this->viewer->getPerformanceData()); } From fdb72579f1bca467619f6b8b5bb3f2bab6d2b18f Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 23 Jan 2023 23:20:29 +0700 Subject: [PATCH 122/290] [Rector] Apply Rector to app/Views --- rector.php | 1 - 1 file changed, 1 deletion(-) diff --git a/rector.php b/rector.php index 095cb2444c62..c2f296f5f8e5 100644 --- a/rector.php +++ b/rector.php @@ -74,7 +74,6 @@ // is there a file you need to skip? $rectorConfig->skip([ - __DIR__ . '/app/Views', __DIR__ . '/system/Debug/Toolbar/Views/toolbar.tpl.php', __DIR__ . '/system/ThirdParty', __DIR__ . '/tests/system/Config/fixtures', From ba96124a1ef53714f6512b6e0ffa2b207f57de85 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 25 Jan 2023 09:31:24 +0700 Subject: [PATCH 123/290] fix line use statemens --- app/Views/errors/html/error_exception.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/Views/errors/html/error_exception.php b/app/Views/errors/html/error_exception.php index c40f3ac55b7c..f311d910c0fa 100644 --- a/app/Views/errors/html/error_exception.php +++ b/app/Views/errors/html/error_exception.php @@ -1,4 +1,9 @@ - + @@ -77,16 +82,16 @@   —   - - ( arguments ) -
    + + ( arguments ) +
    getParameters(); } @@ -189,7 +194,7 @@
    - +
    @@ -297,7 +302,7 @@ setStatusCode(http_response_code()); ?>
    @@ -322,7 +327,7 @@
    - $header) : ?> + @@ -377,7 +382,7 @@

    Displayed at — PHP: — - CodeIgniter: + CodeIgniter:

    From 680ea61a8e18395ee354955278d817e5c0cc9c5a Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 25 Jan 2023 13:48:37 +0900 Subject: [PATCH 124/290] test: improve test case --- tests/system/Router/RouteCollectionTest.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/system/Router/RouteCollectionTest.php b/tests/system/Router/RouteCollectionTest.php index 70d378467414..6458449a02c9 100644 --- a/tests/system/Router/RouteCollectionTest.php +++ b/tests/system/Router/RouteCollectionTest.php @@ -1782,15 +1782,16 @@ public function testGetRegisteredControllersReturnsOneControllerWhenTwoRoutsWith public function testGetRegisteredControllersReturnsAllControllers() { $collection = $this->getCollector(); - $collection->get('test', '\App\Controllers\Hello::get'); - $collection->post('test', '\App\Controllers\Hello::post'); - $collection->post('hello', '\App\Controllers\Test::hello'); + $collection->get('test', '\App\Controllers\HelloGet::get'); + $collection->post('test', '\App\Controllers\HelloPost::post'); + $collection->post('hello', '\App\Controllers\TestPost::hello'); $routes = $collection->getRegisteredControllers('*'); $expects = [ - '\App\Controllers\Hello', - '\App\Controllers\Test', + '\App\Controllers\HelloGet', + '\App\Controllers\HelloPost', + '\App\Controllers\TestPost', ]; $this->assertSame($expects, $routes); } From 74bbf2bcf86712a15683d68e52ddab0b9027ffb0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 25 Jan 2023 14:27:04 +0900 Subject: [PATCH 125/290] fix: getRegisteredControllers() may not return all controllers --- system/Router/RouteCollection.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 7dd87701a432..26cedbfc1a65 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1577,31 +1577,32 @@ public function setPrioritize(bool $enabled = true) * Get all controllers in Route Handlers * * @param string|null $verb HTTP verb. `'*'` returns all controllers in any verb. + * + * @return array controller name list + * @phpstan-return list */ public function getRegisteredControllers(?string $verb = '*'): array { - $routes = []; + $handlers = []; if ($verb === '*') { - $rawRoutes = []; - foreach ($this->defaultHTTPMethods as $tmpVerb) { - $rawRoutes = array_merge($rawRoutes, $this->routes[$tmpVerb]); - } - - foreach ($rawRoutes as $route) { - $key = key($route['route']); - $handler = $route['route'][$key]; - - $routes[$key] = $handler; + foreach ($this->routes[$tmpVerb] as $route) { + $key = key($route['route']); + $handlers[] = $route['route'][$key]; + } } } else { $routes = $this->getRoutes($verb); + + foreach ($routes as $handler) { + $handlers[] = $handler; + } } $controllers = []; - foreach ($routes as $handler) { + foreach ($handlers as $handler) { if (! is_string($handler)) { continue; } From 785c10fc1e0ab860ea9afeea7347c2a4bd55ffd6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 25 Jan 2023 14:42:06 +0900 Subject: [PATCH 126/290] refactor: reduce foreach --- system/Router/RouteCollection.php | 38 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 26cedbfc1a65..c688ed88a04f 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1583,36 +1583,46 @@ public function setPrioritize(bool $enabled = true) */ public function getRegisteredControllers(?string $verb = '*'): array { - $handlers = []; + $controllers = []; if ($verb === '*') { foreach ($this->defaultHTTPMethods as $tmpVerb) { foreach ($this->routes[$tmpVerb] as $route) { - $key = key($route['route']); - $handlers[] = $route['route'][$key]; + $routeKey = key($route['route']); + $controller = $this->getControllerName($route['route'][$routeKey]); + if ($controller !== null) { + $controllers[] = $controller; + } } } } else { $routes = $this->getRoutes($verb); foreach ($routes as $handler) { - $handlers[] = $handler; + $controller = $this->getControllerName($handler); + if ($controller !== null) { + $controllers[] = $controller; + } } } - $controllers = []; - - foreach ($handlers as $handler) { - if (! is_string($handler)) { - continue; - } - - [$controller] = explode('::', $handler, 2); + return array_unique($controllers); + } - $controllers[] = $controller; + /** + * @param Closure|string $handler Handler + * + * @return string|null Controller classname + */ + private function getControllerName($handler) + { + if (! is_string($handler)) { + return null; } - return array_unique($controllers); + [$controller] = explode('::', $handler, 2); + + return $controller; } /** From d19c23522291ec9a705578ee54880b0d5314fe21 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 25 Jan 2023 17:08:15 +0900 Subject: [PATCH 127/290] fix: spark routes shows incorrect hostname routes --- system/Router/RouteCollection.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 7dd87701a432..3c49b5548b6c 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1316,13 +1316,12 @@ protected function create(string $verb, string $from, $to, ?array $options = nul // Hostname limiting? if (! empty($options['hostname'])) { // @todo determine if there's a way to whitelist hosts? - if (isset($this->httpHost) && strtolower($this->httpHost) !== strtolower($options['hostname'])) { + if (! $this->checkHostname($options['hostname'])) { return; } $overwrite = true; } - // Limiting to subdomains? elseif (! empty($options['subdomain'])) { // If we don't match the current subdomain, then @@ -1395,6 +1394,22 @@ protected function create(string $verb, string $from, $to, ?array $options = nul } } + /** + * Compares the hostname passed in against the current hostname + * on this page request. + * + * @param string $hostname Hostname in route options + */ + private function checkHostname($hostname): bool + { + // CLI calls can't be on hostname. + if (! isset($this->httpHost)) { + return false; + } + + return strtolower($this->httpHost) === strtolower($hostname); + } + private function processArrayCallableSyntax(string $from, array $to): string { // [classname, method] From fc05c01472f7b297b6315f9abaf0a1f5e2ac4991 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 10:33:44 +0900 Subject: [PATCH 128/290] docs: fix db group name in sample code It is a property of the Config class. It is not likely PascalCase. --- user_guide_src/source/concepts/factories/004.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/concepts/factories/004.php b/user_guide_src/source/concepts/factories/004.php index 9f6360b8ff5c..dc7dda75f61a 100644 --- a/user_guide_src/source/concepts/factories/004.php +++ b/user_guide_src/source/concepts/factories/004.php @@ -1,4 +1,4 @@ Date: Thu, 26 Jan 2023 10:46:52 +0900 Subject: [PATCH 129/290] docs: add explanation --- user_guide_src/source/concepts/factories.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/user_guide_src/source/concepts/factories.rst b/user_guide_src/source/concepts/factories.rst index dff3a92e017b..a254525da052 100644 --- a/user_guide_src/source/concepts/factories.rst +++ b/user_guide_src/source/concepts/factories.rst @@ -15,6 +15,11 @@ What are Factories? Like :doc:`./services`, **Factories** are an extension of autoloading that helps keep your code concise yet optimal, without having to pass around object instances between classes. +Factories are similar to CodeIgniter 3's ``$this->load`` in the following points: + +- Load a class +- Share the loaded class instance + At its simplest, Factories provide a common way to create a class instance and access it from anywhere. This is a great way to reuse object states and reduce memory load from keeping From c02a013fddae55e9f89f27685f9f3bfc93f6abce Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 10:47:23 +0900 Subject: [PATCH 130/290] docs: improve explanation --- user_guide_src/source/concepts/factories.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/concepts/factories.rst b/user_guide_src/source/concepts/factories.rst index a254525da052..dca07a43707d 100644 --- a/user_guide_src/source/concepts/factories.rst +++ b/user_guide_src/source/concepts/factories.rst @@ -50,7 +50,7 @@ Take a look at **Models** as an example. You can access the Factory specific to by using the magic static method of the Factories class, ``Factories::models()``. By default, Factories first searches in the ``App`` namespace for the path corresponding to the magic static method name. -``Factories::models()`` searches the path **Models/**. +``Factories::models()`` searches the **app/Models** directory. In the following code, if you have ``App\Models\UserModel``, the instance will be returned: From 804d75e075d69ddf68c06cf21e5c8b8e81ec3909 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 10:48:01 +0900 Subject: [PATCH 131/290] docs: fix variable name in sample code --- user_guide_src/source/concepts/factories/010.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/concepts/factories/010.php b/user_guide_src/source/concepts/factories/010.php index 20df61e3b397..90f5f26ef524 100644 --- a/user_guide_src/source/concepts/factories/010.php +++ b/user_guide_src/source/concepts/factories/010.php @@ -1,3 +1,3 @@ false]); +$users = Factories::models('Blog\Models\UserModel', ['preferApp' => false]); From 7655b8998025304745fa2d6658fe10b3bb5aada5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 10:48:38 +0900 Subject: [PATCH 132/290] docs: imporve sample code --- user_guide_src/source/concepts/factories.rst | 2 ++ user_guide_src/source/concepts/factories/003.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/user_guide_src/source/concepts/factories.rst b/user_guide_src/source/concepts/factories.rst index dca07a43707d..5111e3c568a2 100644 --- a/user_guide_src/source/concepts/factories.rst +++ b/user_guide_src/source/concepts/factories.rst @@ -59,6 +59,7 @@ In the following code, if you have ``App\Models\UserModel``, the instance will b Or you could also request a specific class: .. literalinclude:: factories/002.php + :lines: 2- If you have only ``Blog\Models\UserModel``, the instance will be returned. But if you have both ``App\Models\UserModel`` and ``Blog\Models\UserModel``, @@ -67,6 +68,7 @@ the instance of ``App\Models\UserModel`` will be returned. If you want to get ``Blog\Models\UserModel``, you need to disable the option ``preferApp``: .. literalinclude:: factories/010.php + :lines: 2- See :ref:`factories-options` for the details. diff --git a/user_guide_src/source/concepts/factories/003.php b/user_guide_src/source/concepts/factories/003.php index 44d3b06c55f6..f062aeb33f20 100644 --- a/user_guide_src/source/concepts/factories/003.php +++ b/user_guide_src/source/concepts/factories/003.php @@ -1,5 +1,7 @@ Date: Thu, 26 Jan 2023 11:47:33 +0900 Subject: [PATCH 133/290] docs: add about ucfirst() --- user_guide_src/source/concepts/factories.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/concepts/factories.rst b/user_guide_src/source/concepts/factories.rst index 5111e3c568a2..941df1a42702 100644 --- a/user_guide_src/source/concepts/factories.rst +++ b/user_guide_src/source/concepts/factories.rst @@ -126,8 +126,8 @@ Key Type Description ========== ============== ============================================================ =================================================== component string or null The name of the component (if different than the static ``null`` (defaults to the component name) method). This can be used to alias one component to another. -path string or null The relative path within the namespace/folder to look for ``null`` (defaults to the component name) - classes. +path string or null The relative path within the namespace/folder to look for ``null`` (defaults to the component name, + classes. but makes the first character uppercase) instanceOf string or null A required class name to match on the returned instance. ``null`` (no filtering) getShared boolean Whether to return a shared instance of the class or load a ``true`` fresh one. From 4a29526b4c7acbfdc3244b9b02cef38459cd4fbe Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 11:48:27 +0900 Subject: [PATCH 134/290] docs: align comments --- user_guide_src/source/concepts/factories/007.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/concepts/factories/007.php b/user_guide_src/source/concepts/factories/007.php index 4a3f894c7286..2a7def236420 100644 --- a/user_guide_src/source/concepts/factories/007.php +++ b/user_guide_src/source/concepts/factories/007.php @@ -1,4 +1,4 @@ true]); // Default; will always be the same instance +$users = Factories::models('UserModel', ['getShared' => true]); // Default; will always be the same instance $other = Factories::models('UserModel', ['getShared' => false]); // Will always create a new instance From d15405269def84e849b47e5479e078e10732deb5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 11:50:07 +0900 Subject: [PATCH 135/290] docs: add another example --- user_guide_src/source/concepts/factories.rst | 19 +++++++++++++++++++ .../source/concepts/factories/011.php | 12 ++++++++++++ .../source/concepts/factories/012.php | 5 +++++ 3 files changed, 36 insertions(+) create mode 100644 user_guide_src/source/concepts/factories/011.php create mode 100644 user_guide_src/source/concepts/factories/012.php diff --git a/user_guide_src/source/concepts/factories.rst b/user_guide_src/source/concepts/factories.rst index 941df1a42702..6a5743b5404f 100644 --- a/user_guide_src/source/concepts/factories.rst +++ b/user_guide_src/source/concepts/factories.rst @@ -150,6 +150,9 @@ Configurations To set default component options, create a new Config files at **app/Config/Factory.php** that supplies options as an array property that matches the name of the component. +Example: Filters Factories +-------------------------- + For example, if you want to create **Filters** by Factories, the component name wll be ``filters``. And if you want to ensure that each filter is an instance of a class which implements CodeIgniter's ``FilterInterface``, your **app/Config/Factory.php** file might look like this: @@ -162,6 +165,22 @@ and the returned instance will surely be a CodeIgniter's filter. This would prevent conflict of an third-party module which happened to have an unrelated ``Filters`` path in its namespace. +Example: Library Factories +-------------------------- + +If you want to load your library classes in the **app/Libraries** directory with +``Factories::library('SomeLib')``, the path `Libraries` is different from the +default path `Library`. + +In this case, your **app/Config/Factory.php** file will look like this: + +.. literalinclude:: factories/011.php + +Now you can load your libraries with the ``Factories::library()`` method: + +.. literalinclude:: factories/012.php + :lines: 2- + setOptions Method ================= diff --git a/user_guide_src/source/concepts/factories/011.php b/user_guide_src/source/concepts/factories/011.php new file mode 100644 index 000000000000..6e6ce0997884 --- /dev/null +++ b/user_guide_src/source/concepts/factories/011.php @@ -0,0 +1,12 @@ + 'Libraries', + ]; +} diff --git a/user_guide_src/source/concepts/factories/012.php b/user_guide_src/source/concepts/factories/012.php new file mode 100644 index 000000000000..c096ce3b619c --- /dev/null +++ b/user_guide_src/source/concepts/factories/012.php @@ -0,0 +1,5 @@ + Date: Thu, 26 Jan 2023 12:50:44 +0900 Subject: [PATCH 136/290] docs: add explanation for component --- user_guide_src/source/concepts/factories.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/concepts/factories.rst b/user_guide_src/source/concepts/factories.rst index 6a5743b5404f..8b868b78b434 100644 --- a/user_guide_src/source/concepts/factories.rst +++ b/user_guide_src/source/concepts/factories.rst @@ -49,6 +49,8 @@ Example Take a look at **Models** as an example. You can access the Factory specific to Models by using the magic static method of the Factories class, ``Factories::models()``. +The static method name is called *component*. + By default, Factories first searches in the ``App`` namespace for the path corresponding to the magic static method name. ``Factories::models()`` searches the **app/Models** directory. From 4ff63e76dbad80f99026ff3051eebf5798e9d0c2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:04:41 +0900 Subject: [PATCH 137/290] docs: fix :returns: --- user_guide_src/source/general/common_functions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index b63ee020d380..ed8d41885e19 100755 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -104,7 +104,7 @@ Service Accessors :param string $name: The model classname. :param boolean $getShared: Whether to return a shared instance. :param ConnectionInterface|null $conn: The database connection. - :returns: More simple way of getting model instances + :returns: The model instances :rtype: object See also the :ref:`Using CodeIgniter's Model `. From db475049644eed3b3c7a43e5327f71c595d84f27 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:05:35 +0900 Subject: [PATCH 138/290] docs: add explanation and links --- user_guide_src/source/general/common_functions.rst | 5 +++++ user_guide_src/source/models/model.rst | 3 +++ 2 files changed, 8 insertions(+) diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index ed8d41885e19..4a4f9744e800 100755 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -107,6 +107,11 @@ Service Accessors :returns: The model instances :rtype: object + More simple way of getting model instances. + + The ``model()`` uses ``Factories::models()`` internally. + See :ref:`factories-example` for details on the first parameter ``$name``. + See also the :ref:`Using CodeIgniter's Model `. .. php:function:: old($key[, $default = null,[, $escape = 'html']]) diff --git a/user_guide_src/source/models/model.rst b/user_guide_src/source/models/model.rst index dbdbd214f398..a3782c7205ba 100644 --- a/user_guide_src/source/models/model.rst +++ b/user_guide_src/source/models/model.rst @@ -28,6 +28,9 @@ You can access models within your classes by creating a new instance or using th .. literalinclude:: model/001.php +The ``model()`` uses ``Factories::models()`` internally. +See :ref:`factories-example` for details on the first parameter. + CodeIgniter's Model ******************* From ca40054bc8875128fc111b9524e8c75d80b8d65c Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:06:21 +0900 Subject: [PATCH 139/290] docs: change folder decoration --- user_guide_src/source/models/model.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/models/model.rst b/user_guide_src/source/models/model.rst index a3782c7205ba..726c26dac728 100644 --- a/user_guide_src/source/models/model.rst +++ b/user_guide_src/source/models/model.rst @@ -21,7 +21,7 @@ updating records, deleting records, and more. Accessing Models **************** -Models are typically stored in the ``app/Models`` directory. They should have a namespace that matches their +Models are typically stored in the **app/Models** directory. They should have a namespace that matches their location within the directory, like ``namespace App\Models``. You can access models within your classes by creating a new instance or using the :php:func:`model()` helper function. From 921dbbe37ee5125668001a1eca6146eae575269f Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:08:36 +0900 Subject: [PATCH 140/290] docs: add other samle code --- user_guide_src/source/models/model/001.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/models/model/001.php b/user_guide_src/source/models/model/001.php index 22f30bd5e5ee..d8ef48641ea6 100644 --- a/user_guide_src/source/models/model/001.php +++ b/user_guide_src/source/models/model/001.php @@ -3,11 +3,15 @@ // Create a new class manually. $userModel = new \App\Models\UserModel(); -// Create a new class with the model() function. -$userModel = model('App\Models\UserModel', false); - // Create a shared instance of the model. +$userModel = model('UserModel'); +// or $userModel = model('App\Models\UserModel'); +// or +$userModel = model(App\Models\UserModel::class); + +// Create a new class with the model() function. +$userModel = model('UserModel', false); // Create shared instance with a supplied database connection. // When no namespace is given, it will search through all namespaces From bfffe3d4f526c571ded285cf2fddee9fb926a89a Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:09:39 +0900 Subject: [PATCH 141/290] docs: remove incorrect comment When a FQCN is given, it may search through all namespaces. And the App namespace is prefered by default. --- user_guide_src/source/models/model/001.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/user_guide_src/source/models/model/001.php b/user_guide_src/source/models/model/001.php index d8ef48641ea6..90cdb17d98ea 100644 --- a/user_guide_src/source/models/model/001.php +++ b/user_guide_src/source/models/model/001.php @@ -14,7 +14,5 @@ $userModel = model('UserModel', false); // Create shared instance with a supplied database connection. -// When no namespace is given, it will search through all namespaces -// the system knows about and attempts to locate the UserModel class. $db = db_connect('custom'); $userModel = model('UserModel', true, $db); From 661c070266f39e938ef197d65af8301e13824a95 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 13:57:16 +0900 Subject: [PATCH 142/290] docs: remove out-of-dated comment --- app/Config/App.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/Config/App.php b/app/Config/App.php index 0a23462b612e..f598e324152a 100644 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -12,15 +12,10 @@ class App extends BaseConfig * Base Site URL * -------------------------------------------------------------------------- * - * URL to your CodeIgniter root. Typically this will be your base URL, + * URL to your CodeIgniter root. Typically, this will be your base URL, * WITH a trailing slash: * * http://example.com/ - * - * If this is not set then CodeIgniter will try guess the protocol, domain - * and path to your installation. However, you should always configure this - * explicitly and never rely on auto-guessing, especially in production - * environments. */ public string $baseURL = 'http://localhost:8080/'; From 439872a5428194276dd37acbe1ec2255f762bc02 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 15:41:23 +0900 Subject: [PATCH 143/290] docs: add about "defined('BASEPATH') OR exit('No direct script access allowed')" --- user_guide_src/source/installation/upgrade_4xx.rst | 3 +++ user_guide_src/source/installation/upgrade_controllers.rst | 1 + user_guide_src/source/installation/upgrade_migrations.rst | 2 +- user_guide_src/source/installation/upgrade_views.rst | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_4xx.rst b/user_guide_src/source/installation/upgrade_4xx.rst index 86ad86664590..c36cb47b8d62 100644 --- a/user_guide_src/source/installation/upgrade_4xx.rst +++ b/user_guide_src/source/installation/upgrade_4xx.rst @@ -49,6 +49,9 @@ Application Structure - The **application** folder is renamed as **app** and the framework still has **system** folders, with the same interpretation as before. - The framework now provides for a **public** folder, intended as the document root for your app. +- The ``defined('BASEPATH') OR exit('No direct script access allowed');`` line is not necessary + because files outside the **public** folder are not accessible in the standard configuration. + And CI4 no longer defines the constant ``BASEPATH``, so remove the line in all files. - There is also a **writable** folder, to hold cache data, logs, and session data. - The **app** folder looks very similar to **application** for CI3, with some name changes, and some subfolders moved to the **writable** folder. diff --git a/user_guide_src/source/installation/upgrade_controllers.rst b/user_guide_src/source/installation/upgrade_controllers.rst index ca5555de85bb..cd5f17fd3d22 100644 --- a/user_guide_src/source/installation/upgrade_controllers.rst +++ b/user_guide_src/source/installation/upgrade_controllers.rst @@ -27,6 +27,7 @@ Upgrade Guide 1. First, move all controller files to the folder **app/Controllers**. 2. Add this line just after the opening php tag: ``namespace App\Controllers;`` 3. Replace ``extends CI_Controller`` with ``extends BaseController``. +4. Remove the line ``defined('BASEPATH') OR exit('No direct script access allowed');`` if it exists. | If you use sub-directories in your controller structure, you have to change the namespace according to that. | For example, you have a version 3 controller located in **application/controllers/users/auth/Register.php**, diff --git a/user_guide_src/source/installation/upgrade_migrations.rst b/user_guide_src/source/installation/upgrade_migrations.rst index 31eabc0766e1..791cb81a3314 100644 --- a/user_guide_src/source/installation/upgrade_migrations.rst +++ b/user_guide_src/source/installation/upgrade_migrations.rst @@ -26,7 +26,7 @@ Upgrade Guide 1. If your v3 project uses sequential migration names you have to change those to timestamp names. 2. You have to move all migration files to the new folder **app/Database/Migrations**. -3. Remove the following line ``defined('BASEPATH') OR exit('No direct script access allowed');``. +3. Remove the line ``defined('BASEPATH') OR exit('No direct script access allowed');`` if it exists. 4. Add this line just after the opening php tag: ``namespace App\Database\Migrations;``. 5. Below the ``namespace App\Database\Migrations;`` line add this line: ``use CodeIgniter\Database\Migration;`` 6. Replace ``extends CI_Migration`` with ``extends Migration``. diff --git a/user_guide_src/source/installation/upgrade_views.rst b/user_guide_src/source/installation/upgrade_views.rst index 3e56735e3102..09ffa427d33c 100644 --- a/user_guide_src/source/installation/upgrade_views.rst +++ b/user_guide_src/source/installation/upgrade_views.rst @@ -28,6 +28,7 @@ Upgrade Guide - from ``$this->load->view('directory_name/file_name')`` to ``return view('directory_name/file_name');`` - from ``$content = $this->load->view('file', $data, TRUE);`` to ``$content = view('file', $data);`` 3. (optional) You can change the echo syntax in views from ```` to ```` +4. Remove the line ``defined('BASEPATH') OR exit('No direct script access allowed');`` if it exists. Code Example ============ From 7d08abd56840188d324ad59359589295d38b63fe Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 26 Jan 2023 15:42:11 +0900 Subject: [PATCH 144/290] docs: replace title Event with Hooks This doc is for CI3 users. --- user_guide_src/source/installation/upgrade_4xx.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_4xx.rst b/user_guide_src/source/installation/upgrade_4xx.rst index c36cb47b8d62..3b8d7a5be348 100644 --- a/user_guide_src/source/installation/upgrade_4xx.rst +++ b/user_guide_src/source/installation/upgrade_4xx.rst @@ -135,8 +135,8 @@ Helpers - `redirect() Documentation CodeIgniter 3.X `_ - `redirect() Documentation CodeIgniter 4.X <../general/common_functions.html#redirect>`_ -Events -====== +Hooks +===== - `Hooks `_ have been replaced by :doc:`../extending/events`. From 5ad5b58dbc967b2575c1e0d365a441883b5b222f Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Thu, 26 Jan 2023 23:39:52 +0700 Subject: [PATCH 145/290] docs: fix wrong header memcachedhandler in session --- 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 d7b68b36895f..ff8e80303afd 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -671,7 +671,7 @@ 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 +Configure MemcachedHandler ---------------------- The ``$savePath`` format is fairly straightforward here, From d27c07e0cd22260ad2c642a389ce3bedfc8160b3 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Thu, 26 Jan 2023 23:47:48 +0700 Subject: [PATCH 146/290] docs: fix underline to short after header --- 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 ff8e80303afd..a7a63c1b48df 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -672,7 +672,7 @@ expire earlier than that time). This happens very rarely, but should be considered as it may result in loss of sessions. Configure MemcachedHandler ----------------------- +-------------------------- The ``$savePath`` format is fairly straightforward here, being just a ``host:port`` pair: From 3df19deb6ed0779d8de6b6de02b8c023fb0317bd Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 27 Jan 2023 09:35:29 +0900 Subject: [PATCH 147/290] docs: fix command sample with non-existent command --- user_guide_src/source/cli/spark_commands.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/cli/spark_commands.rst b/user_guide_src/source/cli/spark_commands.rst index e336623ec571..b7d51576ae2a 100644 --- a/user_guide_src/source/cli/spark_commands.rst +++ b/user_guide_src/source/cli/spark_commands.rst @@ -33,8 +33,9 @@ You may always pass ``--no-header`` to suppress the header output, helpful for p For all of the commands CodeIgniter provides, if you do not provide the required arguments, you will be prompted for the information it needs to run correctly:: - > php spark migrate:version - > Version? + > php spark make::controller + + Controller class name : Calling Commands ================ From 1ac62bc4cf1b8c8a1a7ed2e08de22f72710ae65e Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 27 Jan 2023 09:37:48 +0900 Subject: [PATCH 148/290] docs: add sub sections --- user_guide_src/source/cli/spark_commands.rst | 29 ++++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/user_guide_src/source/cli/spark_commands.rst b/user_guide_src/source/cli/spark_commands.rst index b7d51576ae2a..06dd096145bc 100644 --- a/user_guide_src/source/cli/spark_commands.rst +++ b/user_guide_src/source/cli/spark_commands.rst @@ -12,13 +12,18 @@ CodeIgniter ships with the official command **spark** and built-in commands. Running Commands **************** -The commands are run from the command line, in the root directory. -A custom script, **spark** has been provided that is used to run any of the CLI commands:: +Running via CLI +=============== + +The commands are run from the command line, in the project root directory. +The command file **spark** has been provided that is used to run any of the CLI commands:: > php spark When called without specifying a command, a simple help page is displayed that also provides a list of -available commands. You should pass the name of the command as the first argument to run that command:: +available commands. + +You should pass the name of the command as the first argument to run that command:: > php spark migrate @@ -55,9 +60,21 @@ so that you can choose to display it or not. Using Help Command ****************** -You can get help about any CLI command using the help command as follows:: +spark help +========== + +You can get help about any CLI command using the ``help`` command as follows:: > php spark help db:seed -Use the **list** command to get a list of available commands and their descriptions, sorted by categories. -You may also use ``spark list --simple`` to get a raw list of all available commands, sorted alphabetically. + +spark list +========== + +Use the ``list`` command to get a list of available commands and their descriptions, sorted by categories:: + + > php spark list + +You may also use the ``--simple`` option to get a raw list of all available commands, sorted alphabetically:: + + > php spark list --simple From 22c8f210fcf5eac9af56a231387e5ffe8019d39b Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 27 Jan 2023 09:38:22 +0900 Subject: [PATCH 149/290] docs: add `--help` usage --- user_guide_src/source/cli/spark_commands.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user_guide_src/source/cli/spark_commands.rst b/user_guide_src/source/cli/spark_commands.rst index 06dd096145bc..8ac2ecba1d6a 100644 --- a/user_guide_src/source/cli/spark_commands.rst +++ b/user_guide_src/source/cli/spark_commands.rst @@ -67,6 +67,9 @@ You can get help about any CLI command using the ``help`` command as follows:: > php spark help db:seed +Since v4.3.0, you can also use the ``--help`` option instead of the ``help`` command:: + + > php spark db:seed --help spark list ========== From 9232e88fab9485a218108a417ae18450f61b8631 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 27 Jan 2023 10:07:22 +0900 Subject: [PATCH 150/290] docs: add note for Auto Routing (Improved) in _remap() --- user_guide_src/source/incoming/controllers.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/incoming/controllers.rst b/user_guide_src/source/incoming/controllers.rst index cd7023653b55..15bee929c214 100644 --- a/user_guide_src/source/incoming/controllers.rst +++ b/user_guide_src/source/incoming/controllers.rst @@ -494,6 +494,8 @@ CodeIgniter also permits you to map your URIs using its :ref:`Defined Route Rout Remapping Method Calls ********************** +.. note:: **Auto Routing (Improved)** does not support this feature intentionally. + As noted above, the second segment of the URI typically determines which method in the controller gets called. CodeIgniter permits you to override this behavior through the use of the ``_remap()`` method: From 3548566979130c4db8f22f6f981ff3b086090393 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 27 Jan 2023 10:20:05 +0900 Subject: [PATCH 151/290] docs: move sentence Without this change, the meaning of the sample code is not clear. --- user_guide_src/source/incoming/controllers.rst | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/user_guide_src/source/incoming/controllers.rst b/user_guide_src/source/incoming/controllers.rst index 15bee929c214..94e750e5049a 100644 --- a/user_guide_src/source/incoming/controllers.rst +++ b/user_guide_src/source/incoming/controllers.rst @@ -221,13 +221,12 @@ class so that it can inherit all its methods. folders/files in **app/Controllers/**, when a match wasn't found against defined routes. That's why your folders/files MUST start with a capital letter and the rest MUST be lowercase. + If you want another naming convention you need to manually define it using the + :ref:`Defined Route Routing `. Here is an example based on PSR-4 Autoloader: .. literalinclude:: controllers/012.php - If you want another naming convention you need to manually define it using the - :ref:`Defined Route Routing `. - Methods ======= @@ -390,13 +389,12 @@ class so that it can inherit all its methods. folders/files in **app/Controllers/**, when a match wasn't found against defined routes. That's why your folders/files MUST start with a capital letter and the rest MUST be lowercase. + If you want another naming convention you need to manually define it using the + :ref:`Defined Route Routing `. Here is an example based on PSR-4 Autoloader: .. literalinclude:: controllers/012.php - If you want another naming convention you need to manually define it using the - :ref:`Defined Route Routing `. - Methods ======= From 4ddb1ff5b2f883c3fe3717fe45fefc26c957a649 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 27 Jan 2023 11:04:35 +0900 Subject: [PATCH 152/290] docs: add section titles --- user_guide_src/source/incoming/controllers.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/incoming/controllers.rst b/user_guide_src/source/incoming/controllers.rst index 94e750e5049a..89d12eff7109 100644 --- a/user_guide_src/source/incoming/controllers.rst +++ b/user_guide_src/source/incoming/controllers.rst @@ -230,11 +230,18 @@ class so that it can inherit all its methods. Methods ======= + +Default Method +-------------- + In the above example, the method name is ``getIndex()``. -The method (HTTP verb + ``Index()``) is loaded if the **second segment** of the URI is empty. +The method (HTTP verb + ``Index()``) is called the **default method**, and is loaded if the **second segment** of the URI is empty. -**The second segment of the URI determines which method in the -controller gets called.** +Normal Methods +-------------- + +The second segment of the URI determines which method in the +controller gets called. Let's try it. Add a new method to your controller: From eeb8f35a4b9f5c3b0d3161b8fe91fd5c53b7a363 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 27 Jan 2023 11:05:10 +0900 Subject: [PATCH 153/290] docs: add method visibility --- user_guide_src/source/incoming/controllers.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/incoming/controllers.rst b/user_guide_src/source/incoming/controllers.rst index 89d12eff7109..7f098f7f1a6b 100644 --- a/user_guide_src/source/incoming/controllers.rst +++ b/user_guide_src/source/incoming/controllers.rst @@ -230,6 +230,13 @@ class so that it can inherit all its methods. Methods ======= +Method Visibility +----------------- + +When you define a method that is executable via HTTP request, the method must be +declared as ``public``. + +.. warning:: For security reasons be sure to declare any new utility methods as ``protected`` or ``private``. Default Method -------------- @@ -253,8 +260,6 @@ Now load the following URL to see the ``getComment()`` method:: You should see your new message. -.. warning:: For security reasons be sure to declare any new utility methods as ``protected`` or ``private``. - Passing URI Segments to Your Methods ==================================== From 82c02fb72d9762c1bfb59d7e2b2207440200776c Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 27 Jan 2023 11:05:37 +0900 Subject: [PATCH 154/290] docs: add note for parameter count check --- user_guide_src/source/incoming/controllers.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/user_guide_src/source/incoming/controllers.rst b/user_guide_src/source/incoming/controllers.rst index 7f098f7f1a6b..232e7c169a42 100644 --- a/user_guide_src/source/incoming/controllers.rst +++ b/user_guide_src/source/incoming/controllers.rst @@ -274,6 +274,10 @@ Your method will be passed URI segments 3 and 4 (``'sandals'`` and ``'123'``): .. literalinclude:: controllers/022.php +.. note:: If there are more parameters in the URI than the method parameters, + Auto Routing (Improved) does not execute the method, and it results in 404 + Not Found. + Defining a Default Controller ============================= From 7c9e5d6c14bee297395aa7115861df4e4423191c Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Fri, 27 Jan 2023 18:29:37 +0400 Subject: [PATCH 155/290] Update upgrade_405.rst str_to_upper() is not a built in php function. https://www.php.net/manual/en/function.strtoupper.php --- user_guide_src/source/installation/upgrade_405.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_405.rst b/user_guide_src/source/installation/upgrade_405.rst index e3c07c13a816..844e76b25200 100644 --- a/user_guide_src/source/installation/upgrade_405.rst +++ b/user_guide_src/source/installation/upgrade_405.rst @@ -39,7 +39,7 @@ Additional related deprecations from the HTTP layer: * ``Message::isJSON()``: Check the "Content-Type" header directly * ``Request[Interface]::isValidIP()``: Use the Validation class with ``valid_ip`` -* ``Request[Interface]::getMethod()``: The ``$upper`` parameter will be removed, use str_to_upper() +* ``Request[Interface]::getMethod()``: The ``$upper`` parameter will be removed, use strtoupper() * ``Request[Trait]::$ipAddress``: This property will become private * ``Request::$proxyIPs``: This property will be removed; access ``config('App')->proxyIPs`` directly * ``Request::__construct()``: The constructor will no longer take ``Config\App`` and has been made nullable to aid transition From 73d2354a00e0a3085343f7c7d79fc00be1a0ddd5 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Fri, 27 Jan 2023 18:32:43 +0400 Subject: [PATCH 156/290] Update upgrade_412.rst Grammatical fix. --- user_guide_src/source/installation/upgrade_412.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_412.rst b/user_guide_src/source/installation/upgrade_412.rst index ae0ba9d6fefc..1fec935f7ec6 100644 --- a/user_guide_src/source/installation/upgrade_412.rst +++ b/user_guide_src/source/installation/upgrade_412.rst @@ -46,7 +46,7 @@ BaseConnection::query() Return Values ``BaseConnection::query()`` method in prior versions was incorrectly returning BaseResult objects even if the query failed. This method will now return ``false`` for failed queries (or throw an Exception if ``DBDebug`` is ``true``) and will return booleans for write-type queries. Review any use -of ``query()`` method and be assess whether the value might be boolean instead of Result object. +of ``query()`` method and assess whether the value might be boolean instead of Result object. For a better idea of what queries are write-type queries, check ``BaseConnection::isWriteType()`` and any DBMS-specific override ``isWriteType()`` in the relevant Connection class. From a3a6daef153ad3db48212708e2d5c532cf76634d Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Fri, 27 Jan 2023 18:34:11 +0400 Subject: [PATCH 157/290] Update upgrade_431.rst It says Encryption.php but the fields below are all in Email.php --- user_guide_src/source/installation/upgrade_431.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_431.rst b/user_guide_src/source/installation/upgrade_431.rst index 4adce6d4af2d..ae9ae6e27e1b 100644 --- a/user_guide_src/source/installation/upgrade_431.rst +++ b/user_guide_src/source/installation/upgrade_431.rst @@ -66,7 +66,7 @@ and it is recommended that you merge the updated versions with your application: Config ------ -- app/Config/Encryption.php +- app/Config/Email.php - Set the default value ``''`` to ``$fromEmail``, ``$fromName``, ``$recipients``, ``$SMTPHost``, ``$SMTPUser`` and ``$SMTPPass`` to apply environment variable (**.env**) values. From 46a18130738d7ef6b1db56cddce5c3f039af6f75 Mon Sep 17 00:00:00 2001 From: Noritaka IZUMI Date: Sat, 28 Jan 2023 10:41:29 +0900 Subject: [PATCH 158/290] docs: fix typos and grammatical errors --- system/Router/RouteCollection.php | 6 +++--- system/Router/RouteCollectionInterface.php | 4 ++-- system/Router/Router.php | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 08741be408fc..6745b4130bc0 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -722,7 +722,7 @@ public function group(string $name, ...$params) * POST /photos/{id} update * * @param string $name The name of the resource/controller to route to. - * @param array|null $options An list of possible ways to customize the routing. + * @param array|null $options A list of possible ways to customize the routing. */ public function resource(string $name, ?array $options = null): RouteCollectionInterface { @@ -816,7 +816,7 @@ public function resource(string $name, ?array $options = null): RouteCollectionI * POST /photos/delete/{id} delete deleting the specified photo object * * @param string $name The name of the controller to route to. - * @param array|null $options An list of possible ways to customize the routing. + * @param array|null $options A list of possible ways to customize the routing. */ public function presenter(string $name, ?array $options = null): RouteCollectionInterface { @@ -1467,7 +1467,7 @@ private function checkSubdomains($subdomains): bool } /** - * Examines the HTTP_HOST to get a best match for the subdomain. It + * Examines the HTTP_HOST to get the best match for the subdomain. It * won't be perfect, but should work for our needs. * * It's especially not perfect since it's possible to register a domain diff --git a/system/Router/RouteCollectionInterface.php b/system/Router/RouteCollectionInterface.php index 00ac88f4b7e2..a8f264a8b8fd 100644 --- a/system/Router/RouteCollectionInterface.php +++ b/system/Router/RouteCollectionInterface.php @@ -21,7 +21,7 @@ * add a number of additional methods to customize how the routes are defined. * * The RouteCollection provides the Router with the routes so that it can determine - * which controller should be ran. + * which controller should be run. */ interface RouteCollectionInterface { @@ -157,7 +157,7 @@ public function getRoutes(); public function getHTTPVerb(); /** - * Attempts to look up a route based on it's destination. + * Attempts to look up a route based on its destination. * * If a route exists: * diff --git a/system/Router/Router.php b/system/Router/Router.php index 83cb6b8244f9..137aa4e43af9 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -324,7 +324,7 @@ public function getMatchedRouteOptions() /** * Sets the value that should be used to match the index.php file. Defaults - * to index.php but this allows you to modify it in case your are using + * to index.php but this allows you to modify it in case you are using * something like mod_rewrite to remove the page. This allows you to set * it a blank. * @@ -376,7 +376,7 @@ public function getLocale() } /** - * Checks Defined Routs. + * Checks Defined Routes. * * Compares the uri string against the routes that the * RouteCollection class defined for us, attempting to find a match. @@ -495,7 +495,7 @@ protected function checkRoutes(string $uri): bool } /** - * Checks Auto Routs. + * Checks Auto Routes. * * Attempts to match a URI path against Controllers and directories * found in APPPATH/Controllers, to find a matching route. From 158e21af5a335624be4697d7ff8a4e38838d641b Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 28 Jan 2023 11:25:33 +0900 Subject: [PATCH 159/290] fix: Autoloader may not add Composer package's namespaces --- system/Autoloader/Autoloader.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index 0f1d91eb7809..f838451ce6fb 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -381,7 +381,12 @@ private function loadComposerNamespaces(ClassLoader $composer, array $composerPa ); } // This method requires Composer 2.0.14 or later. - $packageList = InstalledVersions::getAllRawData()[0]['versions']; + $allData = InstalledVersions::getAllRawData(); + $packageList = []; + + foreach ($allData as $list) { + $packageList = array_merge($packageList, $list['versions']); + } // Check config for $composerPackages. $only = $composerPackages['only'] ?? []; From 410cc759df0cfb4b24a85a014bf231cb490efa12 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Sat, 28 Jan 2023 19:47:52 +0800 Subject: [PATCH 160/290] docs: replace type mixed in the remaining cache class. --- system/Cache/Handlers/FileHandler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/Cache/Handlers/FileHandler.php b/system/Cache/Handlers/FileHandler.php index 98a4ccbf78c6..b95d7f9ee28c 100644 --- a/system/Cache/Handlers/FileHandler.php +++ b/system/Cache/Handlers/FileHandler.php @@ -229,7 +229,7 @@ public function isSupported(): bool * Does the heavy lifting of actually retrieving the file and * verifying it's age. * - * @return mixed + * @return array|bool|float|int|object|string|null */ protected function getItem(string $filename) { @@ -366,8 +366,8 @@ protected function getDirFileInfo(string $sourceDir, bool $topLevelOnly = true, * Options are: name, server_path, size, date, readable, writable, executable, fileperms * Returns FALSE if the file cannot be found. * - * @param string $file Path to file - * @param mixed $returnedValues Array or comma separated string of information returned + * @param string $file Path to file + * @param array|string $returnedValues Array or comma separated string of information returned * * @return array|false */ From 01d0b6ce051c268fc874a0f56482fa32da6a1e57 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 28 Jan 2023 21:21:28 +0900 Subject: [PATCH 161/290] fix: add try/catch ValueError from real_path() --- system/Common.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/Common.php b/system/Common.php index f73a4d4d78d8..f12092a5a3f8 100644 --- a/system/Common.php +++ b/system/Common.php @@ -90,7 +90,11 @@ function cache(?string $key = null) function clean_path(string $path): string { // Resolve relative paths - $path = realpath($path) ?: $path; + try { + $path = realpath($path) ?: $path; + } catch (ErrorException|ValueError $e) { + $path = 'error file path: ' . urlencode($path); + } switch (true) { case strpos($path, APPPATH) === 0: From b547b22efd0f7821a03dea6052b7db1faddb13e4 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Thu, 26 Jan 2023 17:06:18 +0700 Subject: [PATCH 162/290] fix: redis connect to protocol tls --- system/Session/Handlers/RedisHandler.php | 21 ++++++++-------- .../Handlers/Database/RedisHandlerTest.php | 24 +++++++++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/system/Session/Handlers/RedisHandler.php b/system/Session/Handlers/RedisHandler.php index 4492c4dbed32..12e89374876a 100644 --- a/system/Session/Handlers/RedisHandler.php +++ b/system/Session/Handlers/RedisHandler.php @@ -102,20 +102,21 @@ protected function setSavePath(): void throw SessionException::forEmptySavepath(); } - if (preg_match('#(?:tcp://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->savePath, $matches)) { - if (! isset($matches[3])) { - $matches[3] = ''; // Just to avoid undefined index notices below + if (preg_match('#(?:(^.*)://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->savePath, $matches)) { + if (! isset($matches[4])) { + $matches[4] = ''; // Just to avoid undefined index notices below } $this->savePath = [ - 'host' => $matches[1], - 'port' => empty($matches[2]) ? self::DEFAULT_PORT : $matches[2], - 'password' => preg_match('#auth=([^\s&]+)#', $matches[3], $match) ? $match[1] : null, - 'database' => preg_match('#database=(\d+)#', $matches[3], $match) ? (int) $match[1] : 0, - 'timeout' => preg_match('#timeout=(\d+\.\d+|\d+)#', $matches[3], $match) ? (float) $match[1] : 0.0, + 'protocol' => in_array($matches[1], ['tcp', 'tls'], true) ? $matches[1] : 'tcp', + 'host' => $matches[2], + 'port' => empty($matches[3]) ? self::DEFAULT_PORT : $matches[3], + 'password' => preg_match('#auth=([^\s&]+)#', $matches[4], $match) ? $match[1] : null, + 'database' => preg_match('#database=(\d+)#', $matches[4], $match) ? (int) $match[1] : 0, + 'timeout' => preg_match('#timeout=(\d+\.\d+|\d+)#', $matches[4], $match) ? (float) $match[1] : 0.0, ]; - preg_match('#prefix=([^\s&]+)#', $matches[3], $match) && $this->keyPrefix = $match[1]; + preg_match('#prefix=([^\s&]+)#', $matches[4], $match) && $this->keyPrefix = $match[1]; } else { throw SessionException::forInvalidSavePathFormat($this->savePath); } @@ -135,7 +136,7 @@ public function open($path, $name): bool $redis = new Redis(); - if (! $redis->connect($this->savePath['host'], ($this->savePath['host'][0] === '/' ? 0 : $this->savePath['port']), $this->savePath['timeout'])) { + if (! $redis->connect($this->savePath['protocol'] . '://' . $this->savePath['host'], ($this->savePath['host'][0] === '/' ? 0 : $this->savePath['port']), $this->savePath['timeout'])) { $this->logger->error('Session: Unable to connect to Redis with the configured settings.'); } elseif (isset($this->savePath['password']) && ! $redis->auth($this->savePath['password'])) { $this->logger->error('Session: Unable to authenticate to Redis instance.'); diff --git a/tests/system/Session/Handlers/Database/RedisHandlerTest.php b/tests/system/Session/Handlers/Database/RedisHandlerTest.php index 4a4cdcc45f19..c4ee0cf36834 100644 --- a/tests/system/Session/Handlers/Database/RedisHandlerTest.php +++ b/tests/system/Session/Handlers/Database/RedisHandlerTest.php @@ -54,6 +54,30 @@ protected function getInstance($options = []) return new RedisHandler(new AppConfig(), $this->userIpAddress); } + public function testSavePathTLSAuth() + { + $handler = $this->getInstance( + ['savePath' => 'tls://127.0.0.1:6379?auth=password&timeout=2.5'] + ); + + $savePath = $this->getPrivateProperty($handler, 'savePath'); + + $this->assertSame('password', $savePath['password']); + $this->assertSame(2.5, $savePath['timeout']); + } + + public function testSavePathTCPAuth() + { + $handler = $this->getInstance( + ['savePath' => 'tcp://127.0.0.1:6379?auth=password&timeout=2.5'] + ); + + $savePath = $this->getPrivateProperty($handler, 'savePath'); + + $this->assertSame('password', $savePath['password']); + $this->assertSame(2.5, $savePath['timeout']); + } + public function testSavePathTimeoutFloat() { $handler = $this->getInstance( From ff572f6f1d112c880e4996dabbedad5551f20ddb Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Thu, 26 Jan 2023 22:40:54 +0700 Subject: [PATCH 163/290] make default protocol property and test set savePath without protocol --- system/Session/Handlers/RedisHandler.php | 5 +++-- .../Handlers/Database/RedisHandlerTest.php | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/system/Session/Handlers/RedisHandler.php b/system/Session/Handlers/RedisHandler.php index 12e89374876a..f74fdc86d90a 100644 --- a/system/Session/Handlers/RedisHandler.php +++ b/system/Session/Handlers/RedisHandler.php @@ -24,7 +24,8 @@ */ class RedisHandler extends BaseHandler { - private const DEFAULT_PORT = 6379; + private const DEFAULT_PORT = 6379; + private const DEFAULT_PROTOCOL = 'tcp'; /** * phpRedis instance @@ -108,7 +109,7 @@ protected function setSavePath(): void } $this->savePath = [ - 'protocol' => in_array($matches[1], ['tcp', 'tls'], true) ? $matches[1] : 'tcp', + 'protocol' => in_array($matches[1], ['tcp', 'tls'], true) ? $matches[1] : self::DEFAULT_PROTOCOL, 'host' => $matches[2], 'port' => empty($matches[3]) ? self::DEFAULT_PORT : $matches[3], 'password' => preg_match('#auth=([^\s&]+)#', $matches[4], $match) ? $match[1] : null, diff --git a/tests/system/Session/Handlers/Database/RedisHandlerTest.php b/tests/system/Session/Handlers/Database/RedisHandlerTest.php index c4ee0cf36834..4a312d8fc0bf 100644 --- a/tests/system/Session/Handlers/Database/RedisHandlerTest.php +++ b/tests/system/Session/Handlers/Database/RedisHandlerTest.php @@ -54,28 +54,39 @@ protected function getInstance($options = []) return new RedisHandler(new AppConfig(), $this->userIpAddress); } + public function testSavePathWithoutProtocol() + { + $handler = $this->getInstance( + ['savePath' => '127.0.0.1:6379'] + ); + + $savePath = $this->getPrivateProperty($handler, 'savePath'); + + $this->assertSame('tcp', $savePath['protocol']); + } + public function testSavePathTLSAuth() { $handler = $this->getInstance( - ['savePath' => 'tls://127.0.0.1:6379?auth=password&timeout=2.5'] + ['savePath' => 'tls://127.0.0.1:6379?auth=password'] ); $savePath = $this->getPrivateProperty($handler, 'savePath'); + $this->assertSame('tls', $savePath['protocol']); $this->assertSame('password', $savePath['password']); - $this->assertSame(2.5, $savePath['timeout']); } public function testSavePathTCPAuth() { $handler = $this->getInstance( - ['savePath' => 'tcp://127.0.0.1:6379?auth=password&timeout=2.5'] + ['savePath' => 'tcp://127.0.0.1:6379?auth=password'] ); $savePath = $this->getPrivateProperty($handler, 'savePath'); + $this->assertSame('tcp', $savePath['protocol']); $this->assertSame('password', $savePath['password']); - $this->assertSame(2.5, $savePath['timeout']); } public function testSavePathTimeoutFloat() From 1e8b87c2f80f2a861c629834a1a5795bc2ccacbd Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Thu, 26 Jan 2023 23:27:12 +0700 Subject: [PATCH 164/290] tests: added test connect without set protocol (using default) --- .../Session/Handlers/Database/RedisHandlerTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/system/Session/Handlers/Database/RedisHandlerTest.php b/tests/system/Session/Handlers/Database/RedisHandlerTest.php index 4a312d8fc0bf..b5d67a768c47 100644 --- a/tests/system/Session/Handlers/Database/RedisHandlerTest.php +++ b/tests/system/Session/Handlers/Database/RedisHandlerTest.php @@ -117,6 +117,19 @@ public function testOpen() $this->assertTrue($handler->open($this->sessionSavePath, $this->sessionName)); } + public function testOpenWithDefaultProtocol() + { + $default = $this->sessionSavePath; + + $this->sessionSavePath = '127.0.0.1:6379'; + + $handler = $this->getInstance(); + $this->assertTrue($handler->open($this->sessionSavePath, $this->sessionName)); + + // Rollback to default + $this->sessionSavePath = $default; + } + public function testWrite() { $handler = $this->getInstance(); From 57ee387d4bb6dd4986338b79f750e68c6fef9a6c Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Sat, 28 Jan 2023 21:31:32 +0700 Subject: [PATCH 165/290] fix: possible regression tcp and tls in Redis --- system/Session/Handlers/RedisHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Session/Handlers/RedisHandler.php b/system/Session/Handlers/RedisHandler.php index f74fdc86d90a..9910637663f5 100644 --- a/system/Session/Handlers/RedisHandler.php +++ b/system/Session/Handlers/RedisHandler.php @@ -103,13 +103,13 @@ protected function setSavePath(): void throw SessionException::forEmptySavepath(); } - if (preg_match('#(?:(^.*)://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->savePath, $matches)) { + if (preg_match('#(?:(tcp|tls)://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->savePath, $matches)) { if (! isset($matches[4])) { $matches[4] = ''; // Just to avoid undefined index notices below } $this->savePath = [ - 'protocol' => in_array($matches[1], ['tcp', 'tls'], true) ? $matches[1] : self::DEFAULT_PROTOCOL, + 'protocol' => ! empty($matches[1]) ? $matches[1] : self::DEFAULT_PROTOCOL, 'host' => $matches[2], 'port' => empty($matches[3]) ? self::DEFAULT_PORT : $matches[3], 'password' => preg_match('#auth=([^\s&]+)#', $matches[4], $match) ? $match[1] : null, From 8787e8e3285faca9cf78966e2d342a346757f3fa Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Sat, 28 Jan 2023 22:05:42 +0700 Subject: [PATCH 166/290] docs: note about tls protocol in RedisHandler Session --- user_guide_src/source/changelogs/v4.3.2.rst | 2 ++ user_guide_src/source/libraries/sessions.rst | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.3.2.rst b/user_guide_src/source/changelogs/v4.3.2.rst index f1b8e7c5dc72..4652ee995b85 100644 --- a/user_guide_src/source/changelogs/v4.3.2.rst +++ b/user_guide_src/source/changelogs/v4.3.2.rst @@ -27,6 +27,8 @@ Deprecations Bugs Fixed ********** +* Fixed : ``Session`` Redis connect to protocol TLS + See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index a7a63c1b48df..7f316c569276 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -613,7 +613,7 @@ RedisHandler Driver .. note:: Since Redis doesn't have a locking mechanism exposed, locks for this driver are emulated by a separate value that is kept for up - to 300 seconds. + to 300 seconds. With ``v4.3.2`` or above, You can connect ``Redis`` with **TLS** protocol. Redis is a storage engine typically used for caching and popular because of its high performance, which is also probably your reason to use the From 0cff4f79d6f00648965708b2765f3656fc362628 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 29 Jan 2023 10:35:05 +0900 Subject: [PATCH 167/290] docs: add Bugs Fixed items in changelogs/v4.3.2 --- user_guide_src/source/changelogs/v4.3.2.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.3.2.rst b/user_guide_src/source/changelogs/v4.3.2.rst index 4652ee995b85..9249f86fdb5d 100644 --- a/user_guide_src/source/changelogs/v4.3.2.rst +++ b/user_guide_src/source/changelogs/v4.3.2.rst @@ -27,7 +27,12 @@ Deprecations Bugs Fixed ********** -* Fixed : ``Session`` Redis connect to protocol TLS +- **QueryBuilder:** ``where()`` generates incorrect SQL when using ``RawSql`` +- **QueryBuilder:** ``RawSql`` passed to ``set()`` disappears without error +- **Session:** Can't connect to Redis with ``RedisHandler`` over TLS +- **Autoloader:** May not add Composer package's namespaces +- **Parser:** ``!`` does not work if delimiters are changed +- **UserGuide:** Added missing items in ChangeLog and Upgrading Guide v4.3.0 See the repo's `CHANGELOG.md `_ From 7ef79c55d6da0999093031853aaadd73b5ab33c4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 29 Jan 2023 10:54:31 +0900 Subject: [PATCH 168/290] docs: improve text decration --- user_guide_src/source/helpers/url_helper.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst index 7607610d64a5..4e843ead4af0 100644 --- a/user_guide_src/source/helpers/url_helper.rst +++ b/user_guide_src/source/helpers/url_helper.rst @@ -116,10 +116,10 @@ The following functions are available: Returns the full URL (including segments) of the page the user was previously on. - .. note:: Due to security issues of blindly trusting the HTTP_REFERER system variable, CodeIgniter will + .. note:: Due to security issues of blindly trusting the ``HTTP_REFERER`` system variable, CodeIgniter will store previously visited pages in the session if it's available. This ensures that we always use a known and trusted source. If the session hasn't been loaded, or is otherwise unavailable, - then a sanitized version of HTTP_REFERER will be used. + then a sanitized version of ``HTTP_REFERER`` will be used. .. php:function:: uri_string() @@ -151,7 +151,7 @@ The following functions are available: .. php:function:: index_page([$altConfig = null]) :param \\Config\\App $altConfig: Alternate configuration to use - :returns: 'index_page' value + :returns: The ``indexPage`` value :rtype: string Returns your site **indexPage**, as specified in your config file. @@ -180,7 +180,7 @@ The following functions are available: be a string or an array. .. note:: If you are building links that are internal to your application - do not include the base URL (`http://...`). This will be added + do not include the base URL (``http://...``). This will be added automatically from the information specified in your config file. Include only the URI segments you wish appended to the URL. @@ -304,12 +304,12 @@ The following functions are available: .. literalinclude:: url_helper/016.php - .. note:: The only URLs recognized are those that start with "www." or with "://". + .. note:: The only URLs recognized are those that start with ``www.`` or with ``://``. .. php:function:: url_title($str[, $separator = '-'[, $lowercase = false]]) :param string $str: Input string - :param string $separator: Word separator (usually '-' or '_') + :param string $separator: Word separator (usually ``'-'`` or ``'_'``) :param bool $lowercase: Whether to transform the output string to lowercase :returns: URL-formatted string :rtype: string @@ -321,7 +321,7 @@ The following functions are available: .. literalinclude:: url_helper/017.php The second parameter determines the word delimiter. By default dashes - are used. Preferred options are: **-** (dash) or **_** (underscore). + are used. Preferred options are: ``-`` (dash) or ``_`` (underscore). Example: @@ -337,7 +337,7 @@ The following functions are available: .. php:function:: mb_url_title($str[, $separator = '-'[, $lowercase = false]]) :param string $str: Input string - :param string $separator: Word separator (usually '-' or '_') + :param string $separator: Word separator (usually ``'-'`` or ``'_'``) :param bool $lowercase: Whether to transform the output string to lowercase :returns: URL-formatted string :rtype: string @@ -348,11 +348,11 @@ The following functions are available: .. php:function:: prep_url([$str = ''[, $secure = false]]) :param string $str: URL string - :param boolean $secure: true for https:// + :param boolean $secure: true for ``https://`` :returns: Protocol-prefixed URL string :rtype: string - This function will add *http://* or *https://* in the event that a protocol prefix + This function will add ``http://`` or ``https://`` in the event that a protocol prefix is missing from a URL. Pass the URL string to the function like this: From b2ffe417b69a84b5fe5f5c6ada5ef89dec6d9ead Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 29 Jan 2023 11:00:57 +0900 Subject: [PATCH 169/290] docs: improve explanation for url_is() --- user_guide_src/source/helpers/url_helper.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst index 4e843ead4af0..1b17159bbe4a 100644 --- a/user_guide_src/source/helpers/url_helper.rst +++ b/user_guide_src/source/helpers/url_helper.rst @@ -388,14 +388,17 @@ The following functions are available: .. php:function:: url_is($path) - :param string $path: The path to check the current URI path against. + :param string $path: The URL path relative to baseURL to check the current URI path against. :rtype: boolean Compares the current URL's path against the given path to see if they match. Example: .. literalinclude:: url_helper/023.php - This would match ``http://example.com/admin``. You can use the ``*`` wildcard to match + This would match **http://example.com/admin**. It would match **http://example.com/subdir/admin** + if your baseURL is ``http://example.com/subdir/``. + + You can use the ``*`` wildcard to match any other applicable characters in the URL: .. literalinclude:: url_helper/024.php From 4d73ea1002e3929bf411bc19250fa2f1aa2d5fb2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 29 Jan 2023 19:01:39 +0900 Subject: [PATCH 170/290] refactor: rename method name It does not return anything. --- system/Debug/Toolbar/Collectors/Views.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/Debug/Toolbar/Collectors/Views.php b/system/Debug/Toolbar/Collectors/Views.php index 2e036ff19c85..ea44dae44bd5 100644 --- a/system/Debug/Toolbar/Collectors/Views.php +++ b/system/Debug/Toolbar/Collectors/Views.php @@ -73,7 +73,7 @@ class Views extends BaseCollector */ protected $views = []; - private function getViewer(): void + private function initViewer(): void { $this->viewer ??= Services::renderer(); } @@ -84,7 +84,7 @@ private function getViewer(): void */ protected function formatTimelineData(): array { - $this->getViewer(); + $this->initViewer(); $data = []; @@ -120,7 +120,7 @@ protected function formatTimelineData(): array */ public function getVarData(): array { - $this->getViewer(); + $this->initViewer(); return [ 'View Data' => $this->viewer->getData(), @@ -132,7 +132,7 @@ public function getVarData(): array */ public function getBadgeValue(): int { - $this->getViewer(); + $this->initViewer(); return count($this->viewer->getPerformanceData()); } From bc518ea356b83c2932dc7215a9167034332bb679 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 24 Jan 2023 08:18:44 +0900 Subject: [PATCH 171/290] docs: add missing composer.json in Mandatory File Changes --- .../source/installation/upgrade_430.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index 396b45b25f60..f8caccad8558 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -73,6 +73,24 @@ Mock Config Classes - Add **types** to the properties in these Config classes. You may need to fix the property values to match the property types. +composer.json +============= + +If you installed CodeIgnter manually, and are using Composer, +you need to remove the "kint-php/kint" line, and run ``composer update``. + +.. code-block:: text + + { + ... + "require": { + ... + "kint-php/kint": "^4.2", <-- Remove this line + ... + }, + ... + } + Breaking Changes **************** From 2285ee7a03fcb5605dea9b5342ad7e7ae3e14228 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 09:13:36 +0900 Subject: [PATCH 172/290] docs: ComposerScripts::postUpdate is not needed for end users It removes system/ThirdParty/Kint/* when running `composer update` after removing `kint-php/kint` in composer.json. --- user_guide_src/source/installation/upgrade_430.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_430.rst b/user_guide_src/source/installation/upgrade_430.rst index f8caccad8558..6e37811777fe 100644 --- a/user_guide_src/source/installation/upgrade_430.rst +++ b/user_guide_src/source/installation/upgrade_430.rst @@ -77,7 +77,7 @@ composer.json ============= If you installed CodeIgnter manually, and are using Composer, -you need to remove the "kint-php/kint" line, and run ``composer update``. +you need to remove the following lines, and run ``composer update``. .. code-block:: text @@ -89,6 +89,13 @@ you need to remove the "kint-php/kint" line, and run ``composer update``. ... }, ... + "scripts": { + "post-update-cmd": [ + "CodeIgniter\\ComposerScripts::postUpdate" <-- Remove this line + ], + "test": "phpunit" + }, + ... } Breaking Changes From 7a84dd4ed61b57b3fcf69fce5c59b3f8b76ab4e6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 13:50:36 +0900 Subject: [PATCH 173/290] docs: fix typos --- user_guide_src/source/installation/installing_composer.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/installation/installing_composer.rst b/user_guide_src/source/installation/installing_composer.rst index 1a37329b4936..b76283f96b23 100644 --- a/user_guide_src/source/installation/installing_composer.rst +++ b/user_guide_src/source/installation/installing_composer.rst @@ -53,7 +53,7 @@ If you omit the "project-root" argument, the command will create an > composer install --no-dev - The above command will removes the Composer packages only for development + The above command will remove the Composer packages only for development that are not needed in the production environment. This will greatly reduce the vendor folder size. @@ -139,7 +139,7 @@ In your project root:: > composer install --no-dev - The above command will removes the Composer packages only for development + The above command will remove the Composer packages only for development that are not needed in the production environment. This will greatly reduce the vendor folder size. From cf0806b072ef29693d322928dde7f4a5a90317c2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 14:07:20 +0900 Subject: [PATCH 174/290] docs: add note for upgrading tools --- .../source/installation/installing_composer.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/user_guide_src/source/installation/installing_composer.rst b/user_guide_src/source/installation/installing_composer.rst index b76283f96b23..c92c365e2f85 100644 --- a/user_guide_src/source/installation/installing_composer.rst +++ b/user_guide_src/source/installation/installing_composer.rst @@ -85,6 +85,10 @@ Cons You still need to check for file changes in the **project space** (root, app, public, writable) after updating. +.. note:: There are some third-party CodeIgniter modules available to assist + with merging changes to the project space: + `Explore on Packagist `_. + Structure --------- @@ -178,6 +182,10 @@ Cons You still need to check for file changes in the **project space** (root, app, public, writable) after updating. +.. note:: There are some third-party CodeIgniter modules available to assist + with merging changes to the project space: + `Explore on Packagist `_. + Structure --------- From becefa3de5e5855d9f97b65de3e22068bf7381e4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 14:08:01 +0900 Subject: [PATCH 175/290] docs: change decration for file paths --- .../source/installation/installing_manual.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/installation/installing_manual.rst b/user_guide_src/source/installation/installing_manual.rst index 9ae1403b6cbd..c0d35de86bbb 100644 --- a/user_guide_src/source/installation/installing_manual.rst +++ b/user_guide_src/source/installation/installing_manual.rst @@ -9,8 +9,8 @@ The `CodeIgniter 4 framework `_ repository holds the released versions of the framework. It is intended for developers who do not wish to use Composer. -Develop your app inside the ``app`` folder, and the ``public`` folder -will be your public-facing document root. Do not change anything inside the ``system`` +Develop your app inside the **app** folder, and the **public** folder +will be your public-facing document root. Do not change anything inside the **system** folder! .. note:: This is the installation technique closest to that described @@ -37,7 +37,7 @@ See :ref:`initial-configuration` for the detail. Upgrading ========= -Download a new copy of the framework, and then replace the ``system`` folder. +Download a new copy of the framework, and then replace the **system** folder. Read the :doc:`upgrade instructions `, and check Breaking Changes and Enhancements. @@ -65,8 +65,8 @@ If you want to take advantage of the system message translations, they can be added to your project in a similar fashion. Download the `latest version of them `_. -Extract the downloaded zip, and copy the ``Language`` folder contents in it -to your ``PROJECT_ROOT/app/Languages`` folder. +Extract the downloaded zip, and copy the **Language** folder contents in it +to your **app/Languages** folder. This would need to be repeated to incorporate any updates to the translations. From bf3ef0fb1ec26ee9fbfa474282366942e5b40769 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 14:16:10 +0900 Subject: [PATCH 176/290] docs: add "and merge them" --- user_guide_src/source/installation/installing_composer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/installing_composer.rst b/user_guide_src/source/installation/installing_composer.rst index c92c365e2f85..00f736dbe603 100644 --- a/user_guide_src/source/installation/installing_composer.rst +++ b/user_guide_src/source/installation/installing_composer.rst @@ -83,7 +83,7 @@ Cons ---- You still need to check for file changes in the **project space** -(root, app, public, writable) after updating. +(root, app, public, writable) and merge them after updating. .. note:: There are some third-party CodeIgniter modules available to assist with merging changes to the project space: From 59261c3b72898a20a002275efdecc3989e8f0921 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 23 Jan 2023 14:16:43 +0900 Subject: [PATCH 177/290] docs: change the expression --- user_guide_src/source/installation/installing_manual.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/installing_manual.rst b/user_guide_src/source/installation/installing_manual.rst index c0d35de86bbb..7e592046f3a5 100644 --- a/user_guide_src/source/installation/installing_manual.rst +++ b/user_guide_src/source/installation/installing_manual.rst @@ -49,7 +49,8 @@ Download and run. Cons ==== -You are responsible for merge conflicts when updating. +You need to check for file changes in the **project space** +(root, app, public, tests, writable) and merge them by yourself. Structure ========= From 636b38cbf644bfc295d578672e8b1f9df101fd31 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 29 Jan 2023 21:20:47 +0900 Subject: [PATCH 178/290] test: remove unneeded code --- .../HTTP/IncomingRequestDetectingTest.php | 66 +++++++++++-------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/tests/system/HTTP/IncomingRequestDetectingTest.php b/tests/system/HTTP/IncomingRequestDetectingTest.php index ab0bfb5c6092..88b69fe6b028 100644 --- a/tests/system/HTTP/IncomingRequestDetectingTest.php +++ b/tests/system/HTTP/IncomingRequestDetectingTest.php @@ -31,127 +31,139 @@ protected function setUp(): void $_POST = $_GET = $_SERVER = $_REQUEST = $_ENV = $_COOKIE = $_SESSION = []; - $origin = 'http://www.example.com/index.php/woot?code=good#pos'; - + // The URI object is not used in detectPath(). + $origin = 'http://www.example.com/index.php/woot?code=good#pos'; $this->request = new IncomingRequest(new App(), new URI($origin), null, new UserAgent()); } public function testPathDefault() { - $this->request->uri = '/index.php/woot?code=good#pos'; + // /index.php/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/index.php/woot'; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $expected = 'woot'; + + $expected = 'woot'; $this->assertSame($expected, $this->request->detectPath()); } public function testPathEmpty() { - $this->request->uri = '/'; + // / $_SERVER['REQUEST_URI'] = '/'; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $expected = '/'; + + $expected = '/'; $this->assertSame($expected, $this->request->detectPath()); } public function testPathRequestURI() { - $this->request->uri = '/index.php/woot?code=good#pos'; + // /index.php/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/index.php/woot'; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $expected = 'woot'; + + $expected = 'woot'; $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } public function testPathRequestURINested() { - $this->request->uri = '/ci/index.php/woot?code=good#pos'; + // /ci/index.php/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/index.php/woot'; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $expected = 'woot'; + + $expected = 'woot'; $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } public function testPathRequestURISubfolder() { - $this->request->uri = '/ci/index.php/popcorn/woot?code=good#pos'; + // /ci/index.php/popcorn/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/ci/index.php/popcorn/woot'; $_SERVER['SCRIPT_NAME'] = '/ci/index.php'; - $expected = 'popcorn/woot'; + + $expected = 'popcorn/woot'; $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } public function testPathRequestURINoIndex() { - $this->request->uri = '/sub/example'; + // /sub/example $_SERVER['REQUEST_URI'] = '/sub/example'; $_SERVER['SCRIPT_NAME'] = '/sub/index.php'; - $expected = 'example'; + + $expected = 'example'; $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } public function testPathRequestURINginx() { - $this->request->uri = '/ci/index.php/woot?code=good#pos'; + // /ci/index.php/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/index.php/woot?code=good'; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $expected = 'woot'; + + $expected = 'woot'; $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } public function testPathRequestURINginxRedirecting() { - $this->request->uri = '/?/ci/index.php/woot'; + // /?/ci/index.php/woot $_SERVER['REQUEST_URI'] = '/?/ci/woot'; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $expected = 'ci/woot'; + + $expected = 'ci/woot'; $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } public function testPathRequestURISuppressed() { - $this->request->uri = '/woot?code=good#pos'; + // /woot?code=good#pos $_SERVER['REQUEST_URI'] = '/woot'; $_SERVER['SCRIPT_NAME'] = '/'; - $expected = 'woot'; + + $expected = 'woot'; $this->assertSame($expected, $this->request->detectPath('REQUEST_URI')); } public function testPathQueryString() { - $this->request->uri = '/?/ci/index.php/woot'; + // /?/ci/index.php/woot $_SERVER['REQUEST_URI'] = '/?/ci/woot'; $_SERVER['QUERY_STRING'] = '/ci/woot'; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $expected = 'ci/woot'; + + $expected = 'ci/woot'; $this->assertSame($expected, $this->request->detectPath('QUERY_STRING')); } public function testPathQueryStringEmpty() { - $this->request->uri = '/?/ci/index.php/woot'; + // /?/ci/index.php/woot $_SERVER['REQUEST_URI'] = '/?/ci/woot'; $_SERVER['QUERY_STRING'] = ''; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $expected = ''; + + $expected = ''; $this->assertSame($expected, $this->request->detectPath('QUERY_STRING')); } public function testPathPathInfo() { - $this->request->uri = '/index.php/woot?code=good#pos'; + // /index.php/woot?code=good#pos $this->request->setGlobal('server', [ 'PATH_INFO' => null, ]); $_SERVER['REQUEST_URI'] = '/index.php/woot'; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $expected = 'woot'; + + $expected = 'woot'; $this->assertSame($expected, $this->request->detectPath('PATH_INFO')); } public function testPathPathInfoGlobal() { - $this->request->uri = '/index.php/woot?code=good#pos'; + // /index.php/woot?code=good#pos $this->request->setGlobal('server', [ 'PATH_INFO' => 'silliness', ]); From 7503d70386d0267f020d0b9a6a90c36282754fa6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 29 Jan 2023 21:47:26 +0900 Subject: [PATCH 179/290] test: fix incorrect tests --- tests/system/HTTP/IncomingRequestDetectingTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/system/HTTP/IncomingRequestDetectingTest.php b/tests/system/HTTP/IncomingRequestDetectingTest.php index 88b69fe6b028..b326e238f59b 100644 --- a/tests/system/HTTP/IncomingRequestDetectingTest.php +++ b/tests/system/HTTP/IncomingRequestDetectingTest.php @@ -128,8 +128,8 @@ public function testPathRequestURISuppressed() public function testPathQueryString() { - // /?/ci/index.php/woot - $_SERVER['REQUEST_URI'] = '/?/ci/woot'; + // /index.php?/ci/woot + $_SERVER['REQUEST_URI'] = '/index.php?/ci/woot'; $_SERVER['QUERY_STRING'] = '/ci/woot'; $_SERVER['SCRIPT_NAME'] = '/index.php'; @@ -139,8 +139,8 @@ public function testPathQueryString() public function testPathQueryStringEmpty() { - // /?/ci/index.php/woot - $_SERVER['REQUEST_URI'] = '/?/ci/woot'; + // /index.php? + $_SERVER['REQUEST_URI'] = '/index.php?'; $_SERVER['QUERY_STRING'] = ''; $_SERVER['SCRIPT_NAME'] = '/index.php'; From 3eab713e5c30c7e984e1a5110184119a79857b45 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 29 Jan 2023 21:47:39 +0900 Subject: [PATCH 180/290] test: add test --- tests/system/HTTP/IncomingRequestDetectingTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/system/HTTP/IncomingRequestDetectingTest.php b/tests/system/HTTP/IncomingRequestDetectingTest.php index b326e238f59b..81bdfcdc5306 100644 --- a/tests/system/HTTP/IncomingRequestDetectingTest.php +++ b/tests/system/HTTP/IncomingRequestDetectingTest.php @@ -137,6 +137,17 @@ public function testPathQueryString() $this->assertSame($expected, $this->request->detectPath('QUERY_STRING')); } + public function testPathQueryStringWithQueryString() + { + // /index.php?/ci/woot?code=good#pos + $_SERVER['REQUEST_URI'] = '/index.php?/ci/woot?code=good'; + $_SERVER['QUERY_STRING'] = '/ci/woot?code=good'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; + + $expected = 'ci/woot'; + $this->assertSame($expected, $this->request->detectPath('QUERY_STRING')); + } + public function testPathQueryStringEmpty() { // /index.php? From 97002d0b114d41669fddf8598b9fb6c0e497497a Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 13:27:50 +0900 Subject: [PATCH 181/290] docs: add PHPDocs --- system/Router/Router.php | 4 ++++ system/Router/RouterInterface.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/system/Router/Router.php b/system/Router/Router.php index 137aa4e43af9..b0247b2d93f4 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -155,6 +155,10 @@ public function __construct(RouteCollectionInterface $routes, ?Request $request } /** + * Finds the controller method corresponding to the URI. + * + * @param string|null $uri URI path relative to baseURL + * * @return Closure|string Controller classname or Closure * * @throws PageNotFoundException diff --git a/system/Router/RouterInterface.php b/system/Router/RouterInterface.php index 1efeb2e2c6e2..ffed59ca8aac 100644 --- a/system/Router/RouterInterface.php +++ b/system/Router/RouterInterface.php @@ -27,7 +27,7 @@ public function __construct(RouteCollectionInterface $routes, ?Request $request /** * Finds the controller method corresponding to the URI. * - * @param string $uri + * @param string|null $uri URI path relative to baseURL * * @return Closure|string Controller classname or Closure */ From e497c49e1bbc4c2789f432daa33e484a0824bf62 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 13:50:15 +0900 Subject: [PATCH 182/290] fix: if uri is empty string, then it should be `/` Make it the same behavior as when URIProtocol is REQUEST_URI. --- system/HTTP/IncomingRequest.php | 2 +- tests/system/HTTP/IncomingRequestDetectingTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index 3304f4664a76..a3a8de837759 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -329,7 +329,7 @@ protected function parseQueryString(): string $uri = $_SERVER['QUERY_STRING'] ?? @getenv('QUERY_STRING'); if (trim($uri, '/') === '') { - return ''; + return '/'; } if (strncmp($uri, '/', 1) === 0) { diff --git a/tests/system/HTTP/IncomingRequestDetectingTest.php b/tests/system/HTTP/IncomingRequestDetectingTest.php index 81bdfcdc5306..8f265ab13a84 100644 --- a/tests/system/HTTP/IncomingRequestDetectingTest.php +++ b/tests/system/HTTP/IncomingRequestDetectingTest.php @@ -155,7 +155,7 @@ public function testPathQueryStringEmpty() $_SERVER['QUERY_STRING'] = ''; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $expected = ''; + $expected = '/'; $this->assertSame($expected, $this->request->detectPath('QUERY_STRING')); } From edef908890c5ed54ace942133248fb86d04bbe6a Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 13:53:39 +0900 Subject: [PATCH 183/290] fix: defined `/` route may be ignored --- system/Router/Router.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/system/Router/Router.php b/system/Router/Router.php index b0247b2d93f4..8dd35c656e39 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -166,12 +166,9 @@ public function __construct(RouteCollectionInterface $routes, ?Request $request */ public function handle(?string $uri = null) { - // If we cannot find a URI to match against, then - // everything runs off of its default settings. + // If we cannot find a URI to match against, then set it to root (`/`). if ($uri === null || $uri === '') { - return strpos($this->controller, '\\') === false - ? $this->collection->getDefaultNamespace() . $this->controller - : $this->controller; + $uri = '/'; } // Decode URL-encoded string From 021c5bbde49b4b04ea04415e15c0400421e063ed Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 13:55:26 +0900 Subject: [PATCH 184/290] test: improve test method name --- tests/system/HTTP/IncomingRequestDetectingTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/HTTP/IncomingRequestDetectingTest.php b/tests/system/HTTP/IncomingRequestDetectingTest.php index 8f265ab13a84..f3be0aeb2247 100644 --- a/tests/system/HTTP/IncomingRequestDetectingTest.php +++ b/tests/system/HTTP/IncomingRequestDetectingTest.php @@ -46,7 +46,7 @@ public function testPathDefault() $this->assertSame($expected, $this->request->detectPath()); } - public function testPathEmpty() + public function testPathDefaultEmpty() { // / $_SERVER['REQUEST_URI'] = '/'; From aa4a360bfa706e7864572e59ae20fc924255d1b3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 13:55:49 +0900 Subject: [PATCH 185/290] test: update test The auto routing is disabled, so defined route should be used, or 404 should happen. --- tests/system/Router/RouterTest.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/system/Router/RouterTest.php b/tests/system/Router/RouterTest.php index 5e7733ee4ff4..5be01a47bfc6 100644 --- a/tests/system/Router/RouterTest.php +++ b/tests/system/Router/RouterTest.php @@ -39,6 +39,7 @@ protected function setUp(): void $this->collection = new RouteCollection(Services::locator(), $moduleConfig); $routes = [ + '/' => 'Home::index', 'users' => 'Users::index', 'user-setting/show-list' => 'User_setting::show_list', 'user-setting/(:segment)' => 'User_setting::detail/$1', @@ -56,20 +57,20 @@ protected function setUp(): void 'objects/(:segment)/sort/(:segment)/([A-Z]{3,7})' => 'AdminList::objectsSortCreate/$1/$2/$3', '(:segment)/(:segment)/(:segment)' => '$2::$3/$1', ]; - $this->collection->map($routes); + $this->request = Services::request(); $this->request->setMethod('get'); } - public function testEmptyURIMatchesDefaults() + public function testEmptyURIMatchesRoot() { $router = new Router($this->collection, $this->request); $router->handle(''); - $this->assertSame($this->collection->getDefaultController(), $router->controllerName()); - $this->assertSame($this->collection->getDefaultMethod(), $router->methodName()); + $this->assertSame('\Home', $router->controllerName()); + $this->assertSame('index', $router->methodName()); } public function testZeroAsURIPath() From 0b3460baaa9718d5e9d14dd7673df58f812bae9d Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 13:58:26 +0900 Subject: [PATCH 186/290] chore: update phpstan-baseline.neon.dist --- phpstan-baseline.neon.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan-baseline.neon.dist b/phpstan-baseline.neon.dist index 4259df0cc3ef..2d1f9ddd3c41 100644 --- a/phpstan-baseline.neon.dist +++ b/phpstan-baseline.neon.dist @@ -217,7 +217,7 @@ parameters: - message: "#^Call to an undefined method CodeIgniter\\\\Router\\\\RouteCollectionInterface\\:\\:getDefaultNamespace\\(\\)\\.$#" - count: 3 + count: 2 path: system/Router/Router.php - From d95d86ea897b1603a429e4971f47a852bda20acc Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 17:49:24 +0900 Subject: [PATCH 187/290] docs: improve redirect() explanation --- .../source/general/common_functions.rst | 34 +++++++++++++++---- .../source/general/common_functions/005.php | 22 ++---------- .../source/general/common_functions/006.php | 2 +- .../source/general/common_functions/013.php | 4 +++ .../source/general/common_functions/014.php | 16 +++++++++ 5 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 user_guide_src/source/general/common_functions/013.php create mode 100644 user_guide_src/source/general/common_functions/014.php diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index 4a4f9744e800..c96e171680f3 100755 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -317,7 +317,7 @@ Miscellaneous Functions .. php:function:: redirect(string $route) - :param string $route: The reverse-routed or named route to redirect the user to. + :param string $route: The route name or Controller::method to redirect the user to. :rtype: RedirectResponse .. important:: When you use this function, an instance of ``RedirectResponse`` must be returned @@ -325,18 +325,40 @@ Miscellaneous Functions the :doc:`Controller Filter <../incoming/filters>`. If you forget to return it, no redirection will occur. - Returns a RedirectResponse instance allowing you to easily create redirects: + Returns a RedirectResponse instance allowing you to easily create redirects. + + **Redirect to a URI path** + + When you want to pass a URI path (relative to baseURL), use ``redirect()->to()``: .. literalinclude:: common_functions/005.php + :lines: 2- - .. note:: ``redirect()->back()`` is not the same as browser "back" button. - It takes a visitor to "the last page viewed during the Session" when the Session is available. - If the Session hasn’t been loaded, or is otherwise unavailable, then a sanitized version of HTTP_REFERER will be used. + **Redirect to a Defined Route** + + When you want to pass a :ref:`route name ` or Controller::method + for :ref:`reverse routing `, use ``redirect()->route()``: + + .. literalinclude:: common_functions/013.php + :lines: 2- - When passing an argument into the function, it is treated as a named/reverse-routed route, not a relative/full URI, + When passing an argument into the function, it is treated as a route name or + Controller::method for reverse routing, not a relative/full URI, treating it the same as using ``redirect()->route()``: .. literalinclude:: common_functions/006.php + :lines: 2- + + **Redirect Back** + + When you want to redirect back, use ``redirect()->back()``: + + .. literalinclude:: common_functions/014.php + :lines: 2- + + .. note:: ``redirect()->back()`` is not the same as browser "back" button. + It takes a visitor to "the last page viewed during the Session" when the Session is available. + If the Session hasn’t been loaded, or is otherwise unavailable, then a sanitized version of HTTP_REFERER will be used. .. php:function:: remove_invisible_characters($str[, $urlEncoded = true]) diff --git a/user_guide_src/source/general/common_functions/005.php b/user_guide_src/source/general/common_functions/005.php index 0b2197de88ed..6f6f6286dbad 100644 --- a/user_guide_src/source/general/common_functions/005.php +++ b/user_guide_src/source/general/common_functions/005.php @@ -1,22 +1,4 @@ back(); - -// Go to specific URI -return redirect()->to('/admin'); - -// Go to a named route -return redirect()->route('named_route'); - -// Keep the old input values upon redirect so they can be used by the `old()` function -return redirect()->back()->withInput(); - -// Set a flash message -return redirect()->back()->with('foo', 'message'); - -// Copies all cookies from global response instance -return redirect()->back()->withCookies(); - -// Copies all headers from the global response instance -return redirect()->back()->withHeaders(); +// Go to specific URI path. "admin/home" is the URI path relative to baseURL. +return redirect()->to('admin/home'); diff --git a/user_guide_src/source/general/common_functions/006.php b/user_guide_src/source/general/common_functions/006.php index 7df72c5dca79..f605edb4855a 100644 --- a/user_guide_src/source/general/common_functions/006.php +++ b/user_guide_src/source/general/common_functions/006.php @@ -1,4 +1,4 @@ route('user_gallery'); diff --git a/user_guide_src/source/general/common_functions/014.php b/user_guide_src/source/general/common_functions/014.php new file mode 100644 index 000000000000..28b73d6c267c --- /dev/null +++ b/user_guide_src/source/general/common_functions/014.php @@ -0,0 +1,16 @@ +back(); + +// Keep the old input values upon redirect so they can be used by the `old()` function. +return redirect()->back()->withInput(); + +// Set a flash message. +return redirect()->back()->with('foo', 'message'); + +// Copies all cookies from global response instance. +return redirect()->back()->withCookies(); + +// Copies all headers from the global response instance. +return redirect()->back()->withHeaders(); From 5a599ddcce0bf3ce614846dd02772deb5ad480bc Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 17:51:01 +0900 Subject: [PATCH 188/290] docs: update PHPDocs --- system/Common.php | 2 +- system/HTTP/RedirectResponse.php | 4 ++-- system/Router/RouteCollection.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/system/Common.php b/system/Common.php index f12092a5a3f8..218252ed7985 100644 --- a/system/Common.php +++ b/system/Common.php @@ -863,7 +863,7 @@ function old(string $key, $default = null, $escape = 'html') * * If more control is needed, you must use $response->redirect explicitly. * - * @param string $route + * @param string|null $route Route name or Controller::method */ function redirect(?string $route = null): RedirectResponse { diff --git a/system/HTTP/RedirectResponse.php b/system/HTTP/RedirectResponse.php index 34f950de0a60..ed620c40f2ae 100644 --- a/system/HTTP/RedirectResponse.php +++ b/system/HTTP/RedirectResponse.php @@ -24,7 +24,7 @@ class RedirectResponse extends Response * Sets the URI to redirect to and, optionally, the HTTP status code to use. * If no code is provided it will be automatically determined. * - * @param string $uri The URI to redirect to + * @param string $uri The URI path (relative to baseURL) to redirect to * @param int|null $code HTTP status code * * @return $this @@ -44,7 +44,7 @@ public function to(string $uri, ?int $code = null, string $method = 'auto') * Sets the URI to redirect to but as a reverse-routed or named route * instead of a raw URI. * - * @param string $route Named route or Controller::method + * @param string $route Route name or Controller::method * * @return $this * diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index cc37d301473a..b1703f874df7 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1043,7 +1043,7 @@ public function environment(string $env, Closure $callback): RouteCollectionInte * // Equals 'path/$param1/$param2' * reverseRoute('Controller::method', $param1, $param2); * - * @param string $search Named route or Controller::method + * @param string $search Route name or Controller::method * @param int|string ...$params One or more parameters to be passed to the route. * The last parameter allows you to set the locale. * From ff43b9f871f7ce967b9a4f209bb170b40316140d Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 17:58:35 +0900 Subject: [PATCH 189/290] docs: add explanation for redirect() --- user_guide_src/source/installation/upgrade_4xx.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_4xx.rst b/user_guide_src/source/installation/upgrade_4xx.rst index 3b8d7a5be348..30ccd99f9089 100644 --- a/user_guide_src/source/installation/upgrade_4xx.rst +++ b/user_guide_src/source/installation/upgrade_4xx.rst @@ -131,9 +131,11 @@ Helpers will be :doc:`../helpers/filesystem_helper` in CI4. - `String Helper `_ functions in CI3 are included in :doc:`../helpers/text_helper` in CI4. -- In CI4, ``redirect()`` returns a ``RedirectResponse`` instance instead of redirecting and terminating script execution. You must return it. +- In CI4, ``redirect()`` is completely changed from CI3's. - `redirect() Documentation CodeIgniter 3.X `_ - `redirect() Documentation CodeIgniter 4.X <../general/common_functions.html#redirect>`_ + - In CI4, ``redirect()`` returns a ``RedirectResponse`` instance instead of redirecting and terminating script execution. You must return it. + - You need to change CI3's ``redirect('login/form')`` to ``return redirect()->to('login/form')``. Hooks ===== From d3a1e5695abc1ffd8cc46f6a12bb1dd26856c185 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 16:33:49 +0900 Subject: [PATCH 190/290] fix: base_url() removes trailing slash in baseURL --- system/Helpers/url_helper.php | 2 +- .../system/Helpers/URLHelper/SiteUrlTest.php | 45 ++++++++++++++----- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 1a3b78de5c91..5b0a0d6a690b 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -124,7 +124,7 @@ function base_url($relativePath = '', ?string $scheme = null): string $config = clone config('App'); $config->indexPage = ''; - return rtrim(site_url($relativePath, $scheme, $config), '/'); + return site_url($relativePath, $scheme, $config); } } diff --git a/tests/system/Helpers/URLHelper/SiteUrlTest.php b/tests/system/Helpers/URLHelper/SiteUrlTest.php index 1f6f081b4dc2..9873292843e5 100644 --- a/tests/system/Helpers/URLHelper/SiteUrlTest.php +++ b/tests/system/Helpers/URLHelper/SiteUrlTest.php @@ -59,27 +59,31 @@ protected function tearDown(): void * @param bool $secure * @param string $path * @param string $expectedSiteUrl + * @param string $expectedBaseUrl * * @dataProvider configProvider */ - public function testUrls($baseURL, $indexPage, $scheme, $secure, $path, $expectedSiteUrl) - { + public function testUrls( + $baseURL, + $indexPage, + $scheme, + $secure, + $path, + $expectedSiteUrl, + $expectedBaseUrl + ) { // Set the config $this->config->baseURL = $baseURL; $this->config->indexPage = $indexPage; $this->config->forceGlobalSecureRequests = $secure; $this->assertSame($expectedSiteUrl, site_url($path, $scheme, $this->config)); - - // base_url is always the trimmed site_url without index page - $expectedBaseUrl = $indexPage === '' ? $expectedSiteUrl : str_replace('/' . $indexPage, '', $expectedSiteUrl); - $expectedBaseUrl = rtrim($expectedBaseUrl, '/'); $this->assertSame($expectedBaseUrl, base_url($path, $scheme)); } public function configProvider() { - // baseURL, indexPage, scheme, secure, path, expectedSiteUrl + // baseURL, indexPage, scheme, secure, path, expectedSiteUrl, expectedBaseUrl return [ 'forceGlobalSecure' => [ 'http://example.com/', @@ -88,6 +92,7 @@ public function configProvider() true, '', 'https://example.com/index.php', + 'https://example.com/', ], [ 'http://example.com/', @@ -96,14 +101,16 @@ public function configProvider() false, '', 'http://example.com/index.php', + 'http://example.com/', ], - [ + 'baseURL missing /' => [ 'http://example.com', 'index.php', null, false, '', 'http://example.com/index.php', + 'http://example.com/', ], [ 'http://example.com/', @@ -112,6 +119,7 @@ public function configProvider() false, '', 'http://example.com/', + 'http://example.com/', ], [ 'http://example.com/', @@ -120,6 +128,7 @@ public function configProvider() false, '', 'http://example.com/banana.php', + 'http://example.com/', ], [ 'http://example.com/', @@ -128,6 +137,7 @@ public function configProvider() false, 'abc', 'http://example.com/abc', + 'http://example.com/abc', ], 'URL decode' => [ 'http://example.com/', @@ -136,6 +146,7 @@ public function configProvider() false, 'template/meet-%26-greet', 'http://example.com/template/meet-&-greet', + 'http://example.com/template/meet-&-greet', ], 'URL encode' => [ 'http://example.com/', @@ -144,6 +155,7 @@ public function configProvider() false, 'alert', 'http://example.com/%3Cs%3Ealert%3C/s%3E', + 'http://example.com/%3Cs%3Ealert%3C/s%3E', ], [ 'http://example.com/public/', @@ -152,6 +164,7 @@ public function configProvider() false, '', 'http://example.com/public/index.php', + 'http://example.com/public/', ], [ 'http://example.com/public/', @@ -160,6 +173,7 @@ public function configProvider() false, '', 'http://example.com/public/', + 'http://example.com/public/', ], [ 'http://example.com/public', @@ -168,6 +182,7 @@ public function configProvider() false, '', 'http://example.com/public/', + 'http://example.com/public/', ], [ 'http://example.com/public', @@ -176,6 +191,7 @@ public function configProvider() false, '/', 'http://example.com/public/index.php/', + 'http://example.com/public/', ], [ 'http://example.com/public/', @@ -184,6 +200,7 @@ public function configProvider() false, '/', 'http://example.com/public/index.php/', + 'http://example.com/public/', ], [ 'http://example.com/', @@ -192,6 +209,7 @@ public function configProvider() false, 'foo', 'http://example.com/index.php/foo', + 'http://example.com/foo', ], [ 'http://example.com/', @@ -200,6 +218,7 @@ public function configProvider() false, '0', 'http://example.com/index.php/0', + 'http://example.com/0', ], [ 'http://example.com/public', @@ -208,6 +227,7 @@ public function configProvider() false, 'foo', 'http://example.com/public/index.php/foo', + 'http://example.com/public/foo', ], [ 'http://example.com/', @@ -216,6 +236,7 @@ public function configProvider() false, 'foo?bar=bam', 'http://example.com/index.php/foo?bar=bam', + 'http://example.com/foo?bar=bam', ], [ 'http://example.com/', @@ -224,6 +245,7 @@ public function configProvider() false, 'test#banana', 'http://example.com/index.php/test#banana', + 'http://example.com/test#banana', ], [ 'http://example.com/', @@ -232,6 +254,7 @@ public function configProvider() false, 'foo', 'ftp://example.com/index.php/foo', + 'ftp://example.com/foo', ], [ 'http://example.com/', @@ -240,6 +263,7 @@ public function configProvider() false, 'news/local/123', 'http://example.com/index.php/news/local/123', + 'http://example.com/news/local/123', ], [ 'http://example.com/', @@ -248,6 +272,7 @@ public function configProvider() false, ['news', 'local', '123'], 'http://example.com/index.php/news/local/123', + 'http://example.com/news/local/123', ], ]; } @@ -267,12 +292,12 @@ public function testBaseURLDiscovery() $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['REQUEST_URI'] = '/test'; - $this->assertSame('http://example.com', base_url()); + $this->assertSame('http://example.com/', base_url()); $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['REQUEST_URI'] = '/test/page'; - $this->assertSame('http://example.com', base_url()); + $this->assertSame('http://example.com/', base_url()); $this->assertSame('http://example.com/profile', base_url('profile')); } From c3489f007d9f923135e2f85d5d0be19880e9e573 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 31 Jan 2023 08:50:59 +0900 Subject: [PATCH 191/290] docs: add docs --- user_guide_src/source/changelogs/v4.3.2.rst | 11 ++++ user_guide_src/source/helpers/url_helper.rst | 4 ++ .../source/installation/upgrade_432.rst | 56 +++++++++++++++++++ .../source/installation/upgrading.rst | 1 + 4 files changed, 72 insertions(+) create mode 100644 user_guide_src/source/installation/upgrade_432.rst diff --git a/user_guide_src/source/changelogs/v4.3.2.rst b/user_guide_src/source/changelogs/v4.3.2.rst index 9249f86fdb5d..fbb4e016ae63 100644 --- a/user_guide_src/source/changelogs/v4.3.2.rst +++ b/user_guide_src/source/changelogs/v4.3.2.rst @@ -12,6 +12,17 @@ Release Date: Unreleased BREAKING ******** +Behavior Changes +================ + +base_url() +---------- + +Due to a bug, in previous versions :php:func:`base_url()` without argument returned baseURL +without a trailing slash (``/``) like ``http://localhost:8080``. Now it returns +baseURL with a trailing slash. This is the same behavior as ``base_url()`` in +CodeIgniter 3. + Message Changes *************** diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst index 1b17159bbe4a..389b83c3ef62 100644 --- a/user_guide_src/source/helpers/url_helper.rst +++ b/user_guide_src/source/helpers/url_helper.rst @@ -64,6 +64,10 @@ The following functions are available: .. note:: Since v4.3.0, if you set ``Config\App::$allowedHostnames``, this returns the URL with the hostname set in it if the current URL matches. + .. note:: In previous versions, this returned the base URL without a trailing + slash (``/``) when called with no argument. The bug was fixed and + since v4.3.2 it returns the base URL with a trailing slash. + Returns your site base URL, as specified in your config file. Example: .. literalinclude:: url_helper/003.php diff --git a/user_guide_src/source/installation/upgrade_432.rst b/user_guide_src/source/installation/upgrade_432.rst new file mode 100644 index 000000000000..f61e57012d6a --- /dev/null +++ b/user_guide_src/source/installation/upgrade_432.rst @@ -0,0 +1,56 @@ +############################## +Upgrading from 4.3.1 to 4.3.2 +############################## + +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 + +Breaking Changes +**************** + +base_url() +========== + +The :php:func:`base_url()` behavior has been fix. In previous versions, when you +call ``base_url()`` **without argument**, it returned baseURL without a trailing +slash (``/``). Now it returns baseURL with a trailing slash. For example: + +- before: ``http://example.com`` +- after: ``http://example.com/`` + +If you have code to call ``base_url()`` without argument, you may need to adjust the URLs. + +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 +------ + +- @TODO + +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: + +- @TODO diff --git a/user_guide_src/source/installation/upgrading.rst b/user_guide_src/source/installation/upgrading.rst index f5600aa52d00..d754d020b55c 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_432 upgrade_431 upgrade_430 upgrade_4212 From 29901ec525ec44012eef83e679862e5db9944b36 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 31 Jan 2023 09:17:50 +0900 Subject: [PATCH 192/290] docs: add "Loading a Class in Sub-directories" --- user_guide_src/source/concepts/factories.rst | 19 +++++++++++++++++-- .../source/concepts/factories/013.php | 3 +++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 user_guide_src/source/concepts/factories/013.php diff --git a/user_guide_src/source/concepts/factories.rst b/user_guide_src/source/concepts/factories.rst index 8b868b78b434..c09134a47b54 100644 --- a/user_guide_src/source/concepts/factories.rst +++ b/user_guide_src/source/concepts/factories.rst @@ -41,10 +41,16 @@ On the other hand, Services have code to create instances, so it can create a co that needs other services or class instances. When you get a service, Services require a service name, not a class name, so the returned instance can be changed without changing the client code. +Loading Classes +*************** + +Loading a Class +=============== + .. _factories-example: -Example -======= +Model Example +------------- Take a look at **Models** as an example. You can access the Factory specific to Models by using the magic static method of the Factories class, ``Factories::models()``. @@ -79,6 +85,15 @@ you get back the instance as before: .. literalinclude:: factories/003.php +Loading a Class in Sub-directories +================================== + +If you want to load a class in sub directories, you use the ``/`` as a separator. +The following code loads **app/Libraries/Sub/SubLib.php**: + +.. literalinclude:: factories/013.php + :lines: 2- + Convenience Functions ********************* diff --git a/user_guide_src/source/concepts/factories/013.php b/user_guide_src/source/concepts/factories/013.php new file mode 100644 index 000000000000..ce10c9280939 --- /dev/null +++ b/user_guide_src/source/concepts/factories/013.php @@ -0,0 +1,3 @@ + Date: Tue, 31 Jan 2023 09:39:16 +0900 Subject: [PATCH 193/290] docs: add about Factories --- user_guide_src/source/installation/upgrade_4xx.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_4xx.rst b/user_guide_src/source/installation/upgrade_4xx.rst index 3b8d7a5be348..c28dca9cdf4f 100644 --- a/user_guide_src/source/installation/upgrade_4xx.rst +++ b/user_guide_src/source/installation/upgrade_4xx.rst @@ -100,13 +100,17 @@ Class Loading namespaces; with Composer autoloading support. - You can configure the class loading to support whatever application structure you are most comfortable with, including the "HMVC" style. +- Ci4 provides :doc:`../concepts/factories` that can load a class and share the + instance like ``$this->load`` in CI3. Libraries ========= - Your app classes can still go inside **app/Libraries**, but they don't have to. - Instead of CI3's ``$this->load->library('x');`` you can now use - ``$this->x = new X();``, following namespaced conventions for your component. + ``$this->x = new \App\Libraries\X();``, following namespaced conventions for + your component. Alternatively, you can use :doc:`../concepts/factories`: + ``$this->x = \CodeIgniter\Config\Factories::libraries('X');``. Helpers ======= @@ -160,8 +164,10 @@ Upgrading Libraries ******************* - Your app classes can still go inside **app/Libraries**, but they don't have to. -- Instead of CI3's ``$this->load->library('x');`` you can now use ``$this->x = new X();``, - following namespaced conventions for your component. +- Instead of CI3's ``$this->load->library('x');`` you can now use + ``$this->x = new \App\Libraries\X();``, following namespaced conventions for + your component. Alternatively, you can use :doc:`../concepts/factories`: + ``$this->x = \CodeIgniter\Config\Factories::libraries('X');``. - Some libraries from CodeIgniter 3 no longer exists in Version 4. For all these libraries, you have to find a new way to implement your functions. These libraries are `Calendaring `_, From 8237344c811891d4f82f1ea1f6ab2f56dd7ed213 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 31 Jan 2023 13:46:37 +0900 Subject: [PATCH 194/290] docs: add section titles --- .../source/libraries/uploaded_files.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/uploaded_files.rst b/user_guide_src/source/libraries/uploaded_files.rst index 837052c59d21..3de0653d8c19 100644 --- a/user_guide_src/source/libraries/uploaded_files.rst +++ b/user_guide_src/source/libraries/uploaded_files.rst @@ -307,20 +307,34 @@ version, use ``getMimeType()`` instead: Moving Files ============ +with Original Filename +---------------------- + Each file can be moved to its new location with the aptly named ``move()`` method. This takes the directory to move the file to as the first parameter: .. literalinclude:: uploaded_files/016.php -By default, the original filename was used. You can specify a new filename by passing it as the second parameter: +By default, the original filename was used. + +with New Filename +----------------- + +You can specify a new filename by passing it as the second parameter: .. literalinclude:: uploaded_files/017.php +Check if the File Moved +----------------------- + Once the file has been removed the temporary file is deleted. You can check if a file has been moved already with the ``hasMoved()`` method, which returns a boolean: .. literalinclude:: uploaded_files/018.php +When Moving Fails +----------------- + Moving an uploaded file can fail, with an HTTPException, under several circumstances: - the file has already been moved From 639ac1e9c0862e3709ae4eb0a0a1dfae8743999d Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 31 Jan 2023 13:47:09 +0900 Subject: [PATCH 195/290] docs: add "Overwriting Existing File" --- user_guide_src/source/libraries/uploaded_files.rst | 12 ++++++++++++ .../source/libraries/uploaded_files/022.php | 3 +++ 2 files changed, 15 insertions(+) create mode 100644 user_guide_src/source/libraries/uploaded_files/022.php diff --git a/user_guide_src/source/libraries/uploaded_files.rst b/user_guide_src/source/libraries/uploaded_files.rst index 3de0653d8c19..9e6d68f92f07 100644 --- a/user_guide_src/source/libraries/uploaded_files.rst +++ b/user_guide_src/source/libraries/uploaded_files.rst @@ -324,6 +324,18 @@ You can specify a new filename by passing it as the second parameter: .. literalinclude:: uploaded_files/017.php +By default, if the destination file already exists, a new filename will be used. +For example, if **image_name.jpg** already exists in the directory, then the +filename will be **image_name_1.jpg**. + +Overwriting Existing File +------------------------- + +You can overwrite the existing file by passing ``true`` +as the third parameter: + +.. literalinclude:: uploaded_files/022.php + Check if the File Moved ----------------------- diff --git a/user_guide_src/source/libraries/uploaded_files/022.php b/user_guide_src/source/libraries/uploaded_files/022.php new file mode 100644 index 000000000000..e834acba3d23 --- /dev/null +++ b/user_guide_src/source/libraries/uploaded_files/022.php @@ -0,0 +1,3 @@ +move(WRITEPATH . 'uploads', null, true); From eeb04898ba4f48634051147ab9323b4c4a8a8350 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 31 Jan 2023 16:58:46 +0900 Subject: [PATCH 196/290] docs: move paragraph --- user_guide_src/source/libraries/uploaded_files.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/libraries/uploaded_files.rst b/user_guide_src/source/libraries/uploaded_files.rst index 9e6d68f92f07..b91b34ecd718 100644 --- a/user_guide_src/source/libraries/uploaded_files.rst +++ b/user_guide_src/source/libraries/uploaded_files.rst @@ -324,13 +324,13 @@ You can specify a new filename by passing it as the second parameter: .. literalinclude:: uploaded_files/017.php -By default, if the destination file already exists, a new filename will be used. -For example, if **image_name.jpg** already exists in the directory, then the -filename will be **image_name_1.jpg**. - Overwriting Existing File ------------------------- +By default, if the destination file already exists, a new filename will be used. +For example, if **image_name.jpg** already exists in the directory, then the +filename will be **image_name_1.jpg** automatically. + You can overwrite the existing file by passing ``true`` as the third parameter: From 31b8b63467ac5c5a62b06f67e32a352e5d106bbb Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 31 Jan 2023 17:54:08 +0900 Subject: [PATCH 197/290] docs: fix typo Co-authored-by: Michal Sniatala --- user_guide_src/source/installation/upgrade_4xx.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_4xx.rst b/user_guide_src/source/installation/upgrade_4xx.rst index c28dca9cdf4f..0e57504934be 100644 --- a/user_guide_src/source/installation/upgrade_4xx.rst +++ b/user_guide_src/source/installation/upgrade_4xx.rst @@ -100,7 +100,7 @@ Class Loading namespaces; with Composer autoloading support. - You can configure the class loading to support whatever application structure you are most comfortable with, including the "HMVC" style. -- Ci4 provides :doc:`../concepts/factories` that can load a class and share the +- CI4 provides :doc:`../concepts/factories` that can load a class and share the instance like ``$this->load`` in CI3. Libraries From 975210720c92576504e34bbe1e43242b77140450 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 09:19:05 +0900 Subject: [PATCH 198/290] chore: remove post-update-cmd If a dev has installed the Composer packages, they will be used. There is no need to update the source code in the system/ThirdParty/ folder. --- admin/framework/composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/admin/framework/composer.json b/admin/framework/composer.json index 2cf6c1c76de2..248eea0c96cc 100644 --- a/admin/framework/composer.json +++ b/admin/framework/composer.json @@ -56,9 +56,6 @@ ] }, "scripts": { - "post-update-cmd": [ - "CodeIgniter\\ComposerScripts::postUpdate" - ], "test": "phpunit" }, "support": { From fd029ccc1d3170e7b78df9716a76c0e88e1e4cef Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 30 Jan 2023 10:06:49 +0900 Subject: [PATCH 199/290] docs: add upgrading guide --- .../source/installation/upgrade_432.rst | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_432.rst b/user_guide_src/source/installation/upgrade_432.rst index f61e57012d6a..e6d630eb47b4 100644 --- a/user_guide_src/source/installation/upgrade_432.rst +++ b/user_guide_src/source/installation/upgrade_432.rst @@ -27,6 +27,28 @@ slash (``/``). Now it returns baseURL with a trailing slash. For example: If you have code to call ``base_url()`` without argument, you may need to adjust the URLs. +Mandatory File Changes +********************** + +composer.json +============= + +If you have installed CodeIgnter manually and are using or planning to use Composer, +remove the following line: + +.. code-block:: text + + { + ... + "scripts": { + "post-update-cmd": [ + "CodeIgniter\\ComposerScripts::postUpdate" <-- Remove this line + ], + "test": "phpunit" + }, + ... + } + Project Files ************* From 77a67d01eaf88d443d3e5c79091180758451dd28 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 1 Feb 2023 16:45:10 +0900 Subject: [PATCH 200/290] docs: update sample code The value to be validated is not necessarily a string. --- user_guide_src/source/libraries/validation/034.php | 4 ++-- user_guide_src/source/libraries/validation/035.php | 4 ++-- user_guide_src/source/libraries/validation/037.php | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/user_guide_src/source/libraries/validation/034.php b/user_guide_src/source/libraries/validation/034.php index 282bef9aabbc..42be12c4cbcf 100644 --- a/user_guide_src/source/libraries/validation/034.php +++ b/user_guide_src/source/libraries/validation/034.php @@ -2,8 +2,8 @@ class MyRules { - public function even(string $str): bool + public function even($value): bool { - return (int) $str % 2 === 0; + return (int) $value % 2 === 0; } } diff --git a/user_guide_src/source/libraries/validation/035.php b/user_guide_src/source/libraries/validation/035.php index 843b623ba98c..7a571e232efe 100644 --- a/user_guide_src/source/libraries/validation/035.php +++ b/user_guide_src/source/libraries/validation/035.php @@ -2,9 +2,9 @@ class MyRules { - public function even(string $str, ?string &$error = null): bool + public function even($value, ?string &$error = null): bool { - if ((int) $str % 2 !== 0) { + if ((int) $value % 2 !== 0) { $error = lang('myerrors.evenError'); return false; diff --git a/user_guide_src/source/libraries/validation/037.php b/user_guide_src/source/libraries/validation/037.php index 9e13c663b0d7..450c5de1a9cc 100644 --- a/user_guide_src/source/libraries/validation/037.php +++ b/user_guide_src/source/libraries/validation/037.php @@ -2,14 +2,14 @@ class MyRules { - public function required_with($str, string $fields, array $data): bool + public function required_with($value, string $params, array $data): bool { - $fields = explode(',', $fields); + $params = explode(',', $params); // If the field is present we can safely assume that // the field is here, no matter whether the corresponding // search field is present or not. - $present = $this->required($str ?? ''); + $present = $this->required($value ?? ''); if ($present) { return true; @@ -20,7 +20,7 @@ public function required_with($str, string $fields, array $data): bool // as $fields is the lis $requiredFields = []; - foreach ($fields as $field) { + foreach ($params as $field) { if (array_key_exists($field, $data)) { $requiredFields[] = $field; } From bc432c7873896148f82469dad2befab79492946e Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 1 Feb 2023 16:48:43 +0900 Subject: [PATCH 201/290] docs: update description The value to be validated is not necessarily a string. --- user_guide_src/source/libraries/validation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/validation.rst b/user_guide_src/source/libraries/validation.rst index 045abc4604c1..f913079d6f9d 100644 --- a/user_guide_src/source/libraries/validation.rst +++ b/user_guide_src/source/libraries/validation.rst @@ -603,7 +603,7 @@ shown above. The primary benefit here is that it provides some extra navigation Creating a Rule Class --------------------- -Within the file itself, each method is a rule and must accept a string as the first parameter, and must return +Within the file itself, each method is a rule and must accept a value to validate as the first parameter, and must return a boolean true or false value signifying true if it passed the test or false if it did not: .. literalinclude:: validation/034.php @@ -624,7 +624,7 @@ Your new custom rule could now be used just like any other rule: Allowing Parameters ------------------- -If your method needs to work with parameters, the function will need a minimum of three parameters: the string to validate, +If your method needs to work with parameters, the function will need a minimum of three parameters: the value to validate, the parameter string, and an array with all of the data that was submitted the form. The ``$data`` array is especially handy for rules like ``required_with`` that needs to check the value of another submitted field to base its result on: From d7c0af733ac12a902cb6347fa8bdd8a2879d4784 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 1 Feb 2023 16:51:19 +0900 Subject: [PATCH 202/290] docs: improve description --- user_guide_src/source/libraries/validation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/validation.rst b/user_guide_src/source/libraries/validation.rst index f913079d6f9d..7e1731de5f82 100644 --- a/user_guide_src/source/libraries/validation.rst +++ b/user_guide_src/source/libraries/validation.rst @@ -609,7 +609,7 @@ a boolean true or false value signifying true if it passed the test or false if .. literalinclude:: validation/034.php By default, the system will look within ``CodeIgniter\Language\en\Validation.php`` for the language strings used -within errors. In custom rules, you may provide error messages by accepting a ``$error`` variable by reference in the +within errors. In custom rules, you may provide error messages by accepting a ``&$error`` variable by reference in the second parameter: .. literalinclude:: validation/035.php @@ -630,7 +630,7 @@ for rules like ``required_with`` that needs to check the value of another submit .. literalinclude:: validation/037.php -Custom errors can be returned as the fourth parameter, just as described above. +Custom errors can be returned as the fourth parameter ``&$error``, just as described above. .. _validation-using-closure-rule: From 10235a606c10c36ece138bac20e5e07897b27cd1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 09:47:17 +0900 Subject: [PATCH 203/290] docs: move / after folder names --- user_guide_src/source/outgoing/localization.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/outgoing/localization.rst b/user_guide_src/source/outgoing/localization.rst index 2a1f3f5b4197..d6e4a1d1a47b 100644 --- a/user_guide_src/source/outgoing/localization.rst +++ b/user_guide_src/source/outgoing/localization.rst @@ -17,11 +17,11 @@ with different supported languages. Language strings are stored in the **app/Language** directory, with a sub-directory for each supported language:: - /app - /Language - /en + app/ + Language/ + en/ App.php - /fr + fr/ App.php .. important:: Locale detection only works for web-based requests that use the IncomingRequest class. From c7e34fbeec7b5d1a89ed906b69ca59c7a52acc1e Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 09:48:53 +0900 Subject: [PATCH 204/290] docs: use ** for file paths --- .../source/outgoing/localization.rst | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/user_guide_src/source/outgoing/localization.rst b/user_guide_src/source/outgoing/localization.rst index d6e4a1d1a47b..beedb5743125 100644 --- a/user_guide_src/source/outgoing/localization.rst +++ b/user_guide_src/source/outgoing/localization.rst @@ -30,7 +30,7 @@ supported language:: Configuring the Locale ====================== -Every site will have a default language/locale they operate in. This can be set in **Config/App.php**: +Every site will have a default language/locale they operate in. This can be set in **app/Config/App.php**: .. literalinclude:: localization/001.php @@ -57,7 +57,7 @@ Should you ever need to set the locale directly you may use ``IncomingRequest::s Content Negotiation ------------------- -You can set up content negotiation to happen automatically by setting two additional settings in Config/App. +You can set up content negotiation to happen automatically by setting two additional settings in **app/Config/App.php**. The first value tells the Request class that we do want to negotiate a locale, so simply set it to true: .. literalinclude:: localization/002.php @@ -129,7 +129,7 @@ Basic Usage You can use the ``lang()`` helper function to retrieve text from any of the language files, by passing the filename and the language key as the first parameter, separated by a period (.). For example, to load the -``errorEmailMissing`` string from the ``Errors`` language file, you would do the following: +``errorEmailMissing`` string from the **Errors.php** language file, you would do the following: .. literalinclude:: localization/010.php @@ -198,8 +198,8 @@ Language Fallback ================= If you have a set of messages for a given locale, for instance -``Language/en/app.php``, you can add language variants for that locale, -each in its own folder, for instance ``Language/en-US/app.php``. +**Language/en/app.php**, you can add language variants for that locale, +each in its own folder, for instance **Language/en-US/app.php**. You only need to provide values for those messages that would be localized differently for that locale variant. Any missing message @@ -210,8 +210,8 @@ in case new messages are added to the framework and you haven't had a chance to translate them yet for your locale. So, if you are using the locale ``fr-CA``, then a localized -message will first be sought in ``Language/fr/CA``, then in -``Language/fr``, and finally in ``Language/en``. +message will first be sought in the **Language/fr-CA** directory, then in +the **Language/fr** directory, and finally in the **Language/en** directory. Message Translations ==================== @@ -219,9 +219,9 @@ Message Translations We have an "official" set of translations in their `own repository `_. -You could download that repository, and copy its ``Language`` folder -into your ``app``. The incorporated translations will be automatically -picked up because the ``App`` namespace is mapped to your ``app`` folder. +You could download that repository, and copy its **Language** folder +into your **app** folder. The incorporated translations will be automatically +picked up because the ``App`` namespace is mapped to your **app** folder. Alternately, a better practice would be to ``composer require codeigniter4/translations`` inside your project, and the translated messages will be automatically picked From f0d980f05ef8c5ad0068807fb47464418dd947e2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 09:50:00 +0900 Subject: [PATCH 205/290] docs: add note for namespaces --- user_guide_src/source/outgoing/localization.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/outgoing/localization.rst b/user_guide_src/source/outgoing/localization.rst index beedb5743125..5fa11bcce51e 100644 --- a/user_guide_src/source/outgoing/localization.rst +++ b/user_guide_src/source/outgoing/localization.rst @@ -110,6 +110,8 @@ Language Localization Creating Language Files ======================= +.. note:: The Language Files do not have namespaces. + Languages do not have any specific naming convention that are required. The file should be named logically to describe the type of content it holds. For example, let's say you want to create a file containing error messages. You might name it simply: **Errors.php**. From 743f44da67cf1aa4de8e396dce3ff31bb6900938 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 09:50:51 +0900 Subject: [PATCH 206/290] docs: improve description --- user_guide_src/source/outgoing/localization.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/outgoing/localization.rst b/user_guide_src/source/outgoing/localization.rst index 5fa11bcce51e..ccec62734a08 100644 --- a/user_guide_src/source/outgoing/localization.rst +++ b/user_guide_src/source/outgoing/localization.rst @@ -89,7 +89,7 @@ file: .. literalinclude:: localization/018.php -.. note:: ``useSupportedLocalesOnly()`` can be used since v4.3.0. +.. note:: The ``useSupportedLocalesOnly()`` method can be used since v4.3.0. Retrieving the Current Locale ============================= @@ -225,6 +225,10 @@ You could download that repository, and copy its **Language** folder into your **app** folder. The incorporated translations will be automatically picked up because the ``App`` namespace is mapped to your **app** folder. -Alternately, a better practice would be to ``composer require codeigniter4/translations`` -inside your project, and the translated messages will be automatically picked +Alternately, a better practice would be to run the following command inside your +project:: + + > composer require codeigniter4/translations + +The translated messages will be automatically picked up because the translations folders get mapped appropriately. From c19a9a44f11990b1631253b66c51ea2c678325e5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 09:51:20 +0900 Subject: [PATCH 207/290] docs: replace method with function --- user_guide_src/source/outgoing/localization.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/outgoing/localization.rst b/user_guide_src/source/outgoing/localization.rst index ccec62734a08..9755b50b279a 100644 --- a/user_guide_src/source/outgoing/localization.rst +++ b/user_guide_src/source/outgoing/localization.rst @@ -185,7 +185,7 @@ Specifying Locale ----------------- To specify a different locale to be used when replacing parameters, you can pass the locale in as the -third parameter to the ``lang()`` method. +third parameter to the ``lang()`` function. .. literalinclude:: localization/016.php From a10c4f6f032f9531b84a72cec1f1f762df9e0697 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 09:51:50 +0900 Subject: [PATCH 208/290] docs: make function name linkable --- user_guide_src/source/outgoing/localization.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/outgoing/localization.rst b/user_guide_src/source/outgoing/localization.rst index 9755b50b279a..7e495adb00e5 100644 --- a/user_guide_src/source/outgoing/localization.rst +++ b/user_guide_src/source/outgoing/localization.rst @@ -129,7 +129,7 @@ It also support nested definition: Basic Usage =========== -You can use the ``lang()`` helper function to retrieve text from any of the language files, by passing the +You can use the :php:func:`lang()` helper function to retrieve text from any of the language files, by passing the filename and the language key as the first parameter, separated by a period (.). For example, to load the ``errorEmailMissing`` string from the **Errors.php** language file, you would do the following: From 8a9ed47edd56c418dfe144eebbf67ec06918ab2c Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 09:52:11 +0900 Subject: [PATCH 209/290] docs: change text decration --- user_guide_src/source/outgoing/localization.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/outgoing/localization.rst b/user_guide_src/source/outgoing/localization.rst index 7e495adb00e5..2cff7700b091 100644 --- a/user_guide_src/source/outgoing/localization.rst +++ b/user_guide_src/source/outgoing/localization.rst @@ -40,9 +40,9 @@ language codes like en-US for American English, or fr-FR, for French/France. A m to this can be found on the `W3C's site `_. The system is smart enough to fall back to more generic language codes if an exact match -cannot be found. If the locale code was set to **en-US** and we only have language files set up for **en** -then those will be used since nothing exists for the more specific **en-US**. If, however, a language -directory existed at **app/Language/en-US** then that would be used first. +cannot be found. If the locale code was set to ``en-US`` and we only have language files set up for ``en`` +then those will be used since nothing exists for the more specific ``en-US``. If, however, a language +directory existed at the **app/Language/en-US** directory then that would be used first. Locale Detection ================ @@ -65,7 +65,7 @@ The first value tells the Request class that we do want to negotiate a locale, s Once this is enabled, the system will automatically negotiate the correct language based upon an array of locales that you have defined in ``$supportLocales``. If no match is found between the languages that you support, and the requested language, the first item in $supportedLocales will be used. In -the following example, the **en** locale would be used if no match is found: +the following example, the ``en`` locale would be used if no match is found: .. literalinclude:: localization/003.php @@ -80,7 +80,7 @@ segment will be your locale: .. literalinclude:: localization/004.php -In this example, if the user tried to visit ``http://example.com/fr/books``, then the locale would be +In this example, if the user tried to visit **http://example.com/fr/books**, then the locale would be set to ``fr``, assuming it was configured as a valid locale. If the value doesn't match a valid locale as defined in ``$supportedLocales`` in **app/Config/App.php**, the default From 58a5509bcadf91cc9ff92bc526207f57a93ee79b Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 09:52:30 +0900 Subject: [PATCH 210/290] docs: add `// ...` in sample code --- user_guide_src/source/outgoing/localization/001.php | 2 ++ user_guide_src/source/outgoing/localization/002.php | 2 ++ user_guide_src/source/outgoing/localization/003.php | 2 ++ 3 files changed, 6 insertions(+) diff --git a/user_guide_src/source/outgoing/localization/001.php b/user_guide_src/source/outgoing/localization/001.php index f03d25dc036f..4b0a000e3e44 100644 --- a/user_guide_src/source/outgoing/localization/001.php +++ b/user_guide_src/source/outgoing/localization/001.php @@ -6,6 +6,8 @@ class App extends BaseConfig { + // ... + public string $defaultLocale = 'en'; // ... diff --git a/user_guide_src/source/outgoing/localization/002.php b/user_guide_src/source/outgoing/localization/002.php index f4b4de2818f1..0113956ee4e3 100644 --- a/user_guide_src/source/outgoing/localization/002.php +++ b/user_guide_src/source/outgoing/localization/002.php @@ -6,6 +6,8 @@ class App extends BaseConfig { + // ... + public bool $negotiateLocale = true; // ... diff --git a/user_guide_src/source/outgoing/localization/003.php b/user_guide_src/source/outgoing/localization/003.php index 92d0d75e2e59..72f075a6da92 100644 --- a/user_guide_src/source/outgoing/localization/003.php +++ b/user_guide_src/source/outgoing/localization/003.php @@ -6,6 +6,8 @@ class App extends BaseConfig { + // ... + public array $supportedLocales = ['en', 'es', 'fr-FR']; // ... From aa8fc4861559d1e97d54d6b62b8a67522be719b0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 09:59:18 +0900 Subject: [PATCH 211/290] docs: add lang files --- user_guide_src/source/installation/upgrade_4xx.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_4xx.rst b/user_guide_src/source/installation/upgrade_4xx.rst index 30ccd99f9089..24d4b0d2ea2a 100644 --- a/user_guide_src/source/installation/upgrade_4xx.rst +++ b/user_guide_src/source/installation/upgrade_4xx.rst @@ -41,7 +41,8 @@ Downloads Namespaces ========== -- CI4 is built for PHP 7.4+, and everything in the framework is namespaced, except for the helpers. +- CI4 is built for PHP 7.4+, and everything in the framework is namespaced, + except for the helper and lang files. Application Structure ===================== From 64cd95cdd17495f3f643f25315a2c77e7579e611 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 13:24:25 +0900 Subject: [PATCH 212/290] fix: the stack trace displayed when Exception handler runs out of memory is useless --- system/Debug/Exceptions.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index bcce589db894..6dc098d4af10 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -68,6 +68,8 @@ class Exceptions */ protected $response; + private ?Throwable $exceptionCaughtByExceptionHandler = null; + /** * @param CLIRequest|IncomingRequest $request */ @@ -113,6 +115,8 @@ public function initialize() */ public function exceptionHandler(Throwable $exception) { + $this->exceptionCaughtByExceptionHandler = $exception; + [$statusCode, $exitCode] = $this->determineCodes($exception); if ($this->config->log === true && ! in_array($statusCode, $this->config->ignoreCodes, true)) { @@ -191,6 +195,13 @@ public function shutdownHandler() ['type' => $type, 'message' => $message, 'file' => $file, 'line' => $line] = $error; + if ($this->exceptionCaughtByExceptionHandler) { + $message .= "\n【Previous Exception】\n" + . get_class($this->exceptionCaughtByExceptionHandler) . "\n" + . $this->exceptionCaughtByExceptionHandler->getMessage() . "\n" + . $this->exceptionCaughtByExceptionHandler->getTraceAsString(); + } + if (in_array($type, [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE], true)) { $this->exceptionHandler(new ErrorException($message, 0, $type, $file, $line)); } From 3937e4f777890aab7ac17811221b2e2bba556499 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 18:39:05 +0900 Subject: [PATCH 213/290] test: replace deprecated expectErrorMessage() --- tests/system/Entity/EntityTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/system/Entity/EntityTest.php b/tests/system/Entity/EntityTest.php index 85addb58e56e..4ee74514a1b6 100644 --- a/tests/system/Entity/EntityTest.php +++ b/tests/system/Entity/EntityTest.php @@ -429,7 +429,7 @@ public function testCastTimestamp() public function testCastTimestampException() { $this->expectException(CastException::class); - $this->expectErrorMessage('Type casting "timestamp" expects a correct timestamp.'); + $this->expectExceptionMessage('Type casting "timestamp" expects a correct timestamp.'); $entity = $this->getCastEntity(); $entity->ninth = 'some string'; @@ -725,7 +725,7 @@ public function testCustomCast() public function testCustomCastException() { $this->expectException(CastException::class); - $this->expectErrorMessage('The "Tests\Support\Entity\Cast\NotExtendsBaseCast" class must inherit the "CodeIgniter\Entity\Cast\BaseCast" class'); + $this->expectExceptionMessage('The "Tests\Support\Entity\Cast\NotExtendsBaseCast" class must inherit the "CodeIgniter\Entity\Cast\BaseCast" class'); $entity = $this->getCustomCastEntity(); From 10cefa5ccb08b9e13bf7632ca39a3a73db327ace Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Feb 2023 15:16:26 +0000 Subject: [PATCH 214/290] chore(deps-dev): update rector/rector requirement 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.10...0.15.11) --- 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 60144c6ecb61..1fbc0fff4537 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.10", + "rector/rector": "0.15.11", "vimeo/psalm": "^5.0" }, "suggest": { From 8461519e587a43efc140e40054e1d6b9f262dd5c Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 09:36:59 +0900 Subject: [PATCH 215/290] test: replace deprecated assertObjectHasAttribute() --- tests/system/Commands/BaseCommandTest.php | 4 ++-- tests/system/Config/BaseConfigTest.php | 2 +- tests/system/Entity/EntityTest.php | 2 +- tests/system/Log/Handlers/ChromeLoggerHandlerTest.php | 5 +++-- tests/system/Test/FabricatorTest.php | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/system/Commands/BaseCommandTest.php b/tests/system/Commands/BaseCommandTest.php index e1b857e40060..068a8d832924 100644 --- a/tests/system/Commands/BaseCommandTest.php +++ b/tests/system/Commands/BaseCommandTest.php @@ -35,14 +35,14 @@ public function testMagicIssetTrue() { $command = new AppInfo($this->logger, service('commands')); - $this->assertObjectHasAttribute('group', $command); + $this->assertTrue(isset($command->group)); } public function testMagicIssetFalse() { $command = new AppInfo($this->logger, service('commands')); - $this->assertObjectNotHasAttribute('foobar', $command); + $this->assertFalse(isset($command->foobar)); } public function testMagicGet() diff --git a/tests/system/Config/BaseConfigTest.php b/tests/system/Config/BaseConfigTest.php index 014deca6c344..3d1fe88c53a8 100644 --- a/tests/system/Config/BaseConfigTest.php +++ b/tests/system/Config/BaseConfigTest.php @@ -110,7 +110,7 @@ public function testEnvironmentOverrides() // override config with shortPrefix ENV var $this->assertSame('hubbahubba', $config->delta); // incorrect env name should not inject property - $this->assertObjectNotHasAttribute('notthere', $config); + $this->assertFalse(property_exists($config, 'notthere')); // empty ENV var should not affect config setting $this->assertSame('pineapple', $config->fruit); // non-empty ENV var should overrideconfig setting diff --git a/tests/system/Entity/EntityTest.php b/tests/system/Entity/EntityTest.php index 4ee74514a1b6..1e03157ab188 100644 --- a/tests/system/Entity/EntityTest.php +++ b/tests/system/Entity/EntityTest.php @@ -96,7 +96,7 @@ public function testFill() $this->assertSame(123, $entity->foo); $this->assertSame('bar:234:bar', $entity->bar); - $this->assertObjectNotHasAttribute('baz', $entity); + $this->assertSame(4556, $entity->baz); } /** diff --git a/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php b/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php index 0587763bec09..88a27b45b351 100644 --- a/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php +++ b/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php @@ -66,10 +66,11 @@ public function testSetDateFormat() $config->handlers['CodeIgniter\Log\Handlers\TestHandler']['handles'] = ['critical']; $logger = new ChromeLoggerHandler($config->handlers['CodeIgniter\Log\Handlers\TestHandler']); + $result = $logger->setDateFormat('F j, Y'); - $this->assertObjectHasAttribute('dateFormat', $result); - $this->assertObjectHasAttribute('dateFormat', $logger); + $this->assertSame('F j, Y', $this->getPrivateProperty($result, 'dateFormat')); + $this->assertSame('F j, Y', $this->getPrivateProperty($logger, 'dateFormat')); } public function testChromeLoggerHeaderSent() diff --git a/tests/system/Test/FabricatorTest.php b/tests/system/Test/FabricatorTest.php index 7cadb350e047..6f92be2aaaad 100644 --- a/tests/system/Test/FabricatorTest.php +++ b/tests/system/Test/FabricatorTest.php @@ -406,7 +406,7 @@ public function testCreateMockSetsDatabaseFields() $this->assertIsInt($result->created_at); $this->assertIsInt($result->updated_at); - $this->assertObjectHasAttribute('deleted_at', $result); + $this->assertTrue(property_exists($result, 'deleted_at')); $this->assertNull($result->deleted_at); } From b5355a40b3563d2709229b46c8796da8e244674d Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 10:46:42 +0900 Subject: [PATCH 216/290] chore: skip AssertPropertyExistsRector --- rector.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rector.php b/rector.php index c2f296f5f8e5..797387ba4aba 100644 --- a/rector.php +++ b/rector.php @@ -40,6 +40,7 @@ use Rector\Php71\Rector\FuncCall\CountOnNullRector; use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector; +use Rector\PHPUnit\Rector\MethodCall\AssertPropertyExistsRector; use Rector\PHPUnit\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; @@ -80,6 +81,8 @@ __DIR__ . '/tests/_support', JsonThrowOnErrorRector::class, StringifyStrNeedlesRector::class, + // assertObjectHasAttribute() is deprecated + AssertPropertyExistsRector::class, RemoveUnusedPrivateMethodRector::class => [ // private method called via getPrivateMethodInvoker From fe71013b0474f2b67a204e05caa69fc084b3bb4c Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 11:18:06 +0900 Subject: [PATCH 217/290] chore: add UndefinedClass in psalm-baseline.xml --- psalm-baseline.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 6fe1103175b9..9816237b9c82 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -172,6 +172,11 @@ UnexsistenceClass + + + SimpleConfig + + 'SomeWidget' From 912153a4d5450046b1f7252627f865af26bdff10 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 10:38:55 +0900 Subject: [PATCH 218/290] test: add test --- .../system/Helpers/URLHelper/SiteUrlTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/system/Helpers/URLHelper/SiteUrlTest.php b/tests/system/Helpers/URLHelper/SiteUrlTest.php index 9873292843e5..83de57e83871 100644 --- a/tests/system/Helpers/URLHelper/SiteUrlTest.php +++ b/tests/system/Helpers/URLHelper/SiteUrlTest.php @@ -333,6 +333,28 @@ public function testSiteURLWithAllowedHostname() ); } + public function testSiteURLWithAltConfig() + { + $_SERVER['HTTP_HOST'] = 'www.example.jp'; + $_SERVER['REQUEST_URI'] = '/public'; + $_SERVER['SCRIPT_NAME'] = '/public/index.php'; + + $this->config->baseURL = 'http://example.com/public/'; + $this->config->allowedHostnames = ['www.example.jp']; + + // URI object are updated in IncomingRequest constructor. + $request = Services::incomingrequest($this->config); + Services::injectMock('request', $request); + + $altConfig = clone $this->config; + $altConfig->baseURL = 'http://alt.example.com/public/'; + + $this->assertSame( + 'http://alt.example.com/public/index.php/controller/method', + site_url('controller/method', null, $altConfig) + ); + } + public function testBaseURLWithAllowedHostname() { $_SERVER['HTTP_HOST'] = 'www.example.jp'; From 0f357f2c24963be7c33215d6b635a4ae73f12427 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 2 Feb 2023 10:40:17 +0900 Subject: [PATCH 219/290] fix: site_url() does not use alt Config --- system/Helpers/url_helper.php | 40 +++++++++++++------ .../system/Helpers/URLHelper/SiteUrlTest.php | 3 +- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 5b0a0d6a690b..4d286cac4fb3 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -26,12 +26,14 @@ * * @internal Outside the framework this should not be used directly. * - * @param string $relativePath May include queries or fragments + * @param string $relativePath May include queries or fragments + * @param App|null $config Alternative Config to use + * @param bool $useConfig Whether to use the Config baseURL * * @throws HTTPException For invalid paths. * @throws InvalidArgumentException For invalid config. */ - function _get_uri(string $relativePath = '', ?App $config = null): URI + function _get_uri(string $relativePath = '', ?App $config = null, bool $useConfig = false): URI { $config ??= config('App'); @@ -57,9 +59,13 @@ function _get_uri(string $relativePath = '', ?App $config = null): URI $request = Services::request(); /** @var App $config */ - $url = $request instanceof CLIRequest - ? rtrim($config->baseURL, '/ ') . '/' - : $request->getUri()->getBaseURL(); + if ($useConfig) { + $url = rtrim($config->baseURL, '/ ') . '/'; + } else { + $url = $request instanceof CLIRequest + ? rtrim($config->baseURL, '/ ') . '/' + : $request->getUri()->getBaseURL(); + } // Check for an index page if ($config->indexPage !== '') { @@ -88,18 +94,28 @@ function _get_uri(string $relativePath = '', ?App $config = null): URI /** * Returns a site URL as defined by the App config. * - * @param array|string $relativePath URI string or array of URI segments - * @param string|null $scheme URI scheme. E.g., http, ftp - * @param App|null $config Alternate configuration to use + * @param array|string $relativePath URI string or array of URI segments + * @param string|null $scheme URI scheme. E.g., http, ftp + * @param App|null $config Alternate configuration to use + * @param bool $dontUseConfig Set true if you don't use the Config + * baseURL even when you pass the Config */ - function site_url($relativePath = '', ?string $scheme = null, ?App $config = null): string - { + function site_url( + $relativePath = '', + ?string $scheme = null, + ?App $config = null, + bool $dontUseConfig = false + ): string { + // If $dontUseConfig is false and $config is not passed, + // we use the Config baseURL. + $useConfig = (! $dontUseConfig) && ($config !== null); + // Convert array of segments to a string if (is_array($relativePath)) { $relativePath = implode('/', $relativePath); } - $uri = _get_uri($relativePath, $config); + $uri = _get_uri($relativePath, $config, $useConfig); return URI::createURIString( $scheme ?? $uri->getScheme(), @@ -124,7 +140,7 @@ function base_url($relativePath = '', ?string $scheme = null): string $config = clone config('App'); $config->indexPage = ''; - return site_url($relativePath, $scheme, $config); + return site_url($relativePath, $scheme, $config, true); } } diff --git a/tests/system/Helpers/URLHelper/SiteUrlTest.php b/tests/system/Helpers/URLHelper/SiteUrlTest.php index 83de57e83871..fc49b6522683 100644 --- a/tests/system/Helpers/URLHelper/SiteUrlTest.php +++ b/tests/system/Helpers/URLHelper/SiteUrlTest.php @@ -322,6 +322,7 @@ public function testSiteURLWithAllowedHostname() $this->config->baseURL = 'http://example.com/public/'; $this->config->allowedHostnames = ['www.example.jp']; + Services::injectMock('config', $this->config); // URI object are updated in IncomingRequest constructor. $request = Services::incomingrequest($this->config); @@ -329,7 +330,7 @@ public function testSiteURLWithAllowedHostname() $this->assertSame( 'http://www.example.jp/public/index.php/controller/method', - site_url('controller/method', null, $this->config) + site_url('controller/method') ); } From 21a81ad70705ec7d0c8b1fb94a1ecbbd11bb7dc7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 09:03:16 +0900 Subject: [PATCH 220/290] docs: update PHPDoc --- system/HTTP/URI.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index 9af28b346e3c..587e441ffc17 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -148,11 +148,9 @@ class URI /** * Builds a representation of the string from the component parts. * - * @param string|null $scheme URI scheme. E.g., http, ftp - * @param string $authority - * @param string $path - * @param string $query - * @param string $fragment + * @param string|null $scheme URI scheme. E.g., http, ftp + * + * @return string URI string with only passed parts. Maybe incomplete as a URI. */ public static function createURIString( ?string $scheme = null, From 011a1bd22fad6bd45f850a609d401471a14073c8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 09:03:54 +0900 Subject: [PATCH 221/290] test: add tests --- tests/system/HTTP/URITest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/system/HTTP/URITest.php b/tests/system/HTTP/URITest.php index c88a4ca6799a..14de6e3d587b 100644 --- a/tests/system/HTTP/URITest.php +++ b/tests/system/HTTP/URITest.php @@ -978,6 +978,22 @@ public function testSetURISilent() $this->assertTrue(true); } + public function testCreateURIStringNoArguments() + { + $uri = URI::createURIString(); + + $expected = ''; + $this->assertSame($expected, $uri); + } + + public function testCreateURIStringOnlyAuthority() + { + $uri = URI::createURIString(null, 'example.com'); + + $expected = 'example.com'; + $this->assertSame($expected, $uri); + } + public function testCreateURIString() { $uri = URI::createURIString('https', 'example.com', '/'); From 0a8164b5779f4b93456e2cf6173b8eec6890f2d8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 09:09:47 +0900 Subject: [PATCH 222/290] docs: update @param description --- system/Helpers/url_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 4d286cac4fb3..ca6a60f6b237 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -26,7 +26,7 @@ * * @internal Outside the framework this should not be used directly. * - * @param string $relativePath May include queries or fragments + * @param string $relativePath URI path relative to baseURL. May include queries or fragments * @param App|null $config Alternative Config to use * @param bool $useConfig Whether to use the Config baseURL * From bab8f77a472bfee2a439f5e4e0eaff9b942f2cea Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 09:48:18 +0900 Subject: [PATCH 223/290] docs: add comments --- system/HTTP/IncomingRequest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index 3304f4664a76..19b4ea4ffc68 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -451,6 +451,9 @@ public function isSecure(): bool public function setPath(string $path, ?App $config = null) { $this->path = $path; + + // @TODO remove this. The path of the URI object should be a full URI path, + // not a URI path relative to baseURL. $this->uri->setPath($path); $config ??= $this->config; @@ -481,6 +484,9 @@ public function setPath(string $path, ?App $config = null) $this->uri->setScheme('https'); } } elseif (! is_cli()) { + // Do not change exit() to exception; Request is initialized before + // setting the exception handler, so if an exception is raised, an + // error will be displayed in the production environment. // @codeCoverageIgnoreStart exit('You have an empty or invalid base URL. The baseURL value must be set in Config\App.php, or through the .env file.'); // @codeCoverageIgnoreEnd From be96f5ff1f9eb0b248c2a3deeb32d6ffed1c2e03 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 09:49:51 +0900 Subject: [PATCH 224/290] fix: error message --- system/HTTP/IncomingRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index 19b4ea4ffc68..41f1e2c46fc4 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -486,9 +486,9 @@ public function setPath(string $path, ?App $config = null) } elseif (! is_cli()) { // Do not change exit() to exception; Request is initialized before // setting the exception handler, so if an exception is raised, an - // error will be displayed in the production environment. + // error will be displayed even if in the production environment. // @codeCoverageIgnoreStart - exit('You have an empty or invalid base URL. The baseURL value must be set in Config\App.php, or through the .env file.'); + exit('You have an empty or invalid baseURL. The baseURL value must be set in app/Config/App.php, or through the .env file.'); // @codeCoverageIgnoreEnd } From 7c552403772880f0d10592af246786c4a4145ed8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 09:50:10 +0900 Subject: [PATCH 225/290] docs: update @param description --- system/HTTP/IncomingRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index 41f1e2c46fc4..8b2ee22f087b 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -443,7 +443,7 @@ public function isSecure(): bool * instance, this can be used to change the "current URL" * for testing. * - * @param string $path URI path relative to SCRIPT_NAME + * @param string $path URI path relative to baseURL * @param App|null $config Optional alternate config to use * * @return $this From 8c39ef2834eabd2a85d59888bad7bacefebcf730 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 10:10:30 +0900 Subject: [PATCH 226/290] docs: add description for current_url() --- user_guide_src/source/helpers/url_helper.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst index 389b83c3ef62..8e2b32ebfae3 100644 --- a/user_guide_src/source/helpers/url_helper.rst +++ b/user_guide_src/source/helpers/url_helper.rst @@ -98,7 +98,9 @@ The following functions are available: :returns: The current URL :rtype: string|\\CodeIgniter\\HTTP\\URI - Returns the full URL (including segments) of the page being currently viewed. + Returns the full URL of the page being currently viewed. + When returning string, the query and fragment parts of the URL are removed. + When returning URI, the query and fragment parts are preserved. However for security reasons, it is created based on the ``Config\App`` settings, and not intended to match the browser URL. @@ -106,9 +108,10 @@ The following functions are available: Since v4.3.0, if you set ``Config\App::$allowedHostnames``, this returns the URL with the hostname set in it if the current URL matches. - .. note:: Calling this function is the same as doing this: + .. note:: Calling ``current_url()`` is the same as doing this: .. literalinclude:: url_helper/006.php + :lines: 2- .. important:: Prior to v4.1.2, this function had a bug causing it to ignore the configuration on ``Config\App::$indexPage``. From 1e15f3716de18c62b74c3fdc23864344cff92188 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 10:23:13 +0900 Subject: [PATCH 227/290] docs: add @return description --- system/Helpers/url_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index ca6a60f6b237..dd27f25fb686 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -147,12 +147,12 @@ function base_url($relativePath = '', ?string $scheme = null): string if (! function_exists('current_url')) { /** * Returns the current full URL based on the Config\App settings and IncomingRequest. - * String returns ignore query and fragment parts. * * @param bool $returnObject True to return an object instead of a string * @param IncomingRequest|null $request A request to use when retrieving the path * - * @return string|URI + * @return string|URI When returning string, the query and fragment parts are removed. + * When returning URI, the query and fragment parts are preserved. */ function current_url(bool $returnObject = false, ?IncomingRequest $request = null) { From 85a29083093bf18b5061f228cb59f424f7a60fbd Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 10:34:42 +0900 Subject: [PATCH 228/290] refactor: rename variable names --- system/Helpers/url_helper.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index dd27f25fb686..f59a788e6336 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -157,17 +157,19 @@ function base_url($relativePath = '', ?string $scheme = null): string function current_url(bool $returnObject = false, ?IncomingRequest $request = null) { $request ??= Services::request(); - $path = $request->getPath(); + $routePath = $request->getPath(); + $currentURI = $request->getUri(); + $relativePath = $routePath; // Append queries and fragments - if ($query = $request->getUri()->getQuery()) { - $path .= '?' . $query; + if ($query = $currentURI->getQuery()) { + $relativePath .= '?' . $query; } - if ($fragment = $request->getUri()->getFragment()) { - $path .= '#' . $fragment; + if ($fragment = $currentURI->getFragment()) { + $relativePath .= '#' . $fragment; } - $uri = _get_uri($path); + $uri = _get_uri($relativePath); return $returnObject ? $uri : URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath()); } From 6c410f58a085992b91437656df22934e71ed4964 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 11:22:56 +0900 Subject: [PATCH 229/290] refactor: base_url() and site_url() --- system/Helpers/url_helper.php | 100 ++++++++++++++++++++++++++++------ 1 file changed, 82 insertions(+), 18 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index f59a788e6336..3c36c7156e74 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -94,28 +94,65 @@ function _get_uri(string $relativePath = '', ?App $config = null, bool $useConfi /** * Returns a site URL as defined by the App config. * - * @param array|string $relativePath URI string or array of URI segments - * @param string|null $scheme URI scheme. E.g., http, ftp - * @param App|null $config Alternate configuration to use - * @param bool $dontUseConfig Set true if you don't use the Config - * baseURL even when you pass the Config + * @param array|string $relativePath URI string or array of URI segments + * @param string|null $scheme URI scheme. E.g., http, ftp + * @param App|null $config Alternate configuration to use */ - function site_url( - $relativePath = '', - ?string $scheme = null, - ?App $config = null, - bool $dontUseConfig = false - ): string { - // If $dontUseConfig is false and $config is not passed, - // we use the Config baseURL. - $useConfig = (! $dontUseConfig) && ($config !== null); + function site_url($relativePath = '', ?string $scheme = null, ?App $config = null): string + { + $appConfig = null; + if ($config === null) { + $appConfig = config('App'); + } // Convert array of segments to a string if (is_array($relativePath)) { $relativePath = implode('/', $relativePath); } - $uri = _get_uri($relativePath, $config, $useConfig); + // If a full URI was passed then convert it + if (strpos($relativePath, '://') !== false) { + $full = new URI($relativePath); + $relativePath = URI::createURIString( + null, + null, + $full->getPath(), + $full->getQuery(), + $full->getFragment() + ); + } + + $relativePath = URI::removeDotSegments($relativePath); + + $request = Services::request(); + + if ($config === null) { + $url = $request instanceof CLIRequest + ? rtrim($appConfig->baseURL, '/ ') . '/' + // Use the current baseURL for multiple domain support + : $request->getUri()->getBaseURL(); + + $config = $appConfig; + } else { + $url = rtrim($config->baseURL, '/ ') . '/'; + } + + // Check for an index page + if ($config->indexPage !== '') { + $url .= $config->indexPage; + + // Check if we need a separator + if ($relativePath !== '' && $relativePath[0] !== '/' && $relativePath[0] !== '?') { + $url .= '/'; + } + } + + $uri = new URI($url . $relativePath); + + // Check if the baseURL scheme needs to be coerced into its secure version + if ($config->forceGlobalSecureRequests && $uri->getScheme() === 'http') { + $uri->setScheme('https'); + } return URI::createURIString( $scheme ?? $uri->getScheme(), @@ -137,10 +174,37 @@ function site_url( */ function base_url($relativePath = '', ?string $scheme = null): string { - $config = clone config('App'); - $config->indexPage = ''; + // Convert array of segments to a string + if (is_array($relativePath)) { + $relativePath = implode('/', $relativePath); + } + + // If a full URI was passed then convert it + if (strpos($relativePath, '://') !== false) { + $full = new URI($relativePath); + $relativePath = URI::createURIString( + null, + null, + $full->getPath(), + $full->getQuery(), + $full->getFragment() + ); + } + + $relativePath = URI::removeDotSegments($relativePath); + + $request = Services::request(); + $currentBaseURL = $request->getUri()->getBaseURL(); - return site_url($relativePath, $scheme, $config, true); + $uri = new URI($currentBaseURL . $relativePath); + + return URI::createURIString( + $scheme ?? $uri->getScheme(), + $uri->getAuthority(), + $uri->getPath(), + $uri->getQuery(), + $uri->getFragment() + ); } } From ff0321f14008401b9a1ed99b1350ee5275dbfc6f Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 11:42:24 +0900 Subject: [PATCH 230/290] refactor: current_url() _get_uri() is no longer used. --- system/Helpers/url_helper.php | 18 +++++++++++++++++- .../Helpers/URLHelper/CurrentUrlTest.php | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 3c36c7156e74..de3a967949cd 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -32,6 +32,8 @@ * * @throws HTTPException For invalid paths. * @throws InvalidArgumentException For invalid config. + * + * @deprecated No longer used. */ function _get_uri(string $relativePath = '', ?App $config = null, bool $useConfig = false): URI { @@ -224,7 +226,11 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul $routePath = $request->getPath(); $currentURI = $request->getUri(); + $url = $request->getUri()->getBaseURL(); + + $config = config('App'); $relativePath = $routePath; + // Append queries and fragments if ($query = $currentURI->getQuery()) { $relativePath .= '?' . $query; @@ -233,7 +239,17 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul $relativePath .= '#' . $fragment; } - $uri = _get_uri($relativePath); + // Check for an index page + if ($config->indexPage !== '') { + $url .= $config->indexPage; + + // Check if we need a separator + if ($relativePath !== '' && $relativePath[0] !== '/' && $relativePath[0] !== '?') { + $url .= '/'; + } + } + + $uri = new URI($url . $relativePath); return $returnObject ? $uri : URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath()); } diff --git a/tests/system/Helpers/URLHelper/CurrentUrlTest.php b/tests/system/Helpers/URLHelper/CurrentUrlTest.php index ed48be914321..faee0608b54f 100644 --- a/tests/system/Helpers/URLHelper/CurrentUrlTest.php +++ b/tests/system/Helpers/URLHelper/CurrentUrlTest.php @@ -63,6 +63,10 @@ public function testCurrentURLReturnsBasicURL() $this->config->baseURL = 'http://example.com/public'; + // URI object are updated in IncomingRequest constructor. + $request = Services::incomingrequest($this->config); + Services::injectMock('request', $request); + $this->assertSame('http://example.com/public/index.php/', current_url()); } From 60fc61b192e37a921ab65c9797af5671fe142602 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 11:59:00 +0900 Subject: [PATCH 231/290] refactor: extract _get_uri() function --- system/Helpers/url_helper.php | 110 +++++++--------------------------- 1 file changed, 22 insertions(+), 88 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index de3a967949cd..37873f8ce437 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -26,21 +26,23 @@ * * @internal Outside the framework this should not be used directly. * - * @param string $relativePath URI path relative to baseURL. May include queries or fragments - * @param App|null $config Alternative Config to use - * @param bool $useConfig Whether to use the Config baseURL + * @param array|string $relativePath URI string or array of URI segments + * @param App|null $config Alternative Config to use + * @param bool $indexPage Whether to add the $indexPage value * * @throws HTTPException For invalid paths. * @throws InvalidArgumentException For invalid config. - * - * @deprecated No longer used. */ - function _get_uri(string $relativePath = '', ?App $config = null, bool $useConfig = false): URI + function _get_uri($relativePath = '', ?App $config = null, bool $indexPage = false): URI { - $config ??= config('App'); + $appConfig = null; + if ($config === null) { + $appConfig = config('App'); + } - if ($config->baseURL === '') { - throw new InvalidArgumentException('_get_uri() requires a valid baseURL.'); + // Convert array of segments to a string + if (is_array($relativePath)) { + $relativePath = implode('/', $relativePath); } // If a full URI was passed then convert it @@ -57,20 +59,21 @@ function _get_uri(string $relativePath = '', ?App $config = null, bool $useConfi $relativePath = URI::removeDotSegments($relativePath); - // Build the full URL based on $config and $relativePath $request = Services::request(); - /** @var App $config */ - if ($useConfig) { - $url = rtrim($config->baseURL, '/ ') . '/'; - } else { + if ($config === null) { $url = $request instanceof CLIRequest - ? rtrim($config->baseURL, '/ ') . '/' + ? rtrim($appConfig->baseURL, '/ ') . '/' + // Use the current baseURL for multiple domain support : $request->getUri()->getBaseURL(); + + $config = $appConfig; + } else { + $url = rtrim($config->baseURL, '/ ') . '/'; } // Check for an index page - if ($config->indexPage !== '') { + if ($indexPage && $config->indexPage !== '') { $url .= $config->indexPage; // Check if we need a separator @@ -79,16 +82,7 @@ function _get_uri(string $relativePath = '', ?App $config = null, bool $useConfi } } - $url .= $relativePath; - - $uri = new URI($url); - - // Check if the baseURL scheme needs to be coerced into its secure version - if ($config->forceGlobalSecureRequests && $uri->getScheme() === 'http') { - $uri->setScheme('https'); - } - - return $uri; + return new URI($url . $relativePath); } } @@ -107,50 +101,12 @@ function site_url($relativePath = '', ?string $scheme = null, ?App $config = nul $appConfig = config('App'); } - // Convert array of segments to a string - if (is_array($relativePath)) { - $relativePath = implode('/', $relativePath); - } - - // If a full URI was passed then convert it - if (strpos($relativePath, '://') !== false) { - $full = new URI($relativePath); - $relativePath = URI::createURIString( - null, - null, - $full->getPath(), - $full->getQuery(), - $full->getFragment() - ); - } - - $relativePath = URI::removeDotSegments($relativePath); - - $request = Services::request(); + $uri = _get_uri($relativePath, $config, true); if ($config === null) { - $url = $request instanceof CLIRequest - ? rtrim($appConfig->baseURL, '/ ') . '/' - // Use the current baseURL for multiple domain support - : $request->getUri()->getBaseURL(); - $config = $appConfig; - } else { - $url = rtrim($config->baseURL, '/ ') . '/'; } - // Check for an index page - if ($config->indexPage !== '') { - $url .= $config->indexPage; - - // Check if we need a separator - if ($relativePath !== '' && $relativePath[0] !== '/' && $relativePath[0] !== '?') { - $url .= '/'; - } - } - - $uri = new URI($url . $relativePath); - // Check if the baseURL scheme needs to be coerced into its secure version if ($config->forceGlobalSecureRequests && $uri->getScheme() === 'http') { $uri->setScheme('https'); @@ -176,29 +132,7 @@ function site_url($relativePath = '', ?string $scheme = null, ?App $config = nul */ function base_url($relativePath = '', ?string $scheme = null): string { - // Convert array of segments to a string - if (is_array($relativePath)) { - $relativePath = implode('/', $relativePath); - } - - // If a full URI was passed then convert it - if (strpos($relativePath, '://') !== false) { - $full = new URI($relativePath); - $relativePath = URI::createURIString( - null, - null, - $full->getPath(), - $full->getQuery(), - $full->getFragment() - ); - } - - $relativePath = URI::removeDotSegments($relativePath); - - $request = Services::request(); - $currentBaseURL = $request->getUri()->getBaseURL(); - - $uri = new URI($currentBaseURL . $relativePath); + $uri = _get_uri($relativePath); return URI::createURIString( $scheme ?? $uri->getScheme(), From 3202415345e1297ab691291da87472d28ea8f6be Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 12:58:46 +0900 Subject: [PATCH 232/290] refactor: rename variable names --- system/Helpers/url_helper.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 37873f8ce437..08fe1fd89c56 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -160,7 +160,7 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul $routePath = $request->getPath(); $currentURI = $request->getUri(); - $url = $request->getUri()->getBaseURL(); + $currentBaseURL = $currentURI->getBaseURL(); $config = config('App'); $relativePath = $routePath; @@ -174,16 +174,17 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul } // Check for an index page + $indexPage = ''; if ($config->indexPage !== '') { - $url .= $config->indexPage; + $indexPage = $config->indexPage; // Check if we need a separator if ($relativePath !== '' && $relativePath[0] !== '/' && $relativePath[0] !== '?') { - $url .= '/'; + $indexPage .= '/'; } } - $uri = new URI($url . $relativePath); + $uri = new URI($currentBaseURL . $indexPage . $relativePath); return $returnObject ? $uri : URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath()); } From e29c19744af862369e5b51d3f54c4e51366d3d3e Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 17:40:51 +0900 Subject: [PATCH 233/290] fix: base_url() does not change scheme when forceGlobalSecureRequests is true and fix errors if running on CLI. --- system/Helpers/url_helper.php | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 08fe1fd89c56..83b7e1a6ec81 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -26,7 +26,8 @@ * * @internal Outside the framework this should not be used directly. * - * @param array|string $relativePath URI string or array of URI segments + * @param array|string $relativePath URI string or array of URI segments. + * May include queries or fragments. * @param App|null $config Alternative Config to use * @param bool $indexPage Whether to add the $indexPage value * @@ -82,7 +83,14 @@ function _get_uri($relativePath = '', ?App $config = null, bool $indexPage = fal } } - return new URI($url . $relativePath); + $uri = new URI($url . $relativePath); + + // Check if the baseURL scheme needs to be coerced into its secure version + if ($config->forceGlobalSecureRequests && $uri->getScheme() === 'http') { + $uri->setScheme('https'); + } + + return $uri; } } @@ -157,12 +165,10 @@ function base_url($relativePath = '', ?string $scheme = null): string function current_url(bool $returnObject = false, ?IncomingRequest $request = null) { $request ??= Services::request(); + /** @var CLIRequest|IncomingRequest $request */ $routePath = $request->getPath(); $currentURI = $request->getUri(); - $currentBaseURL = $currentURI->getBaseURL(); - - $config = config('App'); $relativePath = $routePath; // Append queries and fragments @@ -173,18 +179,7 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul $relativePath .= '#' . $fragment; } - // Check for an index page - $indexPage = ''; - if ($config->indexPage !== '') { - $indexPage = $config->indexPage; - - // Check if we need a separator - if ($relativePath !== '' && $relativePath[0] !== '/' && $relativePath[0] !== '?') { - $indexPage .= '/'; - } - } - - $uri = new URI($currentBaseURL . $indexPage . $relativePath); + $uri = _get_uri($relativePath, null, true); return $returnObject ? $uri : URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath()); } From f3f216cc353254939ea639f68a34bb267cf5cef7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 08:55:30 +0900 Subject: [PATCH 234/290] refactor: use site_url() instead of _get_uri() --- system/Helpers/url_helper.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 83b7e1a6ec81..d3e77e263e8c 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -140,15 +140,14 @@ function site_url($relativePath = '', ?string $scheme = null, ?App $config = nul */ function base_url($relativePath = '', ?string $scheme = null): string { - $uri = _get_uri($relativePath); + /** @var App $config */ + $config = clone config('App'); - return URI::createURIString( - $scheme ?? $uri->getScheme(), - $uri->getAuthority(), - $uri->getPath(), - $uri->getQuery(), - $uri->getFragment() - ); + // Use the current baseURL for multiple domain support + $config->baseURL = Services::request()->getUri()->getBaseURL(); + $config->indexPage = ''; + + return site_url($relativePath, $scheme, $config); } } From 334a44c0a4ce5e5f8e07bff1968cebc49d4c1348 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 08:59:32 +0900 Subject: [PATCH 235/290] refactor: remove unneeded parameter $indexPage --- system/Helpers/url_helper.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index d3e77e263e8c..8461cdcb5c99 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -29,15 +29,15 @@ * @param array|string $relativePath URI string or array of URI segments. * May include queries or fragments. * @param App|null $config Alternative Config to use - * @param bool $indexPage Whether to add the $indexPage value * * @throws HTTPException For invalid paths. * @throws InvalidArgumentException For invalid config. */ - function _get_uri($relativePath = '', ?App $config = null, bool $indexPage = false): URI + function _get_uri($relativePath = '', ?App $config = null): URI { $appConfig = null; if ($config === null) { + /** @var App $appConfig */ $appConfig = config('App'); } @@ -74,7 +74,7 @@ function _get_uri($relativePath = '', ?App $config = null, bool $indexPage = fal } // Check for an index page - if ($indexPage && $config->indexPage !== '') { + if ($config->indexPage !== '') { $url .= $config->indexPage; // Check if we need a separator @@ -106,10 +106,11 @@ function site_url($relativePath = '', ?string $scheme = null, ?App $config = nul { $appConfig = null; if ($config === null) { + /** @var App $appConfig */ $appConfig = config('App'); } - $uri = _get_uri($relativePath, $config, true); + $uri = _get_uri($relativePath, $config); if ($config === null) { $config = $appConfig; @@ -178,7 +179,7 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul $relativePath .= '#' . $fragment; } - $uri = _get_uri($relativePath, null, true); + $uri = _get_uri($relativePath, null); return $returnObject ? $uri : URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath()); } From 1aefd3d1940e4e23329b317fcae1d7b1964497a8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 09:04:54 +0900 Subject: [PATCH 236/290] refactor: stop reassignments --- system/Helpers/url_helper.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 8461cdcb5c99..2307f0a95d59 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -63,27 +63,28 @@ function _get_uri($relativePath = '', ?App $config = null): URI $request = Services::request(); if ($config === null) { - $url = $request instanceof CLIRequest + $baseURL = $request instanceof CLIRequest ? rtrim($appConfig->baseURL, '/ ') . '/' // Use the current baseURL for multiple domain support : $request->getUri()->getBaseURL(); $config = $appConfig; } else { - $url = rtrim($config->baseURL, '/ ') . '/'; + $baseURL = rtrim($config->baseURL, '/ ') . '/'; } // Check for an index page + $indexPage = ''; if ($config->indexPage !== '') { - $url .= $config->indexPage; + $indexPage = $config->indexPage; // Check if we need a separator if ($relativePath !== '' && $relativePath[0] !== '/' && $relativePath[0] !== '?') { - $url .= '/'; + $indexPage .= '/'; } } - $uri = new URI($url . $relativePath); + $uri = new URI($baseURL . $indexPage . $relativePath); // Check if the baseURL scheme needs to be coerced into its secure version if ($config->forceGlobalSecureRequests && $uri->getScheme() === 'http') { From a4b53194613159e12952d0b0acda2a0c59fb0f83 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 09:10:46 +0900 Subject: [PATCH 237/290] refactor: remove uneeded code --- system/Helpers/url_helper.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 2307f0a95d59..07cc1fc6624d 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -105,23 +105,8 @@ function _get_uri($relativePath = '', ?App $config = null): URI */ function site_url($relativePath = '', ?string $scheme = null, ?App $config = null): string { - $appConfig = null; - if ($config === null) { - /** @var App $appConfig */ - $appConfig = config('App'); - } - $uri = _get_uri($relativePath, $config); - if ($config === null) { - $config = $appConfig; - } - - // Check if the baseURL scheme needs to be coerced into its secure version - if ($config->forceGlobalSecureRequests && $uri->getScheme() === 'http') { - $uri->setScheme('https'); - } - return URI::createURIString( $scheme ?? $uri->getScheme(), $uri->getAuthority(), From 1cac8abd396c8c0427ab4908a0bb18b243c293c1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 09:14:07 +0900 Subject: [PATCH 238/290] fix: logic to get current baseURL --- system/Helpers/url_helper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 07cc1fc6624d..4f1a3b4b7ca1 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -131,7 +131,11 @@ function base_url($relativePath = '', ?string $scheme = null): string $config = clone config('App'); // Use the current baseURL for multiple domain support - $config->baseURL = Services::request()->getUri()->getBaseURL(); + $request = Services::request(); + $config->baseURL = $request instanceof CLIRequest + ? rtrim($config->baseURL, '/ ') . '/' + : $request->getUri()->getBaseURL(); + $config->indexPage = ''; return site_url($relativePath, $scheme, $config); From e5d8549f6d85890dbed368c91f5a9a64fb2545db Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 09:16:36 +0900 Subject: [PATCH 239/290] refactor: remove unneeded argument --- system/Helpers/url_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 4f1a3b4b7ca1..9c035144a04b 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -169,7 +169,7 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul $relativePath .= '#' . $fragment; } - $uri = _get_uri($relativePath, null); + $uri = _get_uri($relativePath); return $returnObject ? $uri : URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath()); } From 940c79454e6f77b2f01c85c1109682909e71564e Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 09:21:33 +0900 Subject: [PATCH 240/290] test: add test for CLI --- tests/system/Helpers/URLHelper/SiteUrlTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/system/Helpers/URLHelper/SiteUrlTest.php b/tests/system/Helpers/URLHelper/SiteUrlTest.php index fc49b6522683..65117c852834 100644 --- a/tests/system/Helpers/URLHelper/SiteUrlTest.php +++ b/tests/system/Helpers/URLHelper/SiteUrlTest.php @@ -314,6 +314,24 @@ public function testBaseURLService() $this->assertSame('http://example.com/ci/v4/controller/method', base_url('controller/method', null)); } + public function testBaseURLWithCLIRequest() + { + unset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']); + + $this->config->baseURL = 'http://example.com/'; + $request = Services::clirequest($this->config); + Services::injectMock('request', $request); + + $this->assertSame( + 'http://example.com/index.php/controller/method', + site_url('controller/method', null, $this->config) + ); + $this->assertSame( + 'http://example.com/controller/method', + base_url('controller/method', null) + ); + } + public function testSiteURLWithAllowedHostname() { $_SERVER['HTTP_HOST'] = 'www.example.jp'; From e0a36ce1824e0ebe65ac5a93efa1824b20cb2b22 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 20:35:48 +0900 Subject: [PATCH 241/290] test: add test cases --- .../system/Helpers/URLHelper/SiteUrlTest.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/system/Helpers/URLHelper/SiteUrlTest.php b/tests/system/Helpers/URLHelper/SiteUrlTest.php index 65117c852834..e05a7093e3da 100644 --- a/tests/system/Helpers/URLHelper/SiteUrlTest.php +++ b/tests/system/Helpers/URLHelper/SiteUrlTest.php @@ -139,6 +139,33 @@ public function configProvider() 'http://example.com/abc', 'http://example.com/abc', ], + [ + 'http://example.com/', + '', + null, + false, + '/abc', + 'http://example.com/abc', + 'http://example.com/abc', + ], + [ + 'http://example.com/', + '', + null, + false, + '/abc/', + 'http://example.com/abc/', + 'http://example.com/abc/', + ], + [ + 'http://example.com/', + '', + null, + false, + '/abc/def', + 'http://example.com/abc/def', + 'http://example.com/abc/def', + ], 'URL decode' => [ 'http://example.com/', '', From cf670a2bec208ede6238e8a72ab3a5616aa7421d Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 3 Feb 2023 18:43:54 +0900 Subject: [PATCH 242/290] chore: update Kint to 5.0.3 --- system/ThirdParty/Kint/Utils.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/ThirdParty/Kint/Utils.php b/system/ThirdParty/Kint/Utils.php index 1394b0819095..b51b33558501 100644 --- a/system/ThirdParty/Kint/Utils.php +++ b/system/ThirdParty/Kint/Utils.php @@ -118,7 +118,9 @@ public static function composerGetExtras(string $key = 'kint'): array continue; } - foreach ($packages as $package) { + // Composer 2.0 Compatibility: packages are now wrapped into a "packages" top level key instead of the whole file being the package array + // @see https://getcomposer.org/upgrade/UPGRADE-2.0.md + foreach ($packages['packages'] ?? $packages as $package) { if (isset($package['extra'][$key]) && \is_array($package['extra'][$key])) { $extras = \array_replace($extras, $package['extra'][$key]); } From 82ddac7bba7691d6afbbb5bf069829df690559ea Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 5 Feb 2023 12:43:55 +0900 Subject: [PATCH 243/290] docs: add how to download previous version user guide --- user_guide_src/source/installation/index.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/index.rst b/user_guide_src/source/installation/index.rst index 3be12a637dcc..8b71ea2833b0 100644 --- a/user_guide_src/source/installation/index.rst +++ b/user_guide_src/source/installation/index.rst @@ -10,8 +10,11 @@ Which is right for you? - If you would like the simple "download & go" install that CodeIgniter3 is known for, choose the manual installation. -However you choose to install and run CodeIgniter4, the +However you choose to install and run CodeIgniter4, the latest `user guide `_ is accessible online. +If you want to see previous versions, you can download from the +`codeigniter4/userguide `_ +repository. .. note:: Before using CodeIgniter 4, make sure that your server meets the :doc:`requirements `, in particular the PHP From 5c86c5c74c349094714ecc797323baaf159b1385 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 5 Feb 2023 13:21:32 +0900 Subject: [PATCH 244/290] docs: add versionadded --- .../source/database/query_builder.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 709e55838941..a6c9f94444a0 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -908,6 +908,8 @@ Upsert $builder->upsert() ------------------ +.. versionadded:: 4.3.0 + Generates an upsert string based on the data you supply, and runs the query. You can either pass an **array** or an **object** to the method. By default a constraint will be defined in order. A primary @@ -929,6 +931,8 @@ The first parameter is an object. $builder->getCompiledUpsert() ----------------------------- +.. versionadded:: 4.3.0 + Compiles the upsert query just like ``$builder->upsert()`` but does not *run* the query. This method simply returns the SQL query as a string. @@ -944,6 +948,8 @@ upsertBatch $builder->upsertBatch() ----------------------- +.. versionadded:: 4.3.0 + Generates an upsert string based on the data you supply, and runs the query. You can either pass an **array** or an **object** to the method. By default a constraint will be defined in order. A primary @@ -967,6 +973,8 @@ You can also upsert from a query: $builder->onConstraint() ------------------------ +.. versionadded:: 4.3.0 + Allows manually setting constraint to be used for upsert. This does not work with MySQL because MySQL checks all constraints by default. @@ -976,6 +984,9 @@ This method accepts a string or an array of columns. $builder->updateFields() ------------------------ + +.. versionadded:: 4.3.0 + Allows manually setting the fields to be updated when performing upserts. .. literalinclude:: query_builder/110.php @@ -1146,6 +1157,8 @@ method, or ``emptyTable()``. $builder->deleteBatch() ----------------------- +.. versionadded:: 4.3.0 + Generates a batch **DELETE** statement based on a set of data. .. literalinclude:: query_builder/118.php @@ -1198,6 +1211,8 @@ When $builder->when() ---------------- +.. versionadded:: 4.3.0 + This allows modifying the query based on a condition without breaking out of the query builder chain. The first parameter is the condition, and it should evaluate to a boolean. The second parameter is a callable that will be ran @@ -1223,6 +1238,8 @@ WhenNot $builder->whenNot() ------------------- +.. versionadded:: 4.3.0 + This works exactly the same way as ``$builder->when()`` except that it will only run the callable when the condition evaluates to ``false``, instead of ``true`` like ``when()``. @@ -1415,6 +1432,8 @@ Class Reference .. php:method:: setQueryAsData($query[, $alias[, $columns = null]]) + .. versionadded:: 4.3.0 + :param BaseBuilder|RawSql $query: Instance of the BaseBuilder or RawSql :param string|null $alias: Alias for query :param array|string|null $columns: Array or comma delimited string of columns in the query From 6c956b06115f7d3b82993ba99d4eb4ab81c994b2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 5 Feb 2023 13:21:58 +0900 Subject: [PATCH 245/290] docs: replace Mysql with MySQL --- user_guide_src/source/database/query_builder.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index a6c9f94444a0..02a336cc558a 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -953,7 +953,7 @@ $builder->upsertBatch() Generates an upsert string based on the data you supply, and runs the query. You can either pass an **array** or an **object** to the method. By default a constraint will be defined in order. A primary -key will be selected first and then unique keys. Mysql will use any +key will be selected first and then unique keys. MySQL will use any constraint by default. Here is an example using an array: .. literalinclude:: query_builder/108.php From 7e8b0869f9034f023b743338b834f36cc80afcda Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 5 Feb 2023 13:23:15 +0900 Subject: [PATCH 246/290] docs: add notes --- user_guide_src/source/database/query_builder.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 02a336cc558a..6b66317dfe86 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -1095,12 +1095,17 @@ UpdateBatch $builder->updateBatch() ----------------------- +.. note:: Since v4.3.0, the second parameter ``$index`` of ``updateBatch()`` has + changed to ``$constraints``. It now accepts types array, string, or ``RawSql``. + Generates an update string based on the data you supply, and runs the query. You can either pass an **array** or an **object** to the method. Here is an example using an array: .. literalinclude:: query_builder/092.php +.. note:: Since v4.3.0, the generated SQL structure has been Improved. + The first parameter is an associative array of values, the second parameter is the where key. .. note:: All values except ``RawSql`` are escaped automatically producing safer queries. From ec20625a15278211655f1ef7b523eb2ba0bc2d4e Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 5 Feb 2023 13:23:34 +0900 Subject: [PATCH 247/290] docs: update notes --- user_guide_src/source/database/query_builder.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 6b66317dfe86..8fdb3dfaabee 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -966,7 +966,8 @@ You can also upsert from a query: .. literalinclude:: query_builder/115.php -.. note:: ``setQueryAsData()`` can be used since v4.3.0. +.. note:: The ``setQueryAsData()``, ``onConstraint()``, and ``updateFields()`` + methods can be used since v4.3.0. .. note:: It is required to alias the columns of the select query to match those of the target table. @@ -1120,7 +1121,8 @@ You can also update from a query: .. literalinclude:: query_builder/116.php -.. note:: ``setQueryAsData()`` can be used since v4.3.0. +.. note:: The ``setQueryAsData()``, ``onConstraint()``, and ``updateFields()`` + methods can be used since v4.3.0. .. note:: It is required to alias the columns of the select query to match those of the target table. From cd4cc572aaeb4b6e93961615fe2022cde1bfd8eb Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 5 Feb 2023 13:24:04 +0900 Subject: [PATCH 248/290] docs: split sample code and add explanation --- .../source/database/query_builder.rst | 5 +++ .../source/database/query_builder/092.php | 24 +------------ .../source/database/query_builder/120.php | 36 +++++++++++++++++++ 3 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 user_guide_src/source/database/query_builder/120.php diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 8fdb3dfaabee..56035153db80 100755 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -1109,6 +1109,11 @@ Here is an example using an array: The first parameter is an associative array of values, the second parameter is the where key. +Since v4.3.0, you can also use the ``setQueryAsData()``, ``onConstraint()``, and +``updateFields()`` methods: + +.. literalinclude:: query_builder/120.php + .. note:: All values except ``RawSql`` are escaped automatically producing safer queries. .. warning:: When you use ``RawSql``, you MUST escape the data manually. Failure to do so could result in SQL injections. diff --git a/user_guide_src/source/database/query_builder/092.php b/user_guide_src/source/database/query_builder/092.php index 911771fc1850..407eadbfef29 100644 --- a/user_guide_src/source/database/query_builder/092.php +++ b/user_guide_src/source/database/query_builder/092.php @@ -14,28 +14,7 @@ 'date' => 'Date 2', ], ]; - $builder->updateBatch($data, ['title', 'author']); - -// OR -$builder->setData($data)->onConstraint('title, author')->updateBatch(); - -// OR -$builder->setData($data, null, 'u') - ->onConstraint(['`mytable`.`title`' => '`u`.`title`', 'author' => new RawSql('`u`.`author`')]) - ->updateBatch(); - -// OR -foreach ($data as $row) { - $builder->setData($row); -} -$builder->onConstraint('title, author')->updateBatch(); - -// OR -$builder->setData($data, true, 'u') - ->onConstraint(new RawSql('`mytable`.`title` = `u`.`title` AND `mytable`.`author` = `u`.`author`')) - ->updateFields(['last_update' => new RawSql('CURRENT_TIMESTAMP()')], true) - ->updateBatch(); /* * Produces: * UPDATE `mytable` @@ -47,6 +26,5 @@ * SET * `mytable`.`title` = `u`.`title`, * `mytable`.`name` = `u`.`name`, - * `mytable`.`date` = `u`.`date`, - * `mytable`.`last_update` = CURRENT_TIMESTAMP() // this only applies to the last scenario + * `mytable`.`date` = `u`.`date` */ diff --git a/user_guide_src/source/database/query_builder/120.php b/user_guide_src/source/database/query_builder/120.php new file mode 100644 index 000000000000..d0bea8a1cfba --- /dev/null +++ b/user_guide_src/source/database/query_builder/120.php @@ -0,0 +1,36 @@ +setData($data)->onConstraint('title, author')->updateBatch(); + +// OR +$builder->setData($data, null, 'u') + ->onConstraint(['`mytable`.`title`' => '`u`.`title`', 'author' => new RawSql('`u`.`author`')]) + ->updateBatch(); + +// OR +foreach ($data as $row) { + $builder->setData($row); +} +$builder->onConstraint('title, author')->updateBatch(); + +// OR +$builder->setData($data, true, 'u') + ->onConstraint(new RawSql('`mytable`.`title` = `u`.`title` AND `mytable`.`author` = `u`.`author`')) + ->updateFields(['last_update' => new RawSql('CURRENT_TIMESTAMP()')], true) + ->updateBatch(); +/* + * Produces: + * UPDATE `mytable` + * INNER JOIN ( + * SELECT 'Title 1' `title`, 'Author 1' `author`, 'Name 1' `name`, 'Date 1' `date` UNION ALL + * SELECT 'Title 2' `title`, 'Author 2' `author`, 'Name 2' `name`, 'Date 2' `date` + * ) `u` + * ON `mytable`.`title` = `u`.`title` AND `mytable`.`author` = `u`.`author` + * SET + * `mytable`.`title` = `u`.`title`, + * `mytable`.`name` = `u`.`name`, + * `mytable`.`date` = `u`.`date`, + * `mytable`.`last_update` = CURRENT_TIMESTAMP() // this only applies to the last scenario + */ From 09276f8bf54b7d5c66a5283d5ea252db152df5e7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 5 Feb 2023 13:25:03 +0900 Subject: [PATCH 249/290] docs: break long line in sample code --- user_guide_src/source/database/query_builder/115.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/database/query_builder/115.php b/user_guide_src/source/database/query_builder/115.php index cc5607d3982c..7526474da334 100644 --- a/user_guide_src/source/database/query_builder/115.php +++ b/user_guide_src/source/database/query_builder/115.php @@ -7,7 +7,10 @@ $additionalUpdateField = ['updated_at' => new RawSql('CURRENT_TIMESTAMP')]; -$sql = $builder->setQueryAsData($query)->onConstraint('email')->updateFields($additionalUpdateField, true)->upsertBatch(); +$sql = $builder->setQueryAsData($query) + ->onConstraint('email') + ->updateFields($additionalUpdateField, true) + ->upsertBatch(); /* MySQLi produces: INSERT INTO `db_user` (`country`, `email`, `name`) SELECT user2.name, user2.email, user2.country From 1450be7e1c470ba350c781a606ce523016f12485 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 5 Feb 2023 13:30:11 +0900 Subject: [PATCH 250/290] chore: update Kint version in composer.json --- admin/framework/composer.json | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/framework/composer.json b/admin/framework/composer.json index 248eea0c96cc..2f3022a92b2b 100644 --- a/admin/framework/composer.json +++ b/admin/framework/composer.json @@ -13,7 +13,7 @@ "psr/log": "^1.1" }, "require-dev": { - "kint-php/kint": "^5.0.1", + "kint-php/kint": "^5.0.3", "codeigniter/coding-standard": "^1.5", "fakerphp/faker": "^1.9", "friendsofphp/php-cs-fixer": "3.13.0", diff --git a/composer.json b/composer.json index 1fbc0fff4537..f4c9c31236fa 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "psr/log": "^1.1" }, "require-dev": { - "kint-php/kint": "^5.0.1", + "kint-php/kint": "^5.0.3", "codeigniter/coding-standard": "^1.5", "fakerphp/faker": "^1.9", "friendsofphp/php-cs-fixer": "3.13.0", From 09e267db52ddf02183f53af28ad072b8fc0f0c4d Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Sun, 5 Feb 2023 09:52:45 +0100 Subject: [PATCH 251/290] add support for display of error message using wildcard (*) --- system/Helpers/form_helper.php | 9 ++++++--- tests/system/Helpers/FormHelperTest.php | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index 57d3f38b63a4..dfd4a64f0669 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -741,9 +741,12 @@ function validation_show_error(string $field, string $template = 'single'): stri $config = config('Validation'); $view = Services::renderer(); - $errors = validation_errors(); + $errors = array_filter(validation_errors(), static fn ($key) => preg_match( + '/^' . str_replace(['\.\*', '\*\.'], ['\..+', '.+\.'], preg_quote($field, '/')) . '$/', + $key + ), ARRAY_FILTER_USE_KEY); - if (! array_key_exists($field, $errors)) { + if ($errors === []) { return ''; } @@ -751,7 +754,7 @@ function validation_show_error(string $field, string $template = 'single'): stri throw ValidationException::forInvalidTemplate($template); } - return $view->setVar('error', $errors[$field]) + return $view->setVar('error', implode("\n", $errors)) ->render($config->templates[$template]); } } diff --git a/tests/system/Helpers/FormHelperTest.php b/tests/system/Helpers/FormHelperTest.php index 4e1ea582dd2d..d6508d8ff18c 100644 --- a/tests/system/Helpers/FormHelperTest.php +++ b/tests/system/Helpers/FormHelperTest.php @@ -996,6 +996,16 @@ public function testValidationShowError() $this->assertSame('The ID field is required.' . "\n", $html); } + public function testValidationShowErrorForWildcards() + { + $validation = Services::validation(); + $validation->setRule('user.0.name', 'Name', 'required')->run([]); + + $html = validation_show_error('user.*.name'); + + $this->assertSame('The Name field is required.' . "\n", $html); + } + public function testFormParseFormAttributesTrue() { $expected = 'readonly '; From f557414433b71210007cf533c907df67c8ebcffa Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 5 Feb 2023 19:21:05 +0900 Subject: [PATCH 252/290] docs: add section "GPG-Signing Old Commits" All topics related to GPG signatures can be reached from this document. --- contributing/signing.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contributing/signing.md b/contributing/signing.md index e925327e9b71..6626911591d2 100644 --- a/contributing/signing.md +++ b/contributing/signing.md @@ -53,3 +53,7 @@ bash shell to use the **-S** option to force the secure signing. Regardless of how you sign a commit, commit messages are important too. See [Contribution Workflow](./workflow.md#commit-messages) for details. + +## GPG-Signing Old Commits + +See [Contribution Workflow](./workflow.md#gpg-signing-old-commits). From 6bbf117c535af776a5adeaad1de77e51d91d333a Mon Sep 17 00:00:00 2001 From: Amel Date: Sun, 5 Feb 2023 08:55:57 +0100 Subject: [PATCH 253/290] sign commits --- system/Common.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/system/Common.php b/system/Common.php index 218252ed7985..95253830430a 100644 --- a/system/Common.php +++ b/system/Common.php @@ -10,6 +10,7 @@ */ use CodeIgniter\Cache\CacheInterface; +use CodeIgniter\Config\BaseConfig; use CodeIgniter\Config\Factories; use CodeIgniter\Cookie\Cookie; use CodeIgniter\Cookie\CookieStore; @@ -47,8 +48,7 @@ */ function app_timezone(): string { - /** @var App $config */ - $config = config('App'); + $config = config(App::class); return $config->appTimezone; } @@ -203,7 +203,11 @@ function command(string $command) /** * More simple way of getting config instances from Factories * - * @return object|null + * @template T of BaseConfig + * + * @param class-string $name + * + * @return T */ function config(string $name, bool $getShared = true) { @@ -495,7 +499,7 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu Services::session(null, true)->regenerate(); // @codeCoverageIgnore } - $baseURL = config('App')->baseURL; + $baseURL = config(App::class)->baseURL; if (strpos($baseURL, 'https://') === 0) { $authority = substr($baseURL, strlen('https://')); @@ -885,7 +889,7 @@ function redirect(?string $route = null): RedirectResponse */ function _solidus(): string { - if (config('DocTypes')->html5 ?? false) { + if (config(\Config\DocTypes::class)->html5 ?? false) { return ''; } @@ -973,10 +977,9 @@ function route_to(string $method, ...$params) * session()->set('foo', 'bar'); * $foo = session('bar'); * - * @param string $val + * @param string|null $val * * @return array|bool|float|int|object|Session|string|null - * @phpstan-return ($val is null ? Session : array|bool|float|int|object|string|null) */ function session(?string $val = null) { @@ -1064,7 +1067,7 @@ function single_service(string $name, ...$params) */ function slash_item(string $item): ?string { - $config = config('App'); + $config = config(App::class); if (! property_exists($config, $item)) { return null; @@ -1166,10 +1169,8 @@ function timer(?string $name = null, ?callable $callable = null) */ function view(string $name, array $data = [], array $options = []): string { - /** @var CodeIgniter\View\View $renderer */ $renderer = Services::renderer(); - /** @var \CodeIgniter\Config\View $config */ $config = config(View::class); $saveData = $config->saveData; From 8b9bf3bfd3ea52df3b5403ef790a637c676d0f4b Mon Sep 17 00:00:00 2001 From: Amel Date: Sun, 5 Feb 2023 09:57:08 +0100 Subject: [PATCH 254/290] Replace qualifier with an import DocTypes --- system/Common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/Common.php b/system/Common.php index 95253830430a..9cd08f55fa59 100644 --- a/system/Common.php +++ b/system/Common.php @@ -32,6 +32,7 @@ use CodeIgniter\Test\TestLogger; use Config\App; use Config\Database; +use Config\DocTypes; use Config\Logger; use Config\Services; use Config\View; @@ -889,7 +890,7 @@ function redirect(?string $route = null): RedirectResponse */ function _solidus(): string { - if (config(\Config\DocTypes::class)->html5 ?? false) { + if (config(DocTypes::class)->html5 ?? false) { return ''; } From 4adc017d739a22fd86d24155a09bdfa853256806 Mon Sep 17 00:00:00 2001 From: Amel Date: Sun, 5 Feb 2023 11:53:32 +0100 Subject: [PATCH 255/290] Restore @phpstan-return [ci skip] --- system/Common.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system/Common.php b/system/Common.php index 9cd08f55fa59..dd055a230f1b 100644 --- a/system/Common.php +++ b/system/Common.php @@ -978,9 +978,8 @@ function route_to(string $method, ...$params) * session()->set('foo', 'bar'); * $foo = session('bar'); * - * @param string|null $val - * * @return array|bool|float|int|object|Session|string|null + * @phpstan-return ($val is null ? Session : array|bool|float|int|object|string|null) */ function session(?string $val = null) { From ce1247d7b05af5e52c13401c282dd095470a1181 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Sun, 5 Feb 2023 12:15:23 +0100 Subject: [PATCH 256/290] applied code review suggestion --- tests/system/Helpers/FormHelperTest.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/system/Helpers/FormHelperTest.php b/tests/system/Helpers/FormHelperTest.php index d6508d8ff18c..0c914ee1df67 100644 --- a/tests/system/Helpers/FormHelperTest.php +++ b/tests/system/Helpers/FormHelperTest.php @@ -999,7 +999,16 @@ public function testValidationShowError() public function testValidationShowErrorForWildcards() { $validation = Services::validation(); - $validation->setRule('user.0.name', 'Name', 'required')->run([]); + $validation->setRule('user.*.name', 'Name', 'required') + ->run([ + 'user' => [ + 'friends' => [ + ['name' => 'Name1'], + ['name' => ''], + ['name' => 'Name2'], + ] + ] + ]); $html = validation_show_error('user.*.name'); From 256d9a2f6e5cb498bb98c82a79f65330980ef154 Mon Sep 17 00:00:00 2001 From: Samuel Asor Date: Sun, 5 Feb 2023 12:20:22 +0100 Subject: [PATCH 257/290] cs-fix --- tests/system/Helpers/FormHelperTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/system/Helpers/FormHelperTest.php b/tests/system/Helpers/FormHelperTest.php index 0c914ee1df67..9a525adf7ad2 100644 --- a/tests/system/Helpers/FormHelperTest.php +++ b/tests/system/Helpers/FormHelperTest.php @@ -1006,8 +1006,8 @@ public function testValidationShowErrorForWildcards() ['name' => 'Name1'], ['name' => ''], ['name' => 'Name2'], - ] - ] + ], + ], ]); $html = validation_show_error('user.*.name'); From 9f93346e8fe6ead5395f91676c5b387c059a452b Mon Sep 17 00:00:00 2001 From: Amel Date: Sun, 5 Feb 2023 12:24:29 +0100 Subject: [PATCH 258/290] Fix phpstan errors --- system/Common.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/system/Common.php b/system/Common.php index dd055a230f1b..ce81e92dd183 100644 --- a/system/Common.php +++ b/system/Common.php @@ -204,11 +204,12 @@ function command(string $command) /** * More simple way of getting config instances from Factories * - * @template T of BaseConfig + * @template ConfigTemplate of BaseConfig * - * @param class-string $name + * @param class-string|string $name * - * @return T + * @return ConfigTemplate + * @phpstan-return ($name is class-string ? ConfigTemplate : object|null) */ function config(string $name, bool $getShared = true) { From dbf23bf5d369cb809aa1820062ec2645001ffdf0 Mon Sep 17 00:00:00 2001 From: MichalKoder <50060787+MichalKoder@users.noreply.github.com> Date: Sun, 5 Feb 2023 14:07:16 +0100 Subject: [PATCH 259/290] A spelling correction in model.html --- user_guide_src/source/models/model.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/models/model.rst b/user_guide_src/source/models/model.rst index 726c26dac728..06f7d84f26f2 100644 --- a/user_guide_src/source/models/model.rst +++ b/user_guide_src/source/models/model.rst @@ -727,7 +727,7 @@ Additionally, each model may allow (default) or deny callbacks class-wide by set .. literalinclude:: model/052.php -You may also change this setting temporarily for a single model call sing the ``allowCallbacks()`` method: +You may also change this setting temporarily for a single model call using the ``allowCallbacks()`` method: .. literalinclude:: model/053.php From 5f19ad9a4e95a7fae0c5cd1655fea0a5c43eea8c Mon Sep 17 00:00:00 2001 From: Amel Date: Sun, 5 Feb 2023 16:29:03 +0100 Subject: [PATCH 260/290] Add null as a possible return --- system/Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Common.php b/system/Common.php index ce81e92dd183..e6fc862fa102 100644 --- a/system/Common.php +++ b/system/Common.php @@ -208,7 +208,7 @@ function command(string $command) * * @param class-string|string $name * - * @return ConfigTemplate + * @return ConfigTemplate|null * @phpstan-return ($name is class-string ? ConfigTemplate : object|null) */ function config(string $name, bool $getShared = true) From 671cc824739b2c7727c2b1e68d33f2f962e2f78a Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 6 Feb 2023 07:26:53 +0900 Subject: [PATCH 261/290] fix: restore removed $config->baseURL check --- system/Helpers/url_helper.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 9c035144a04b..ee41d2488e70 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -39,6 +39,16 @@ function _get_uri($relativePath = '', ?App $config = null): URI if ($config === null) { /** @var App $appConfig */ $appConfig = config('App'); + + if ($appConfig->baseURL === '') { + throw new InvalidArgumentException( + '_get_uri() requires a valid baseURL.' + ); + } + } elseif ($config->baseURL === '') { + throw new InvalidArgumentException( + '_get_uri() requires a valid baseURL.' + ); } // Convert array of segments to a string From b9cae3c766ea21fa39f3fd9f99947a6a600494f8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 6 Feb 2023 07:34:34 +0900 Subject: [PATCH 262/290] refactor: remove variable --- system/Helpers/url_helper.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index ee41d2488e70..1a064a76175f 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -169,17 +169,15 @@ function current_url(bool $returnObject = false, ?IncomingRequest $request = nul $routePath = $request->getPath(); $currentURI = $request->getUri(); - $relativePath = $routePath; - // Append queries and fragments if ($query = $currentURI->getQuery()) { - $relativePath .= '?' . $query; + $query = '?' . $query; } if ($fragment = $currentURI->getFragment()) { - $relativePath .= '#' . $fragment; + $fragment = '#' . $fragment; } - $uri = _get_uri($relativePath); + $uri = _get_uri($routePath . $query . $fragment); return $returnObject ? $uri : URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath()); } From 495418ae8efde7ba9a45967c3f3442d2a9b58f3b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 15:01:21 +0000 Subject: [PATCH 263/290] chore(deps-dev): update rector/rector requirement 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.11...0.15.12) --- 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 f4c9c31236fa..8a2f047409f0 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.11", + "rector/rector": "0.15.12", "vimeo/psalm": "^5.0" }, "suggest": { From 20638680f388d753288146d839642276c72b9b32 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 7 Feb 2023 17:32:15 +0900 Subject: [PATCH 264/290] test: add comment --- tests/system/HTTP/IncomingRequestDetectingTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/system/HTTP/IncomingRequestDetectingTest.php b/tests/system/HTTP/IncomingRequestDetectingTest.php index f3be0aeb2247..cd220cbe0987 100644 --- a/tests/system/HTTP/IncomingRequestDetectingTest.php +++ b/tests/system/HTTP/IncomingRequestDetectingTest.php @@ -68,6 +68,14 @@ public function testPathRequestURI() public function testPathRequestURINested() { + // I'm not sure but this is a case of Apache config making such SERVER + // values? + // The current implementation doesn't use the value of the URI object. + // So I removed the code to set URI. Therefore, it's exactly the same as + // the method above as a test. + // But it may be changed in the future to use the value of the URI object. + // So I don't remove this test case. + // /ci/index.php/woot?code=good#pos $_SERVER['REQUEST_URI'] = '/index.php/woot'; $_SERVER['SCRIPT_NAME'] = '/index.php'; From 66bafe4e54a16ebdefa57d5e785154e52b86fddb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 15:00:57 +0000 Subject: [PATCH 265/290] chore(deps-dev): update rector/rector requirement 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.12...0.15.13) --- 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 8a2f047409f0..7a58a7be0d21 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.12", + "rector/rector": "0.15.13", "vimeo/psalm": "^5.0" }, "suggest": { From ef8a25f359aaf7621431eb42c461846220fe99dd Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Thu, 9 Feb 2023 05:42:36 +0330 Subject: [PATCH 266/290] docs: link to all repo --- .../source/installation/repositories.rst | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/user_guide_src/source/installation/repositories.rst b/user_guide_src/source/installation/repositories.rst index cbdf8f8c28d3..920efc27800f 100644 --- a/user_guide_src/source/installation/repositories.rst +++ b/user_guide_src/source/installation/repositories.rst @@ -16,24 +16,31 @@ There are several development repositories, of interest to potential contributor +------------------+--------------+-----------------------------------------------------------------+ | Repository | Audience | Description | +==================+==============+=================================================================+ -| CodeIgniter4 | contributors | Project codebase, including tests & user guide sources | +| CodeIgniter4_ | contributors | Project codebase, including tests & user guide sources | +------------------+--------------+-----------------------------------------------------------------+ -| translations | developers | System message translations | +| translations_ | developers | System message translations | +------------------+--------------+-----------------------------------------------------------------+ | coding-standard_ | contributors | Coding style conventions & rules | +------------------+--------------+-----------------------------------------------------------------+ -| devkit | developers | Development toolkit for CodeIgniter libraries and projects | +| devkit_ | developers | Development toolkit for CodeIgniter libraries and projects | +------------------+--------------+-----------------------------------------------------------------+ -| settings | developers | Settings Library for CodeIgniter 4 | +| settings_ | developers | Settings Library for CodeIgniter 4 | +------------------+--------------+-----------------------------------------------------------------+ -| shield | developers | Authentication and Authorization Library for CodeIgniter 4 | +| shield_ | developers | Authentication and Authorization Library for CodeIgniter 4 | +------------------+--------------+-----------------------------------------------------------------+ -| tasks | developers | Task Scheduler for CodeIgniter 4 | +| tasks_ | developers | Task Scheduler for CodeIgniter 4 | +------------------+--------------+-----------------------------------------------------------------+ -| cache | developers | PSR-6 and PSR-16 Cache Adapters for CodeIgniter 4 | +| cache_ | developers | PSR-6 and PSR-16 Cache Adapters for CodeIgniter 4 | +------------------+--------------+-----------------------------------------------------------------+ +.. _CodeIgniter4: https://github.com/codeigniter4/CodeIgniter4 +.. _translations: https://github.com/codeigniter4/translations .. _coding-standard: https://github.com/CodeIgniter/coding-standard +.. _devkit: https://github.com/codeigniter4/devkit +.. _settings: https://github.com/codeigniter4/settings +.. _shield: https://codeigniter4.github.io/shield +.. _tasks: https://github.com/codeigniter4/tasks +.. _cache: https://github.com/codeigniter4/cache There are also several deployment repositories, referenced in the installation directions. The deployment repositories are built automatically when a new version is released, and they @@ -42,14 +49,18 @@ are not directly contributed to. +------------------+--------------+-----------------------------------------------------------------+ | Repository | Audience | Description | +==================+==============+=================================================================+ -| framework | developers | Released versions of the framework | +| framework_ | developers | Released versions of the framework | +------------------+--------------+-----------------------------------------------------------------+ -| appstarter | developers | Starter project (app/public/writable). | +| appstarter_ | developers | Starter project (app/public/writable). | | | | Dependent on "framework" | +------------------+--------------+-----------------------------------------------------------------+ -| userguide | anyone | Pre-built user guide | +| userguide_ | anyone | Pre-built user guide | +------------------+--------------+-----------------------------------------------------------------+ +.. _framework: https://github.com/codeigniter4/framework +.. _appstarter: https://github.com/codeigniter4/appstarter +.. _userguide: https://github.com/codeigniter4/userguide + In all the above, the latest version of a repository can be downloaded by selecting the "releases" link in the secondary navbar inside the "Code" tab of its GitHub repository page. The current (in development) version of each can @@ -83,9 +94,12 @@ but which showcase it or make it easier to work with! +------------------+--------------+-----------------------------------------------------------------+ | Repository | Audience | Description | +==================+==============+=================================================================+ -| website | developers | The codeigniter.com website, written in CodeIgniter 4 | +| website_ | developers | The codeigniter.com website, written in CodeIgniter 4 | +------------------+--------------+-----------------------------------------------------------------+ -| playground | developers | Basic code examples in project form. Still growing. | +| playground_ | developers | Basic code examples in project form. Still growing. | +------------------+--------------+-----------------------------------------------------------------+ +.. _website: https://github.com/codeigniter4projects/website +.. _playground: https://github.com/codeigniter4projects/playground + These are not composer-installable repositories. From fab8a3dab6f6b470756bb243b31c511258ee82e4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 9 Feb 2023 14:17:29 +0900 Subject: [PATCH 267/290] docs: clarify the method name --- user_guide_src/source/dbmgmt/forge.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index a3b74e979966..934e9e3a64e7 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -116,7 +116,7 @@ After the fields have been defined, they can be added using $forge->addField() ------------------ -The add fields method will accept the above array. +The ``addField()`` method will accept the above array. .. _forge-addfield-default-value-rawsql: From d89d6fc6b9f8fc22597bef822a4e4c5fc59c1e59 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 9 Feb 2023 14:18:12 +0900 Subject: [PATCH 268/290] docs: clarify above --- user_guide_src/source/dbmgmt/forge.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index 934e9e3a64e7..3714dd07a976 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -86,6 +86,8 @@ There are several things you may wish to do when creating tables. Add fields, add keys to the table, alter columns. CodeIgniter provides a mechanism for this. +.. _adding-fields: + Adding Fields ============= @@ -249,8 +251,8 @@ $forge->addColumn() ------------------- The ``addColumn()`` method is used to modify an existing table. It -accepts the same field array as above, and can be used for an unlimited -number of additional fields. +accepts the same field array as :ref:`Creating Tables `, and can +be used for an unlimited number of additional fields. .. literalinclude:: forge/022.php From e93fc0a4e50d6e61a53f32abc0b65fd832b1a6b6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 9 Feb 2023 14:20:42 +0900 Subject: [PATCH 269/290] docs: add "existing" --- user_guide_src/source/dbmgmt/forge.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index 3714dd07a976..01ace8e60029 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -350,7 +350,7 @@ Class Reference :returns: true on success, false on failure :rtype: bool - Adds a column to a table. Usage: See `Adding a Field to a Table`_. + Adds a column to an existing table. Usage: See `Adding a Field to a Table`_. .. php:method:: addField($field) From 73d6d624c8c8d780e334679909d8251b33543466 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 9 Feb 2023 14:21:36 +0900 Subject: [PATCH 270/290] docs: fix classname notation --- user_guide_src/source/dbmgmt/forge.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index 01ace8e60029..dafabfdaed57 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -355,8 +355,8 @@ Class Reference .. php:method:: addField($field) :param array $field: Field definition to add - :returns: \CodeIgniter\Database\Forge instance (method chaining) - :rtype: \CodeIgniter\Database\Forge + :returns: ``\CodeIgniter\Database\Forge`` instance (method chaining) + :rtype: ``\CodeIgniter\Database\Forge`` Adds a field to the set that will be used to create a table. Usage: See `Adding Fields`_. @@ -368,8 +368,8 @@ Class Reference :param string $onUpdate: Desired action for the "on update" :param string $onDelete: Desired action for the "on delete" :param string $fkName: Name of foreign key. This does not work with SQLite3 - :returns: \CodeIgniter\Database\Forge instance (method chaining) - :rtype: \CodeIgniter\Database\Forge + :returns: ``\CodeIgniter\Database\Forge`` instance (method chaining) + :rtype: ``\CodeIgniter\Database\Forge`` Adds a foreign key to the set that will be used to create a table. Usage: See `Adding Foreign Keys`_. @@ -381,8 +381,8 @@ Class Reference :param bool $primary: Set to true if it should be a primary key or a regular one :param bool $unique: Set to true if it should be a unique key or a regular one :param string $keyName: Name of key to be added - :returns: \CodeIgniter\Database\Forge instance (method chaining) - :rtype: \CodeIgniter\Database\Forge + :returns: ``\CodeIgniter\Database\Forge`` instance (method chaining) + :rtype: ``\CodeIgniter\Database\Forge`` Adds a key to the set that will be used to create a table. Usage: See `Adding Keys`_. @@ -392,8 +392,8 @@ Class Reference :param mixed $key: Name of a key field or an array of fields :param string $keyName: Name of key to be added - :returns: \CodeIgniter\Database\Forge instance (method chaining) - :rtype: \CodeIgniter\Database\Forge + :returns: ``\CodeIgniter\Database\Forge`` instance (method chaining) + :rtype: ``\CodeIgniter\Database\Forge`` Adds a primary key to the set that will be used to create a table. Usage: See `Adding Keys`_. @@ -403,8 +403,8 @@ Class Reference :param mixed $key: Name of a key field or an array of fields :param string $keyName: Name of key to be added - :returns: \CodeIgniter\Database\Forge instance (method chaining) - :rtype: \CodeIgniter\Database\Forge + :returns: ``\CodeIgniter\Database\Forge`` instance (method chaining) + :rtype: ``\CodeIgniter\Database\Forge`` Adds a unique key to the set that will be used to create a table. Usage: See `Adding Keys`_. From 6af6a8579eabc558c4c6ec19bd7b846bb6e5231f Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 9 Feb 2023 14:22:02 +0900 Subject: [PATCH 271/290] docs: remove unneeded space --- user_guide_src/source/dbmgmt/forge.rst | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index dafabfdaed57..ff53a9ae3c5f 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -358,7 +358,7 @@ Class Reference :returns: ``\CodeIgniter\Database\Forge`` instance (method chaining) :rtype: ``\CodeIgniter\Database\Forge`` - Adds a field to the set that will be used to create a table. Usage: See `Adding Fields`_. + Adds a field to the set that will be used to create a table. Usage: See `Adding Fields`_. .. php:method:: addForeignKey($fieldName, $tableName, $tableField[, $onUpdate = '', $onDelete = '', $fkName = '']) @@ -371,7 +371,7 @@ Class Reference :returns: ``\CodeIgniter\Database\Forge`` instance (method chaining) :rtype: ``\CodeIgniter\Database\Forge`` - Adds a foreign key to the set that will be used to create a table. Usage: See `Adding Foreign Keys`_. + Adds a foreign key to the set that will be used to create a table. Usage: See `Adding Foreign Keys`_. .. note:: ``$fkName`` can be used since v4.3.0. @@ -384,7 +384,7 @@ Class Reference :returns: ``\CodeIgniter\Database\Forge`` instance (method chaining) :rtype: ``\CodeIgniter\Database\Forge`` - Adds a key to the set that will be used to create a table. Usage: See `Adding Keys`_. + Adds a key to the set that will be used to create a table. Usage: See `Adding Keys`_. .. note:: ``$keyName`` can be used since v4.3.0. @@ -395,7 +395,7 @@ Class Reference :returns: ``\CodeIgniter\Database\Forge`` instance (method chaining) :rtype: ``\CodeIgniter\Database\Forge`` - Adds a primary key to the set that will be used to create a table. Usage: See `Adding Keys`_. + Adds a primary key to the set that will be used to create a table. Usage: See `Adding Keys`_. .. note:: ``$keyName`` can be used since v4.3.0. @@ -406,7 +406,7 @@ Class Reference :returns: ``\CodeIgniter\Database\Forge`` instance (method chaining) :rtype: ``\CodeIgniter\Database\Forge`` - Adds a unique key to the set that will be used to create a table. Usage: See `Adding Keys`_. + Adds a unique key to the set that will be used to create a table. Usage: See `Adding Keys`_. .. note:: ``$keyName`` can be used since v4.3.0. @@ -417,7 +417,7 @@ Class Reference :returns: true on success, false on failure :rtype: bool - Creates a new database. Usage: See `Creating and Dropping Databases`_. + Creates a new database. Usage: See `Creating and Dropping Databases`_. .. php:method:: createTable($table[, $if_not_exists = false[, array $attributes = []]]) @@ -427,7 +427,7 @@ Class Reference :returns: Query object on success, false on failure :rtype: mixed - Creates a new table. Usage: See `Creating a Table`_. + Creates a new table. Usage: See `Creating a Table`_. .. php:method:: dropColumn($table, $column_name) @@ -436,7 +436,7 @@ Class Reference :returns: true on success, false on failure :rtype: bool - Drops single or multiple columns from a table. Usage: See `Dropping Fields From a Table`_. + Drops single or multiple columns from a table. Usage: See `Dropping Fields From a Table`_. .. php:method:: dropDatabase($dbName) @@ -444,7 +444,7 @@ Class Reference :returns: true on success, false on failure :rtype: bool - Drops a database. Usage: See `Creating and Dropping Databases`_. + Drops a database. Usage: See `Creating and Dropping Databases`_. .. php:method:: dropKey($table, $keyName[, $prefixKeyName = true]) @@ -476,7 +476,7 @@ Class Reference :returns: true on success, false on failure :rtype: bool - Drops a table. Usage: See `Dropping a Table`_. + Drops a table. Usage: See `Dropping a Table`_. .. php:method:: processIndexes($table) @@ -497,7 +497,7 @@ Class Reference :returns: true on success, false on failure :rtype: bool - Modifies a table column. Usage: See `Modifying a Field in a Table`_. + Modifies a table column. Usage: See `Modifying a Field in a Table`_. .. php:method:: renameTable($table_name, $new_table_name) @@ -506,4 +506,4 @@ Class Reference :returns: Query object on success, false on failure :rtype: mixed - Renames a table. Usage: See `Renaming a Table`_. + Renames a table. Usage: See `Renaming a Table`_. From 4b153141a2d1eae9b47717abe3f30a14283fe349 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 10 Feb 2023 09:36:52 +0900 Subject: [PATCH 272/290] docs: fix incorrect description DBMS has its own maximum column number in a table. --- user_guide_src/source/dbmgmt/forge.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index ff53a9ae3c5f..21da852e9d4f 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -252,7 +252,7 @@ $forge->addColumn() The ``addColumn()`` method is used to modify an existing table. It accepts the same field array as :ref:`Creating Tables `, and can -be used for an unlimited number of additional fields. +be used to add additional fields. .. literalinclude:: forge/022.php From 7240d4b1f377bd2e3b60498a11a6684467e76243 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 11 Feb 2023 13:47:30 +0900 Subject: [PATCH 273/290] docs: change text decoration --- user_guide_src/source/general/environments.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index bac1f4c394cb..e623d1754382 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -48,7 +48,7 @@ The simplest method to set the variable is in your :doc:`.env file `_. .. code-block:: apache @@ -62,7 +62,7 @@ nginx ----- Under nginx, you must pass the environment variable through the ``fastcgi_params`` -in order for it to show up under the `$_SERVER` variable. This allows it to work on the +in order for it to show up under the ``$_SERVER`` variable. This allows it to work on the virtual-host level, instead of using `env` to set it for the entire server, though that would work fine on a dedicated server. You would then modify your server config to something like: @@ -105,14 +105,14 @@ a fresh install: Effects On Default Framework Behavior ===================================== -There are some places in the CodeIgniter system where the ENVIRONMENT +There are some places in the CodeIgniter system where the ``ENVIRONMENT`` constant is used. This section describes how default framework behavior is affected. Error Reporting --------------- -Setting the ENVIRONMENT constant to a value of ``development`` will cause +Setting the ``ENVIRONMENT`` constant to a value of ``development`` will cause all PHP errors to be rendered to the browser when they occur. Conversely, setting the constant to ``production`` will disable all error output. Disabling error reporting in production is a From 36f17a9aba067a419b773d2d66d6f26948a6e32c Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 11 Feb 2023 13:48:02 +0900 Subject: [PATCH 274/290] docs: update apache docs link --- user_guide_src/source/general/environments.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index e623d1754382..f847ce9e3398 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -49,7 +49,7 @@ Apache ------ This server variable can be set in your **.htaccess** file or Apache -config using `SetEnv `_. +config using `SetEnv `_. .. code-block:: apache From a375cefd92da0790e1630ddbad72494c94991b72 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 11 Feb 2023 13:48:25 +0900 Subject: [PATCH 275/290] docs: replace nginx with Nginx --- user_guide_src/source/general/environments.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index f847ce9e3398..00661c5c86dd 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -58,10 +58,10 @@ config using `SetEnv .. _environment-nginx: -nginx +Nginx ----- -Under nginx, you must pass the environment variable through the ``fastcgi_params`` +Under Nginx, you must pass the environment variable through the ``fastcgi_params`` in order for it to show up under the ``$_SERVER`` variable. This allows it to work on the virtual-host level, instead of using `env` to set it for the entire server, though that would work fine on a dedicated server. You would then modify your server config to something @@ -80,7 +80,7 @@ like: } } -Alternative methods are available for nginx and other servers, or you can +Alternative methods are available for Nginx and other servers, or you can remove this logic entirely and set the constant based on the server's IP address (for instance). From 5acce4d3588d30b3ab5b980e08493b876f1dfe3f Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 11 Feb 2023 13:48:50 +0900 Subject: [PATCH 276/290] docs: replace On with on --- user_guide_src/source/general/environments.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst index 00661c5c86dd..c95041865f54 100644 --- a/user_guide_src/source/general/environments.rst +++ b/user_guide_src/source/general/environments.rst @@ -102,7 +102,7 @@ a fresh install: * production.php * testing.php -Effects On Default Framework Behavior +Effects on Default Framework Behavior ===================================== There are some places in the CodeIgniter system where the ``ENVIRONMENT`` From fe9be1b8b892f670280afe0b9a68a13603030fd7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 12 Feb 2023 09:03:44 +0900 Subject: [PATCH 277/290] docs: add link to page --- user_guide_src/source/libraries/uri.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index 5e400874f548..f772840b0046 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -31,7 +31,7 @@ The Current URI --------------- Many times, all you really want is an object representing the current URL of this request. -You can use one of the functions available in the **url_helper**: +You can use one of the functions available in the :doc:`../helpers/url_helper`: .. literalinclude:: uri/004.php From 9e6fb5d43bcabc4a69fbd4a1f672e037e6ae7178 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 12 Feb 2023 09:04:20 +0900 Subject: [PATCH 278/290] docs: change text decoration --- user_guide_src/source/libraries/uri.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index f772840b0046..a795cff51ad8 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -37,7 +37,7 @@ You can use one of the functions available in the :doc:`../helpers/url_helper`: You must pass ``true`` as the first parameter, otherwise, it will return the string representation of the current URL. This URI is based on the path (relative to your ``baseURL``) as determined by the current request object and -your settings in ``Config\App`` (baseURL, indexPage, and forceGlobalSecureRequests). +your settings in ``Config\App`` (``baseURL``, ``indexPage``, and ``forceGlobalSecureRequests``). Assuming that you're in a controller that extends ``CodeIgniter\Controller`` you can get this relative path: .. literalinclude:: uri/005.php @@ -174,7 +174,7 @@ you can use the ``stripQuery()`` and ``keepQuery()`` methods to change the actua Fragment -------- -Fragments are the portion at the end of the URL, preceded by the pound-sign (#). In HTML URLs these are links +Fragments are the portion at the end of the URL, preceded by the pound-sign (``#``). In HTML URLs these are links to an on-page anchor. Media URI's can make use of them in various other ways. .. literalinclude:: uri/022.php From eb527d6fd6761ada83e0797fe3ae8504f1cbd18f Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 12 Feb 2023 09:05:23 +0900 Subject: [PATCH 279/290] docs: fix incorrect output The getPath() returns the path starting with `/`. But if you set the path `another/path`, it returns `another/path`. --- user_guide_src/source/libraries/uri/016.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/uri/016.php b/user_guide_src/source/libraries/uri/016.php index a9e680ac38de..f9d82a86759d 100644 --- a/user_guide_src/source/libraries/uri/016.php +++ b/user_guide_src/source/libraries/uri/016.php @@ -2,5 +2,5 @@ $uri = new \CodeIgniter\HTTP\URI('http://www.example.com/some/path'); -echo $uri->getPath(); // 'some/path' -echo $uri->setPath('another/path')->getPath(); // 'another/path' +echo $uri->getPath(); // '/some/path' +echo $uri->setPath('/another/path')->getPath(); // '/another/path' From 17fa375648ec158449d455337a5208937c3ac4bb Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 12 Feb 2023 09:07:57 +0900 Subject: [PATCH 280/290] docs: add empty line --- user_guide_src/source/libraries/uri.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index a795cff51ad8..d399e286ef8d 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -36,6 +36,7 @@ You can use one of the functions available in the :doc:`../helpers/url_helper`: .. literalinclude:: uri/004.php You must pass ``true`` as the first parameter, otherwise, it will return the string representation of the current URL. + This URI is based on the path (relative to your ``baseURL``) as determined by the current request object and your settings in ``Config\App`` (``baseURL``, ``indexPage``, and ``forceGlobalSecureRequests``). Assuming that you're in a controller that extends ``CodeIgniter\Controller`` you can get this relative path: From fdef54957009b75dca6e11121b9064ddf3951ad6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 12 Feb 2023 09:08:19 +0900 Subject: [PATCH 281/290] docs: replace "i" with "I" --- user_guide_src/source/libraries/uri.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index d399e286ef8d..e0a35e283e8d 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -96,7 +96,7 @@ If you do not want to display the port, pass in ``true`` as the only parameter: .. note:: If the current port is the default port for the scheme it will never be displayed. -Userinfo +UserInfo -------- The userinfo section is simply the username and password that you might see with an FTP URI. While you can get From 7411c64ba980efa2e2342efd7398a3b07caaed5a Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 12 Feb 2023 09:09:03 +0900 Subject: [PATCH 282/290] docs: add section titles --- user_guide_src/source/libraries/uri.rst | 26 ++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index e0a35e283e8d..33bb43a40588 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -139,24 +139,40 @@ can be used to manipulate it: Query ----- -The query variables can be manipulated through the class using simple string representations. Query values can only +The query variables can be manipulated through the class using simple string representations. + +Getting/Setting Query +^^^^^^^^^^^^^^^^^^^^^ + +Query values can only be set as a string currently. .. literalinclude:: uri/017.php +The ``setQuery()`` method overwrite any existing query variables. + .. note:: Query values cannot contain fragments. An InvalidArgumentException will be thrown if it does. +Setting Query from Array +^^^^^^^^^^^^^^^^^^^^^^^^ + You can set query values using an array: .. literalinclude:: uri/018.php -The ``setQuery()`` and ``setQueryArray()`` methods overwrite any existing query variables. You can add a value to the +The ``setQueryArray()`` method overwrite any existing query variables. + +Adding Query Value +^^^^^^^^^^^^^^^^^^ + +You can add a value to the query variables collection without destroying the existing query variables with the ``addQuery()`` method. The first parameter is the name of the variable, and the second parameter is the value: .. literalinclude:: uri/019.php -**Filtering Query Values** +Filtering Query Values +^^^^^^^^^^^^^^^^^^^^^^ You can filter the query values returned by passing an options array to the ``getQuery()`` method, with either an *only* or an *except* key: @@ -164,6 +180,10 @@ You can filter the query values returned by passing an options array to the ``ge .. literalinclude:: uri/020.php This only changes the values returned during this one call. If you need to modify the URI's query values more permanently, + +Changing Query Values +^^^^^^^^^^^^^^^^^^^^^ + you can use the ``stripQuery()`` and ``keepQuery()`` methods to change the actual object's query variable collection: .. literalinclude:: uri/021.php From 46308217fbf5736a12972710c4c9f2048abdbc7b Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 12 Feb 2023 15:50:39 +0900 Subject: [PATCH 283/290] docs: create file_collections.rst from files.rst --- .../source/libraries/file_collections.rst | 116 ++++++++++++++++++ user_guide_src/source/libraries/files.rst | 103 ---------------- user_guide_src/source/libraries/index.rst | 1 + 3 files changed, 117 insertions(+), 103 deletions(-) create mode 100644 user_guide_src/source/libraries/file_collections.rst diff --git a/user_guide_src/source/libraries/file_collections.rst b/user_guide_src/source/libraries/file_collections.rst new file mode 100644 index 000000000000..4b54f0ab07a8 --- /dev/null +++ b/user_guide_src/source/libraries/file_collections.rst @@ -0,0 +1,116 @@ +################ +File Collections +################ + +Working with groups of files can be cumbersome, so the framework supplies the ``FileCollection`` class to facilitate +locating and working with groups of files across the filesystem. + +.. contents:: + :local: + :depth: 2 + +*********** +Basic Usage +*********** + +At its most basic, ``FileCollection`` is an index +of files you set or build: + +.. literalinclude:: files/011.php + +After you have input the files you would like to work with you may remove files or use the filtering commands to remove +or retain files matching a certain regex or glob-style pattern: + +.. literalinclude:: files/012.php + +When your collection is complete, you can use ``get()`` to retrieve the final list of file paths, or take advantage of +``FileCollection`` being countable and iterable to work directly with each ``File``: + +.. literalinclude:: files/013.php + +Below are the specific methods for working with a ``FileCollection``. + +********************* +Starting a Collection +********************* + +__construct(string[] $files = []) +================================= + +The constructor accepts an optional array of file paths to use as the initial collection. These are passed to +``add()`` so any files supplied by child classes in the ``$files`` will remain. + +define() +======== + +Allows child classes to define their own initial files. This method is called by the constructor and allows +predefined collections without having to use their methods. Example: + +.. literalinclude:: files/014.php + +Now you may use the ``ConfigCollection`` anywhere in your project to access all App Config files without +having to re-call the collection methods every time. + +set(array $files) +================= + +Sets the list of input files to the provided string array of file paths. This will remove any existing +files from the collection, so ``$collection->set([])`` is essentially a hard reset. + +*************** +Inputting Files +*************** + +add(string[]|string $paths, bool $recursive = true) +=================================================== + +Adds all files indicated by the path or array of paths. If the path resolves to a directory then ``$recursive`` +will include sub-directories. + +addFile(string $file) / addFiles(array $files) +============================================== + +Adds the file or files to the current list of input files. Files are absolute paths to actual files. + +removeFile(string $file) / removeFiles(array $files) +==================================================== + +Removes the file or files from the current list of input files. + +addDirectory(string $directory, bool $recursive = false) +======================================================== +addDirectories(array $directories, bool $recursive = false) +=========================================================== + +Adds all files from the directory or directories, optionally recursing into sub-directories. Directories are +absolute paths to actual directories. + +*************** +Filtering Files +*************** + +removePattern(string $pattern, string $scope = null) +==================================================== +retainPattern(string $pattern, string $scope = null) +==================================================== + +Filters the current file list through the pattern (and optional scope), removing or retaining matched +files. ``$pattern`` may be a complete regex (like ``'#[A-Za-z]+\.php#'``) or a pseudo-regex similar +to ``glob()`` (like ``*.css``). +If a ``$scope`` is provided then only files in or under that directory will be considered (i.e. files +outside of ``$scope`` are always retained). When no scope is provided then all files are subject. + +Examples: + +.. literalinclude:: files/015.php + +**************** +Retrieving Files +**************** + +get(): string[] +=============== + +Returns an array of all the loaded input files. + +.. note:: ``FileCollection`` is an ``IteratorAggregate`` so you can work with it directly (e.g. ``foreach ($collection as $file)``). diff --git a/user_guide_src/source/libraries/files.rst b/user_guide_src/source/libraries/files.rst index 0c394eb35cc9..0b55982692c2 100644 --- a/user_guide_src/source/libraries/files.rst +++ b/user_guide_src/source/libraries/files.rst @@ -87,106 +87,3 @@ The move() method returns a new File instance that for the relocated file, so yo resulting location is needed: .. literalinclude:: files/010.php - -################ -File Collections -################ - -Working with groups of files can be cumbersome, so the framework supplies the ``FileCollection`` class to facilitate -locating and working with groups of files across the filesystem. At its most basic, ``FileCollection`` is an index -of files you set or build: - -.. literalinclude:: files/011.php - -After you have input the files you would like to work with you may remove files or use the filtering commands to remove -or retain files matching a certain regex or glob-style pattern: - -.. literalinclude:: files/012.php - -When your collection is complete, you can use ``get()`` to retrieve the final list of file paths, or take advantage of -``FileCollection`` being countable and iterable to work directly with each ``File``: - -.. literalinclude:: files/013.php - -Below are the specific methods for working with a ``FileCollection``. - -Starting a Collection -********************* - -__construct(string[] $files = []) -================================= - -The constructor accepts an optional array of file paths to use as the initial collection. These are passed to -``add()`` so any files supplied by child classes in the ``$files`` will remain. - -define() -======== - -Allows child classes to define their own initial files. This method is called by the constructor and allows -predefined collections without having to use their methods. Example: - -.. literalinclude:: files/014.php - -Now you may use the ``ConfigCollection`` anywhere in your project to access all App Config files without -having to re-call the collection methods every time. - -set(array $files) -================= - -Sets the list of input files to the provided string array of file paths. This will remove any existing -files from the collection, so ``$collection->set([])`` is essentially a hard reset. - -Inputting Files -*************** - -add(string[]|string $paths, bool $recursive = true) -=================================================== - -Adds all files indicated by the path or array of paths. If the path resolves to a directory then ``$recursive`` -will include sub-directories. - -addFile(string $file) / addFiles(array $files) -============================================== - -Adds the file or files to the current list of input files. Files are absolute paths to actual files. - -removeFile(string $file) / removeFiles(array $files) -==================================================== - -Removes the file or files from the current list of input files. - -addDirectory(string $directory, bool $recursive = false) -======================================================== -addDirectories(array $directories, bool $recursive = false) -=========================================================== - -Adds all files from the directory or directories, optionally recursing into sub-directories. Directories are -absolute paths to actual directories. - -Filtering Files -*************** - -removePattern(string $pattern, string $scope = null) -==================================================== -retainPattern(string $pattern, string $scope = null) -==================================================== - -Filters the current file list through the pattern (and optional scope), removing or retaining matched -files. ``$pattern`` may be a complete regex (like ``'#[A-Za-z]+\.php#'``) or a pseudo-regex similar -to ``glob()`` (like ``*.css``). -If a ``$scope`` is provided then only files in or under that directory will be considered (i.e. files -outside of ``$scope`` are always retained). When no scope is provided then all files are subject. - -Examples: - -.. literalinclude:: files/015.php - -Retrieving Files -**************** - -get(): string[] -=============== - -Returns an array of all the loaded input files. - -.. note:: ``FileCollection`` is an ``IteratorAggregate`` so you can work with it directly (e.g. ``foreach ($collection as $file)``). diff --git a/user_guide_src/source/libraries/index.rst b/user_guide_src/source/libraries/index.rst index 9f977e91d604..c0cfb0bd18b4 100644 --- a/user_guide_src/source/libraries/index.rst +++ b/user_guide_src/source/libraries/index.rst @@ -11,6 +11,7 @@ Library Reference email encryption files + file_collections honeypot images pagination From d8954a14af119d24cea9ed8cf38dd10e3b13ab42 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 13 Feb 2023 15:31:03 +0900 Subject: [PATCH 284/290] docs: replace "query variables" with "query data" --- user_guide_src/source/libraries/uri.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index 33bb43a40588..43e77e0626e2 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -139,7 +139,7 @@ can be used to manipulate it: Query ----- -The query variables can be manipulated through the class using simple string representations. +The query data can be manipulated through the class using simple string representations. Getting/Setting Query ^^^^^^^^^^^^^^^^^^^^^ From 8c974fd98934817296034a47168a6d98083d1bc8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 14 Feb 2023 09:56:24 +0900 Subject: [PATCH 285/290] docs: improve explanation --- user_guide_src/source/incoming/filters.rst | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/incoming/filters.rst b/user_guide_src/source/incoming/filters.rst index d768fa9879f7..ca63f38b391a 100644 --- a/user_guide_src/source/incoming/filters.rst +++ b/user_guide_src/source/incoming/filters.rst @@ -32,16 +32,29 @@ but may leave the methods empty if they are not needed. A skeleton filter class Before Filters ============== +Replacing Request +----------------- + From any filter, you can return the ``$request`` object and it will replace the current Request, allowing you to make changes that will still be present when the controller executes. -Since before filters are executed prior to your controller being executed, you may at times want to stop the -actions in the controller from happening. Also, when you have a series of filters you may also want to +Stopping Later Filters +---------------------- + +Also, when you have a series of filters you may also want to stop the execution of the later filters after a certain filter. You can easily do this by returning **any non-empty** result. If the before filter returns an empty result, the controller actions or the later -filters will still be executed. An exception to the non-empty result rule is the ``Request`` instance. +filters will still be executed. + +An exception to the non-empty result rule is the ``Request`` instance. Returning it in the before filter will not stop the execution but only replace the current ``$request`` object. +Returning Response +------------------ + +Since before filters are executed prior to your controller being executed, you may at times want to stop the +actions in the controller from happening. + This is typically used to perform redirects, like in this example: .. literalinclude:: filters/002.php From 33a2b6452a71c556e11d51dad78510863dbce74a Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 15 Feb 2023 10:08:29 +0900 Subject: [PATCH 286/290] docs: improve PHPDoc for model() --- system/Common.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/system/Common.php b/system/Common.php index e6fc862fa102..2a98253cb6b4 100644 --- a/system/Common.php +++ b/system/Common.php @@ -817,11 +817,12 @@ function log_message(string $level, string $message, array $context = []) /** * More simple way of getting model instances from Factories * - * @template T of Model + * @template ModelTemplate of Model * - * @param class-string $name + * @param class-string|string $name * - * @return T + * @return ModelTemplate|null + * @phpstan-return ($name is class-string ? ModelTemplate : object|null) */ function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn = null) { From 0e3d1abe30a0561d97e0ee1086fb59f7058e168f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Feb 2023 15:57:18 +0000 Subject: [PATCH 287/290] chore(deps-dev): update rector/rector requirement 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.13...0.15.16) --- 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 7a58a7be0d21..d0c2bd1e4dda 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.13", + "rector/rector": "0.15.16", "vimeo/psalm": "^5.0" }, "suggest": { From d3a6351ade8cba120a0179cab5336b56aacb2e0c Mon Sep 17 00:00:00 2001 From: paul45 Date: Wed, 15 Feb 2023 17:18:34 +0100 Subject: [PATCH 288/290] add missing @method having() in Model add missing @method having() in Model --- system/Model.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/Model.php b/system/Model.php index de646c6f8c7c..2df1bb2f5132 100644 --- a/system/Model.php +++ b/system/Model.php @@ -43,6 +43,7 @@ * @method $this groupBy($by, ?bool $escape = null) * @method $this groupEnd() * @method $this groupStart() + * @method $this having($key, $value = null, ?bool $escape = null) * @method $this havingGroupEnd() * @method $this havingGroupStart() * @method $this havingIn(?string $key = null, $values = null, ?bool $escape = null) From 4a5e07050f8b3c20e8a1aee4ad5934530df046b8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 18 Feb 2023 08:48:35 +0900 Subject: [PATCH 289/290] Prep for 4.3.2 release --- CHANGELOG.md | 47 +++++++++++++++++++ system/CodeIgniter.php | 2 +- user_guide_src/source/changelogs/v4.3.2.rst | 2 +- user_guide_src/source/conf.py | 2 +- .../source/installation/upgrade_432.rst | 13 ++++- 5 files changed, 61 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff34b8171aa2..9786833e1d2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,52 @@ # Changelog +## [v4.3.2](https://github.com/codeigniter4/CodeIgniter4/tree/v4.3.2) (2023-02-18) +[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.3.1...v4.3.2) + +### Breaking Changes + +* fix: base_url() removes trailing slash in baseURL by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7200 + +### Fixed Bugs + +* docs: fix incorrect sample code in view_parser by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7103 +* docs: add missing items in upgrade_430.rst/v4.3.0.rst by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7119 +* fix: remove `All` from `Options All -Indexes` in .htaccess by @sba in https://github.com/codeigniter4/CodeIgniter4/pull/7093 +* fix: bug on stuck content-type header in Feature Testing by @baycik in https://github.com/codeigniter4/CodeIgniter4/pull/7112 +* fix: ordering `Validation` show error by call `setRule()` by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/7149 +* fix: remove parameter $relative in `uri_string()` by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7135 +* fix: [QueryBuilder] where() generates incorrect SQL when using RawSql by @sclubricants in https://github.com/codeigniter4/CodeIgniter4/pull/7147 +* fix: [QueryBuilder] RawSql passed to set() disappears without error by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7148 +* fix: [Parser] local_currency causes "Passing null to parameter" by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7157 +* fix: [Parser] `!` does not work if delimiters are changed by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7142 +* fix: Throttler token time calculation by @rumpfc in https://github.com/codeigniter4/CodeIgniter4/pull/7160 +* fix: [QueryBuilder] getOperatorFromWhereKey() misses EXISTS, BETWEEN by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7155 +* docs: Correcting documentation mistakes in upgrading from one version to another by @objecttothis in https://github.com/codeigniter4/CodeIgniter4/pull/7191 +* fix: [Session] `Redis` connect to protocol `TLS` by @ddevsr in https://github.com/codeigniter4/CodeIgniter4/pull/7187 +* fix: Autoloader may not add Composer package's namespaces by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7193 +* fix: add try/catch to real_path() in clean_path() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7195 +* fix: cannot create shared View instance when using debugbar by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7172 +* fix: RouteCollection::getRegisteredControllers() may not return all controllers by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7174 +* fix: `spark routes` shows incorrect hostname routes by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7176 +* docs: add missing composer.json in Mandatory File Changes by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7170 +* fix: stack trace displayed when Exception handler runs out of memory is useless by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7212 +* fix: support for display of error message using wildcard (*) by @sammyskills in https://github.com/codeigniter4/CodeIgniter4/pull/7226 +* fix: routing behavior when $uriProtocol is QUERY_STRING by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7199 +* fix: site_url() does not use alt Config by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7215 +* docs: add missing @method having() in Model by @paul45 in https://github.com/codeigniter4/CodeIgniter4/pull/7258 + +### Enhancements + +* add `application/vnd.microsoft.portable-executable` and `application/x-dosexec` by @totoprayogo1916 in https://github.com/codeigniter4/CodeIgniter4/pull/7144 + +### Refactoring + +* refactor: add PHPDoc types in RouteCollection by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7129 +* refactor: URI::parseStr() by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7154 +* refactor: error_exception.php by @kenjis in https://github.com/codeigniter4/CodeIgniter4/pull/7171 +* [Rector] Apply Rector to app/Views by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/7169 +* refactor: Update PHPDoc Common::config by @maniaba in https://github.com/codeigniter4/CodeIgniter4/pull/7224 + ## [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) diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 5cb98c438863..d370e34ca22e 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.1'; + public const CI_VERSION = '4.3.2'; /** * App startup time. diff --git a/user_guide_src/source/changelogs/v4.3.2.rst b/user_guide_src/source/changelogs/v4.3.2.rst index fbb4e016ae63..19498b286544 100644 --- a/user_guide_src/source/changelogs/v4.3.2.rst +++ b/user_guide_src/source/changelogs/v4.3.2.rst @@ -1,7 +1,7 @@ Version 4.3.2 ############# -Release Date: Unreleased +Release Date: February 18, 2023 **4.3.2 release of CodeIgniter4** diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index a0484b3d0c3c..7f7aa87e7c59 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.1' +release = '4.3.2' # -- General configuration --------------------------------------------------- diff --git a/user_guide_src/source/installation/upgrade_432.rst b/user_guide_src/source/installation/upgrade_432.rst index e6d630eb47b4..adb40380aedc 100644 --- a/user_guide_src/source/installation/upgrade_432.rst +++ b/user_guide_src/source/installation/upgrade_432.rst @@ -67,7 +67,11 @@ and it is recommended that you merge the updated versions with your application: Config ------ -- @TODO +- app/Config/Email.php +- app/Config/Mimes.php +- app/Views/errors/html/error_exception.php +- composer.json +- public/.htaccess All Changes =========== @@ -75,4 +79,9 @@ 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: -- @TODO +- app/Config/App.php +- app/Config/Email.php +- app/Config/Mimes.php +- app/Views/errors/html/error_exception.php +- composer.json +- public/.htaccess From 2fb7023e82468140c9c1b36cbb7b1d35d69fe61d Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 18 Feb 2023 08:55:45 +0900 Subject: [PATCH 290/290] docs: remove empty section titles --- user_guide_src/source/changelogs/v4.3.2.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.3.2.rst b/user_guide_src/source/changelogs/v4.3.2.rst index 19498b286544..939ee780bb29 100644 --- a/user_guide_src/source/changelogs/v4.3.2.rst +++ b/user_guide_src/source/changelogs/v4.3.2.rst @@ -23,18 +23,12 @@ without a trailing slash (``/``) like ``http://localhost:8080``. Now it returns baseURL with a trailing slash. This is the same behavior as ``base_url()`` in CodeIgniter 3. -Message Changes -*************** - Changes ******* - The parameter ``$relative`` in :php:func:`uri_string()` was removed. Due to a bug, the function always returned a path relative to baseURL. No behavior changes. -Deprecations -************ - Bugs Fixed **********
    getHeaderLine($name), 'html') ?>