From d09994595b2114b22ac1d765e37e00acbb945c04 Mon Sep 17 00:00:00 2001 From: thenerdyshark Date: Tue, 20 Dec 2022 14:07:17 -0500 Subject: [PATCH 001/118] Declared session in BaseController to avoid 8.2 depreciation --- app/Controllers/BaseController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 122db5f9a9f2..24d5cebe0a12 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -37,6 +37,13 @@ abstract class BaseController extends Controller */ protected $helpers = []; + /** + * To declare the session propety to allow for global + * initialization in the initController() method + * @var object + */ + public $session; + /** * Constructor. */ From 1e1d24b02f483b428d4665a03fda2a74e7dcbe2d Mon Sep 17 00:00:00 2001 From: thenerdyshark Date: Tue, 20 Dec 2022 14:11:33 -0500 Subject: [PATCH 002/118] Fix: Creation of dynamic property depreciation to allow for session initialization --- app/Controllers/BaseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 24d5cebe0a12..5c90783a9486 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -40,7 +40,7 @@ abstract class BaseController extends Controller /** * To declare the session propety to allow for global * initialization in the initController() method - * @var object + * See the Creation of dynamic property depreciation i php 8.2 */ public $session; From 7b4d9b98affe6b1368298a6b5136fe5b32f06910 Mon Sep 17 00:00:00 2001 From: thenerdyshark Date: Tue, 20 Dec 2022 15:16:21 -0500 Subject: [PATCH 003/118] Commented session property declaration --- app/Controllers/BaseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 5c90783a9486..be7891eec020 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -42,7 +42,7 @@ abstract class BaseController extends Controller * initialization in the initController() method * See the Creation of dynamic property depreciation i php 8.2 */ - public $session; + // public $session; /** * Constructor. From b1f2f26ec39587689071de6b528fd29dfb7cd835 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 22 Dec 2022 14:01:30 +0900 Subject: [PATCH 004/118] docs: add SECURITY --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18f45d61580c..8d0898dc789b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ ## [v4.2.11](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.10) (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 @@ -77,6 +81,9 @@ ## [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 From ff19bd1de109623589cf7b34b4095f38c8de32e5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 22 Dec 2022 14:21:10 +0900 Subject: [PATCH 005/118] docs: fix typo in link url Co-authored-by: Pooya Parsa Dadashi --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d0898dc789b..f245bfd6b062 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [v4.2.11](https://github.com/codeigniter4/CodeIgniter4/tree/v4.2.10) (2022-12-21) +## [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 From a47e45eac5b8319f1718beee04678394ef1f2307 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 22 Dec 2022 14:22:51 +0900 Subject: [PATCH 006/118] refactor: by rector --- system/HTTP/RequestTrait.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/system/HTTP/RequestTrait.php b/system/HTTP/RequestTrait.php index a9d55224c557..8c6307bde5fa 100644 --- a/system/HTTP/RequestTrait.php +++ b/system/HTTP/RequestTrait.php @@ -64,13 +64,11 @@ public function getIPAddress(): string */ // @phpstan-ignore-next-line $proxyIPs = $this->proxyIPs ?? config('App')->proxyIPs; - if (! empty($proxyIPs)) { - // @phpstan-ignore-next-line - if (! is_array($proxyIPs) || is_int(array_key_first($proxyIPs))) { - throw new ConfigException( - 'You must set an array with Proxy IP address key and HTTP header name value in Config\App::$proxyIPs.' - ); - } + // @phpstan-ignore-next-line + if (! empty($proxyIPs) && (! is_array($proxyIPs) || is_int(array_key_first($proxyIPs)))) { + throw new ConfigException( + 'You must set an array with Proxy IP address key and HTTP header name value in Config\App::$proxyIPs.' + ); } $this->ipAddress = $this->getServer('REMOTE_ADDR'); From 0de725e5c286e001e03943a85f8e29a1102870cf Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 22 Dec 2022 13:52:10 +0900 Subject: [PATCH 007/118] test: update failed tests --- tests/_support/Database/Seeds/CITestSeeder.php | 4 ++-- .../Session/Handlers/Database/AbstractHandlerTestCase.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/_support/Database/Seeds/CITestSeeder.php b/tests/_support/Database/Seeds/CITestSeeder.php index fb43d37a9ff4..9353578246b5 100644 --- a/tests/_support/Database/Seeds/CITestSeeder.php +++ b/tests/_support/Database/Seeds/CITestSeeder.php @@ -150,7 +150,7 @@ public function run() if ($this->db->DBDriver === 'MySQLi') { $data['ci_sessions'][] = [ - 'id' => '1f5o06b43phsnnf8if6bo33b635e4p2o', + 'id' => 'ci_session:1f5o06b43phsnnf8if6bo33b635e4p2o', 'ip_address' => '127.0.0.1', 'timestamp' => '2021-06-25 21:54:14', 'data' => '__ci_last_regenerate|i:1624650854;_ci_previous_url|s:40:\"http://localhost/index.php/home/index\";', @@ -159,7 +159,7 @@ public function run() if ($this->db->DBDriver === 'Postgre') { $data['ci_sessions'][] = [ - 'id' => '1f5o06b43phsnnf8if6bo33b635e4p2o', + 'id' => 'ci_session:1f5o06b43phsnnf8if6bo33b635e4p2o', 'ip_address' => '127.0.0.1', 'timestamp' => '2021-06-25 21:54:14.991403+02', 'data' => '\x' . bin2hex('__ci_last_regenerate|i:1624650854;_ci_previous_url|s:40:\"http://localhost/index.php/home/index\";'), diff --git a/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php b/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php index c6d20f4267a9..cc71321b15f7 100644 --- a/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php +++ b/tests/system/Session/Handlers/Database/AbstractHandlerTestCase.php @@ -76,7 +76,7 @@ public function testWriteInsert() $this->setPrivateProperty($handler, 'lock', false); $row = $this->db->table('ci_sessions') - ->getWhere(['id' => '555556b43phsnnf8if6bo33b635e4444']) + ->getWhere(['id' => 'ci_session:555556b43phsnnf8if6bo33b635e4444']) ->getRow(); $this->assertGreaterThan(time() - 100, strtotime($row->timestamp)); @@ -100,7 +100,7 @@ public function testWriteUpdate() $releaseLock(); $row = $this->db->table('ci_sessions') - ->getWhere(['id' => '1f5o06b43phsnnf8if6bo33b635e4p2o']) + ->getWhere(['id' => 'ci_session:1f5o06b43phsnnf8if6bo33b635e4p2o']) ->getRow(); $this->assertGreaterThan(time() - 100, strtotime($row->timestamp)); From 5991fa204f8308ee91d1fbe9bd0de1ab1dd633bb Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 22 Dec 2022 18:54:42 +0900 Subject: [PATCH 008/118] docs: fix incorrect method name --- 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 d665167f824c..a7e258c9411f 100644 --- a/user_guide_src/source/incoming/incomingrequest.rst +++ b/user_guide_src/source/incoming/incomingrequest.rst @@ -40,7 +40,7 @@ be checked with the ``isAJAX()`` and ``isCLI()`` methods: which in some cases is not sent by default in XHR requests via JavaScript (i.e., fetch). See the :doc:`AJAX Requests ` section on how to avoid this problem. -You can check the HTTP method that this request represents with the ``method()`` method: +You can check the HTTP method that this request represents with the ``getMethod()`` method: .. literalinclude:: incomingrequest/005.php From c59b3c287ebd313790a3f149fb460e4101bd3437 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 22 Dec 2022 18:55:11 +0900 Subject: [PATCH 009/118] docs: change note:: to important:: To make it stand out. --- 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 a7e258c9411f..8373f15ceea2 100644 --- a/user_guide_src/source/incoming/incomingrequest.rst +++ b/user_guide_src/source/incoming/incomingrequest.rst @@ -46,7 +46,7 @@ You can check the HTTP method that this request represents with the ``getMethod( By default, the method is returned as a lower-case string (i.e., ``'get'``, ``'post'``, etc). -.. note:: The functionality to convert the return value to lower case is deprecated. +.. important:: The functionality to convert the return value to lower case is deprecated. It will be removed in the future version, and this method will be PSR-7 equivalent. You can get an From e99128f1979d6ab5ff95fb843a321cebb85601fa Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 22 Dec 2022 21:50:23 +0900 Subject: [PATCH 010/118] docs: add versionadded and deprecated --- contributing/documentation.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/contributing/documentation.rst b/contributing/documentation.rst index 34b1c90ca52c..fdffa1611a98 100644 --- a/contributing/documentation.rst +++ b/contributing/documentation.rst @@ -130,3 +130,18 @@ To a Method ============= :php:meth:`CodeIgniter\\HTTP\\Response::setCookie()` + +**************** +Other Directives +**************** + +New Feature +=========== + + .. versionadded:: 4.3.0 + +Deprecated +========== + + .. deprecated:: 4.3.0 + Use :php:meth:`CodeIgniter\\Database\\BaseBuilder::setData()` instead. From 0f7098d5774b1a0c4151b52f1f115cca6a8b148c Mon Sep 17 00:00:00 2001 From: thenerdyshark Date: Thu, 22 Dec 2022 11:32:37 -0500 Subject: [PATCH 011/118] Edited comment regarding property and changed from public to protected method --- app/Controllers/BaseController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index be7891eec020..5593201fe566 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -38,11 +38,11 @@ abstract class BaseController extends Controller protected $helpers = []; /** - * To declare the session propety to allow for global - * initialization in the initController() method - * See the Creation of dynamic property depreciation i php 8.2 + * Be sure to declare properties for anything you assign. + * The creation of dynamic property is deprecated in PHP 8.2. + * + * protected $session; */ - // public $session; /** * Constructor. From a6d64d0a5bb494bd51835cc4f673297168e8754b Mon Sep 17 00:00:00 2001 From: Dominic Rego Date: Thu, 22 Dec 2022 19:23:47 -0500 Subject: [PATCH 012/118] Update app/Controllers/BaseController.php Co-authored-by: kenjis --- app/Controllers/BaseController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 5593201fe566..70d092ba393d 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -37,12 +37,11 @@ abstract class BaseController extends Controller */ protected $helpers = []; - /** + /** * Be sure to declare properties for anything you assign. * The creation of dynamic property is deprecated in PHP 8.2. - * - * protected $session; */ + // protected $session; /** * Constructor. From ac2f64f787259a4f50e3a9d4bdff28d14b450bd1 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Fri, 23 Dec 2022 15:45:33 +0800 Subject: [PATCH 013/118] docs: fix typo and docs of uploaded_files. --- .../source/libraries/uploaded_files.rst | 20 ++++++++-------- .../source/libraries/uploaded_files/002.php | 24 ++++++++++++++----- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/user_guide_src/source/libraries/uploaded_files.rst b/user_guide_src/source/libraries/uploaded_files.rst index 2ec5776f8b5d..837052c59d21 100644 --- a/user_guide_src/source/libraries/uploaded_files.rst +++ b/user_guide_src/source/libraries/uploaded_files.rst @@ -126,7 +126,7 @@ request, use ``getFiles()``. This will return an array of files represented by i Of course, there are multiple ways to name the file input, and anything but the simplest can create strange results. The array returns in a manner that you would expect. With the simplest usage, a single file might be submitted like:: - + Which would return a simple array like:: @@ -138,7 +138,7 @@ Which would return a simple array like:: If you used an array notation for the name, the input would look something like:: - + The array returned by ``getFiles()`` would look more like this:: @@ -153,8 +153,8 @@ The array returned by ``getFiles()`` would look more like this:: In some cases, you may specify an array of files to upload:: - Upload an avatar: - Upload an avatar: + Upload an avatar: + Upload an avatar: In this case, the returned array of files would be more like:: @@ -179,7 +179,7 @@ Simplest usage With the simplest usage, a single file might be submitted like:: - + Which would return a simple file instance like: @@ -190,7 +190,7 @@ Array notation If you used an array notation for the name, the input would look something like:: - + For get the file instance: @@ -201,7 +201,7 @@ Multiple files :: - + In controller: @@ -221,8 +221,8 @@ You might find it easier to use ``getFileMultiple()``, to get an array of upload Another example:: - Upload an avatar: - Upload an avatar: + Upload an avatar: + Upload an avatar: In controller: @@ -334,7 +334,7 @@ Each file can be moved to its new location with the aptly named ``store()`` meth With the simplest usage, a single file might be submitted like:: - + By default, upload files are saved in **writable/uploads** directory. The **YYYYMMDD** folder and random file name will be created. Returns a file path: diff --git a/user_guide_src/source/libraries/uploaded_files/002.php b/user_guide_src/source/libraries/uploaded_files/002.php index 11c6b18698d4..2cf584f67f9f 100644 --- a/user_guide_src/source/libraries/uploaded_files/002.php +++ b/user_guide_src/source/libraries/uploaded_files/002.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + namespace App\Controllers; use CodeIgniter\Files\File; @@ -18,11 +27,13 @@ public function upload() $validationRule = [ 'userfile' => [ 'label' => 'Image File', - 'rules' => 'uploaded[userfile]' - . '|is_image[userfile]' - . '|mime_in[userfile,image/jpg,image/jpeg,image/gif,image/png,image/webp]' - . '|max_size[userfile,100]' - . '|max_dims[userfile,1024,768]', + 'rules' => [ + 'uploaded[userfile]', + 'is_image[userfile]', + 'mime_in[userfile,image/jpg,image/jpeg,image/gif,image/png,image/webp]', + 'max_size[userfile,100]', + 'max_dims[userfile,1024,768]', + ], ], ]; if (! $this->validate($validationRule)) { @@ -36,10 +47,11 @@ public function upload() if (! $img->hasMoved()) { $filepath = WRITEPATH . 'uploads/' . $img->store(); - $data = ['uploaded_flleinfo' => new File($filepath)]; + $data = ['uploaded_fileinfo' => new File($filepath)]; return view('upload_success', $data); } + $data = ['errors' => 'The file has already been moved.']; return view('upload_form', $data); From 067289252a9d2c8ea4fd24c21cd3adc9db58a8e8 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Fri, 23 Dec 2022 16:50:19 +0800 Subject: [PATCH 014/118] Revert the html tag and remove the comment out. --- .../source/libraries/uploaded_files.rst | 20 +++++++++---------- .../source/libraries/uploaded_files/002.php | 9 --------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/user_guide_src/source/libraries/uploaded_files.rst b/user_guide_src/source/libraries/uploaded_files.rst index 837052c59d21..2ec5776f8b5d 100644 --- a/user_guide_src/source/libraries/uploaded_files.rst +++ b/user_guide_src/source/libraries/uploaded_files.rst @@ -126,7 +126,7 @@ request, use ``getFiles()``. This will return an array of files represented by i Of course, there are multiple ways to name the file input, and anything but the simplest can create strange results. The array returns in a manner that you would expect. With the simplest usage, a single file might be submitted like:: - + Which would return a simple array like:: @@ -138,7 +138,7 @@ Which would return a simple array like:: If you used an array notation for the name, the input would look something like:: - + The array returned by ``getFiles()`` would look more like this:: @@ -153,8 +153,8 @@ The array returned by ``getFiles()`` would look more like this:: In some cases, you may specify an array of files to upload:: - Upload an avatar: - Upload an avatar: + Upload an avatar: + Upload an avatar: In this case, the returned array of files would be more like:: @@ -179,7 +179,7 @@ Simplest usage With the simplest usage, a single file might be submitted like:: - + Which would return a simple file instance like: @@ -190,7 +190,7 @@ Array notation If you used an array notation for the name, the input would look something like:: - + For get the file instance: @@ -201,7 +201,7 @@ Multiple files :: - + In controller: @@ -221,8 +221,8 @@ You might find it easier to use ``getFileMultiple()``, to get an array of upload Another example:: - Upload an avatar: - Upload an avatar: + Upload an avatar: + Upload an avatar: In controller: @@ -334,7 +334,7 @@ Each file can be moved to its new location with the aptly named ``store()`` meth With the simplest usage, a single file might be submitted like:: - + By default, upload files are saved in **writable/uploads** directory. The **YYYYMMDD** folder and random file name will be created. Returns a file path: diff --git a/user_guide_src/source/libraries/uploaded_files/002.php b/user_guide_src/source/libraries/uploaded_files/002.php index 2cf584f67f9f..44b33a854a61 100644 --- a/user_guide_src/source/libraries/uploaded_files/002.php +++ b/user_guide_src/source/libraries/uploaded_files/002.php @@ -1,14 +1,5 @@ - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - namespace App\Controllers; use CodeIgniter\Files\File; From d1c45f4fce99d7870e12ecc19078dad844eb3baa Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 09:05:00 +0900 Subject: [PATCH 015/118] docs: fix section level --- user_guide_src/source/incoming/request.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index 0b6128a4bd19..edcdbf18b5a3 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -1,5 +1,6 @@ +############# Request Class -************* +############# The request class is an object-oriented representation of an HTTP request. This is meant to work for both incoming, such as a request to the application from a browser, and outgoing requests, @@ -11,7 +12,7 @@ See the documentation for the :doc:`IncomingRequest Class ` for more usage details. Class Reference -=============== +*************** .. php:namespace:: CodeIgniter\HTTP From 08155ec96dd3cc5d04983b6780f017256e795ddb Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 09:25:32 +0900 Subject: [PATCH 016/118] docs: add empty line --- user_guide_src/source/incoming/request.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index edcdbf18b5a3..e92480304b4d 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -4,7 +4,9 @@ Request Class The request class is an object-oriented representation of an HTTP request. This is meant to work for both incoming, such as a request to the application from a browser, and outgoing requests, -like would be used to send a request from the application to a third-party application. This class +like would be used to send a request from the application to a third-party application. + +This class provides the common functionality they both need, but both cases have custom classes that extend from the Request class to add specific functionality. From 4bcedb057a53f1b3132900351880c648fa4fa9d3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 09:29:32 +0900 Subject: [PATCH 017/118] docs: fix `here` in links --- user_guide_src/source/incoming/request.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index e92480304b4d..53acd94276df 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -75,8 +75,8 @@ Class Reference .. php:method:: getServer([$index = null[, $filter = null[, $flags = null]]]) :param mixed $index: Value name - :param int $filter: The type of filter to apply. A list of filters can be found `here `__. - :param int|array $flags: Flags to apply. A list of flags can be found `here `__. + :param int $filter: The type of filter to apply. A list of filters can be found in `PHP manual `__. + :param int|array $flags: Flags to apply. A list of flags can be found in `PHP manual `__. :returns: $_SERVER item value if found, null if not :rtype: mixed @@ -93,8 +93,8 @@ Class Reference .. php:method:: getEnv([$index = null[, $filter = null[, $flags = null]]]) :param mixed $index: Value name - :param int $filter: The type of filter to apply. A list of filters can be found `here `__. - :param int|array $flags: Flags to apply. A list of flags can be found `here `__. + :param int $filter: The type of filter to apply. A list of filters can be found in `PHP manual `__. + :param int|array $flags: Flags to apply. A list of flags can be found in `PHP manual `__. :returns: $_ENV item value if found, null if not :rtype: mixed @@ -121,8 +121,8 @@ Class Reference :param string $method: Input filter constant :param mixed $index: Value name - :param int $filter: The type of filter to apply. A list of filters can be found `here `__. - :param int|array $flags: Flags to apply. A list of flags can be found `here `__. + :param int $filter: The type of filter to apply. A list of filters can be found in `PHP manual `__. + :param int|array $flags: Flags to apply. A list of flags can be found in `PHP manual `__. :rtype: mixed Fetches one or more items from a global, like cookies, get, post, etc. From e08b7bb5666ad89af585730049b345c09046523f Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 09:32:15 +0900 Subject: [PATCH 018/118] docs: decorate variables --- user_guide_src/source/incoming/request.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index 53acd94276df..5928a6248d90 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -77,7 +77,7 @@ Class Reference :param mixed $index: Value name :param int $filter: The type of filter to apply. A list of filters can be found in `PHP manual `__. :param int|array $flags: Flags to apply. A list of flags can be found in `PHP manual `__. - :returns: $_SERVER item value if found, null if not + :returns: ``$_SERVER`` item value if found, null if not :rtype: mixed This method is identical to the ``post()``, ``get()`` and ``cookie()`` methods from the @@ -95,7 +95,7 @@ Class Reference :param mixed $index: Value name :param int $filter: The type of filter to apply. A list of filters can be found in `PHP manual `__. :param int|array $flags: Flags to apply. A list of flags can be found in `PHP manual `__. - :returns: $_ENV item value if found, null if not + :returns: ``$_ENV`` item value if found, null if not :rtype: mixed This method is identical to the ``post()``, ``get()`` and ``cookie()`` methods from the @@ -115,7 +115,7 @@ Class Reference :returns: HTTP request method :rtype: Request - Allows manually setting the value of PHP global, like $_GET, $_POST, etc. + Allows manually setting the value of PHP global, like ``$_GET``, ``$_POST``, etc. .. php:method:: fetchGlobal($method [, $index = null[, $filter = null[, $flags = null]]]) From f423b2b73682df5d2d0e5de175a33d76dbdc8b7f Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 09:32:51 +0900 Subject: [PATCH 019/118] docs: fix wrong method names --- user_guide_src/source/incoming/request.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index 5928a6248d90..47e006dc746b 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -80,7 +80,7 @@ Class Reference :returns: ``$_SERVER`` item value if found, null if not :rtype: mixed - This method is identical to the ``post()``, ``get()`` and ``cookie()`` methods from the + This method is identical to the ``getPost()``, ``getGet()`` and ``getCookie()`` methods from the :doc:`IncomingRequest Class `, only it fetches server data (``$_SERVER``): .. literalinclude:: request/004.php @@ -98,8 +98,8 @@ Class Reference :returns: ``$_ENV`` item value if found, null if not :rtype: mixed - This method is identical to the ``post()``, ``get()`` and ``cookie()`` methods from the - :doc:`IncomingRequest Class `, only it fetches getEnv data (``$_ENV``): + This method is identical to the ``getPost()``, ``getGet()`` and ``getCookie()`` methods from the + :doc:`IncomingRequest Class `, only it fetches env data (``$_ENV``): .. literalinclude:: request/006.php From 1c6c0fdbfd7280ef6ffcc639dabfcaea531a1d5e Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 09:35:18 +0900 Subject: [PATCH 020/118] docs: add deprecated --- user_guide_src/source/incoming/request.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index 47e006dc746b..61a9bb8a5f38 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -36,6 +36,9 @@ Class Reference .. php:method:: isValidIP($ip[, $which = '']) + .. deprecated:: 4.0.5 + Use :doc:`../libraries/validation` instead. + .. important:: This method is deprecated. It will be removed in future releases. :param string $ip: IP address @@ -68,6 +71,9 @@ Class Reference .. php:method:: setMethod($method) + .. deprecated:: 4.0.5 + Use :php:meth:`CodeIgniter\\HTTP\\Request::withMethod()` instead. + :param string $upper: Sets the request method. Used when spoofing the request. :returns: HTTP request method :rtype: Request From 2ffdaef72b5af4b9ecc77efc72d528bb989d6056 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 09:37:27 +0900 Subject: [PATCH 021/118] docs: fix wrong descriptions --- user_guide_src/source/incoming/request.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index 61a9bb8a5f38..911fcec08c3c 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -74,8 +74,8 @@ Class Reference .. deprecated:: 4.0.5 Use :php:meth:`CodeIgniter\\HTTP\\Request::withMethod()` instead. - :param string $upper: Sets the request method. Used when spoofing the request. - :returns: HTTP request method + :param string $method: Sets the request method. Used when spoofing the request. + :returns: This request :rtype: Request .. php:method:: getServer([$index = null[, $filter = null[, $flags = null]]]) @@ -118,8 +118,8 @@ Class Reference :param string $method: Method name :param mixed $value: Data to be added - :returns: HTTP request method - :rtype: Request + :returns: This request + :rtype: Request Allows manually setting the value of PHP global, like ``$_GET``, ``$_POST``, etc. From 4440c34dfef51174e50bd1f2250b5078211191ac Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 09:37:49 +0900 Subject: [PATCH 022/118] docs: add missing withMethod() --- user_guide_src/source/incoming/request.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index 911fcec08c3c..d0524f8661a7 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -78,6 +78,14 @@ Class Reference :returns: This request :rtype: Request + .. php:method:: withMethod($method) + + .. versionadded:: 4.0.5 + + :param string $method: Sets the request method. + :returns: New request instance + :rtype: Request + .. php:method:: getServer([$index = null[, $filter = null[, $flags = null]]]) :param mixed $index: Value name From cb7ccc60b604de29aefcd34272888f33f0ce44b9 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 09:44:48 +0900 Subject: [PATCH 023/118] docs: align comments in sample code --- user_guide_src/source/incoming/request/003.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/incoming/request/003.php b/user_guide_src/source/incoming/request/003.php index fbfda408e272..4b0b537b801f 100644 --- a/user_guide_src/source/incoming/request/003.php +++ b/user_guide_src/source/incoming/request/003.php @@ -1,5 +1,5 @@ getMethod(true); // Outputs: POST +echo $request->getMethod(true); // Outputs: POST echo $request->getMethod(false); // Outputs: post -echo $request->getMethod(); // Outputs: post +echo $request->getMethod(); // Outputs: post From 173c742e8129135bf33585ec2a541f501edfbce0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 09:45:14 +0900 Subject: [PATCH 024/118] docs: add description --- user_guide_src/source/incoming/request.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index d0524f8661a7..0a6e91d88102 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -8,7 +8,7 @@ like would be used to send a request from the application to a third-party appli This class provides the common functionality they both need, but both cases have custom classes that extend -from the Request class to add specific functionality. +from the Request class to add specific functionality. In practice, you will need to use these classes. See the documentation for the :doc:`IncomingRequest Class ` and :doc:`CURLRequest Class ` for more usage details. From 3519c715b1c998907568e7839859b88d5c4589ae Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 24 Dec 2022 12:53:57 +0900 Subject: [PATCH 025/118] chore: set GITHUB_AUTH_TOKEN for phive --- .github/workflows/test-deptrac.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-deptrac.yml b/.github/workflows/test-deptrac.yml index e756f83ebcd7..a7c755e58492 100644 --- a/.github/workflows/test-deptrac.yml +++ b/.github/workflows/test-deptrac.yml @@ -73,3 +73,5 @@ jobs: run: | sudo phive --no-progress install --global qossmic/deptrac --trust-gpg-keys B8F640134AB1782E deptrac analyze --cache-file=build/deptrac.cache + env: + GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a2c47fa5cf5b3e6f2297356fe210f022a4ab16e6 Mon Sep 17 00:00:00 2001 From: Dominic Rego Date: Sat, 24 Dec 2022 09:56:05 -0500 Subject: [PATCH 026/118] Update app/Controllers/BaseController.php Co-authored-by: Abdul Malik Ikhsan --- app/Controllers/BaseController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 70d092ba393d..ecea16206654 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -38,7 +38,7 @@ abstract class BaseController extends Controller protected $helpers = []; /** - * Be sure to declare properties for anything you assign. + * Be sure to declare properties for any property fetch you initialized. * The creation of dynamic property is deprecated in PHP 8.2. */ // protected $session; From db56f87527013db169bd4883d51a53df421bdf1b Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 09:43:00 +0900 Subject: [PATCH 027/118] docs: fix file path decoration --- 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 d83f461b3218..245e443ecb65 100644 --- a/user_guide_src/source/installation/upgrade_405.rst +++ b/user_guide_src/source/installation/upgrade_405.rst @@ -16,7 +16,7 @@ Please refer to the upgrade instructions corresponding to your installation meth CodeIgniter 4.0.5 introduces a setting for the cookie SameSite attribute. Prior versions did not set this attribute at all. The default setting for cookies is now `Lax`. This will affect how cookies are handled in -cross-domain contexts and you may need to adjust this setting in your projects. Separate settings in `app/Config/App.php` +cross-domain contexts and you may need to adjust this setting in your projects. Separate settings in **app/Config/App.php** exists for Response cookies and for CSRF cookies. For additional information, see `MDN Web Docs `_. From 4582fbcee3ae47787581c26a485bdb94de716844 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 09:43:30 +0900 Subject: [PATCH 028/118] docs: add () after method names --- user_guide_src/source/installation/upgrade_405.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_405.rst b/user_guide_src/source/installation/upgrade_405.rst index 245e443ecb65..5ea329bb7ef1 100644 --- a/user_guide_src/source/installation/upgrade_405.rst +++ b/user_guide_src/source/installation/upgrade_405.rst @@ -32,8 +32,8 @@ to all classes that extend ``Message`` as well: ``Request``, ``Response`` and th 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`` +* ``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[Trait]::$ipAddress``: This property will become private * ``Request::$proxyIPs``: This property will be removed; access ``config('App')->proxyIPs`` directly From 5deea7bbaeccdf8130edd3225a1d59c60ae5b1fa Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 09:43:50 +0900 Subject: [PATCH 029/118] docs: fix typo --- 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 5ea329bb7ef1..651d04ea323a 100644 --- a/user_guide_src/source/installation/upgrade_405.rst +++ b/user_guide_src/source/installation/upgrade_405.rst @@ -44,7 +44,7 @@ Additional related deprecations from the HTTP layer: **ResponseInterface** This interface intends to include the necessary methods for any framework-compatible response class. -A number of methods expected by the framework were missing and have noe been added. If you use any +A number of methods expected by the framework were missing and have now been added. If you use any classes the implement ``ResponseInterface`` directly they will need to be compatible with the updated requirements. These methods are as follows: From 5a7503c1b801e375973defa44d9799e89c47f816 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 09:44:03 +0900 Subject: [PATCH 030/118] docs: remove ; --- .../source/installation/upgrade_405.rst | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_405.rst b/user_guide_src/source/installation/upgrade_405.rst index 651d04ea323a..81a16f8d8ee9 100644 --- a/user_guide_src/source/installation/upgrade_405.rst +++ b/user_guide_src/source/installation/upgrade_405.rst @@ -48,22 +48,22 @@ A number of methods expected by the framework were missing and have now been add classes the implement ``ResponseInterface`` directly they will need to be compatible with the updated requirements. These methods are as follows: -* ``setLastModified($date);`` -* ``setLink(PagerInterface $pager);`` -* ``setJSON($body, bool $unencoded = false);`` -* ``getJSON();`` -* ``setXML($body);`` -* ``getXML();`` -* ``send();`` -* ``sendHeaders();`` -* ``sendBody();`` -* ``setCookie($name, $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = false, $httponly = false, $samesite = null);`` -* ``hasCookie(string $name, string $value = null, string $prefix = ''): bool;`` -* ``getCookie(string $name = null, string $prefix = '');`` -* ``deleteCookie(string $name = '', string $domain = '', string $path = '/', string $prefix = '');`` -* ``getCookies();`` -* ``redirect(string $uri, string $method = 'auto', int $code = null);`` -* ``download(string $filename = '', $data = '', bool $setMime = false);`` +* ``setLastModified($date)`` +* ``setLink(PagerInterface $pager)`` +* ``setJSON($body, bool $unencoded = false)`` +* ``getJSON(;`` +* ``setXML($body)`` +* ``getXML()`` +* ``send()`` +* ``sendHeaders()`` +* ``sendBody()`` +* ``setCookie($name, $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = false, $httponly = false, $samesite = null)`` +* ``hasCookie(string $name, string $value = null, string $prefix = ''): bool`` +* ``getCookie(string $name = null, string $prefix = '')`` +* ``deleteCookie(string $name = '', string $domain = '', string $path = '/', string $prefix = '')`` +* ``getCookies()`` +* ``redirect(string $uri, string $method = 'auto', int $code = null)`` +* ``download(string $filename = '', $data = '', bool $setMime = false)`` To facilitate use of this interface these methods have been moved from the framework's ``Response`` into a ``ResponseTrait`` which you may use, and ``DownloadResponse`` now extends ``Response`` directly to ensure maximum compatibility. From c22a3d8a21b77677ed9b59967248b34b9079386e Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 09:58:54 +0900 Subject: [PATCH 031/118] docs: fix typo Co-authored-by: Pooya Parsa Dadashi --- 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 81a16f8d8ee9..b35fb56a1757 100644 --- a/user_guide_src/source/installation/upgrade_405.rst +++ b/user_guide_src/source/installation/upgrade_405.rst @@ -51,7 +51,7 @@ updated requirements. These methods are as follows: * ``setLastModified($date)`` * ``setLink(PagerInterface $pager)`` * ``setJSON($body, bool $unencoded = false)`` -* ``getJSON(;`` +* ``getJSON()`` * ``setXML($body)`` * ``getXML()`` * ``send()`` From 390be1a2db4915bf353fefcb6af560c96bc1f587 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 10:46:34 +0900 Subject: [PATCH 032/118] docs: add section titles --- .../source/installation/upgrade_404.rst | 6 +++- .../source/installation/upgrade_405.rst | 21 ++++++++----- .../source/installation/upgrade_410.rst | 3 +- .../source/installation/upgrade_412.rst | 30 +++++++++++++------ .../source/installation/upgrade_413.rst | 8 +++-- .../source/installation/upgrade_414.rst | 8 +++-- .../source/installation/upgrade_415.rst | 8 ++--- .../source/installation/upgrade_416.rst | 2 +- 8 files changed, 59 insertions(+), 27 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_404.rst b/user_guide_src/source/installation/upgrade_404.rst index 899dfb49a35a..fcae336e07f8 100644 --- a/user_guide_src/source/installation/upgrade_404.rst +++ b/user_guide_src/source/installation/upgrade_404.rst @@ -15,7 +15,11 @@ Please refer to the upgrade instructions corresponding to your installation meth CodeIgniter 4.0.4 fixes a bug in the implementation of :doc:`Controller Filters `, breaking code implementing the ``FilterInterface``. -**Update FilterInterface declarations** +Breaking Changes +**************** + +Update FilterInterface Declarations +=================================== The method signatures for ``after()`` and ``before()`` must be updated to include ``$arguments``. The function definitions should be changed from:: diff --git a/user_guide_src/source/installation/upgrade_405.rst b/user_guide_src/source/installation/upgrade_405.rst index d83f461b3218..8a87693667a2 100644 --- a/user_guide_src/source/installation/upgrade_405.rst +++ b/user_guide_src/source/installation/upgrade_405.rst @@ -12,7 +12,11 @@ Please refer to the upgrade instructions corresponding to your installation meth :local: :depth: 2 -**Cookie SameSite support** +Breaking Enhancements +********************* + +Cookie SameSite Support +======================= CodeIgniter 4.0.5 introduces a setting for the cookie SameSite attribute. Prior versions did not set this attribute at all. The default setting for cookies is now `Lax`. This will affect how cookies are handled in @@ -23,7 +27,8 @@ For additional information, see `MDN Web Docs `_ and the `RFC 6265bis revision `_. -**Message::getHeader(s)** +Message::getHeader(s) +===================== The HTTP layer is moving towards `PSR-7 compliance `_. Towards this end ``Message::getHeader()`` and ``Message::getHeaders()`` are deprecated and should be replaced @@ -41,7 +46,8 @@ Additional related deprecations from the HTTP layer: * ``Response[Interface]::getReason()``: Use ``getReasonPhrase()`` instead * ``Response[Interface]::getStatusCode()``: The explicit ``int`` return type will be removed (no action required) -**ResponseInterface** +ResponseInterface +================= This interface intends to include the necessary methods for any framework-compatible response class. A number of methods expected by the framework were missing and have noe been added. If you use any @@ -68,13 +74,14 @@ updated requirements. These methods are as follows: To facilitate use of this interface these methods have been moved from the framework's ``Response`` into a ``ResponseTrait`` which you may use, and ``DownloadResponse`` now extends ``Response`` directly to ensure maximum compatibility. -**Config\Services** +Config\\Services +================ Service discovery has been updated to allow third-party services (when enabled via Modules) to take precedence over core services. Update **app/Config/Services.php** so the class extends ``CodeIgniter\Config\BaseService`` to allow proper discovery of third-party services. Project Files -============= +************* Numerous 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. @@ -86,7 +93,7 @@ the project space: `Explore on Packagist `_ in ``current_url()``, the resulting URIs could be incorrect for a project's configuration, most importantly: ``indexPage`` @@ -20,7 +24,8 @@ would *not* be included. Projects using ``App::$indexPage`` should expect altere ``current_url()`` and all its dependencies (including Response Testing, Pager, Form Helper, Pager, and View Parser). Update your projects accordingly. -**Cache Keys** +Cache Keys +========== Cache handlers had wildly different compatibility for keys. The updated cache drivers now pass all keys through validation, roughly matching PSR-6's recommendations: @@ -35,7 +40,8 @@ all keys through validation, roughly matching PSR-6's recommendations: Update your projects to remove any invalid cache keys. -**BaseConnection::query() return values** +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 @@ -44,13 +50,18 @@ of ``query()`` method and be assess whether the value might be boolean instead o 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. -**ConnectionInterface::isWriteType() declaration added** +Breaking Enhancements +********************* + +ConnectionInterface::isWriteType() Declaration Added +==================================================== If you have written any classes that implement ConnectionInterface, these must now implement the ``isWriteType()`` method, declared as ``public function isWriteType($sql): bool``. If your class extends BaseConnection, then that class will provide a basic ``isWriteType()`` method which you might want to override. -**Test Traits** +Test Traits +=========== The ``CodeIgniter\Test`` namespace has had significant improvements to help developers with their own test cases. Most notably test extensions have moved to Traits to make them easier to @@ -68,7 +79,8 @@ and use any traits you need. For example: Finally, ``ControllerTester`` has been superseded by ``ControllerTestTrait`` to standardize approach and take advantage of the updated response testing (below). -**Test Responses** +Test Responses +============== The tools for testing responses have been consolidated and improved. A new ``TestResponse`` replaces ``ControllerResponse`` and ``FeatureResponse`` with a complete @@ -80,7 +92,7 @@ changes to be aware of: * ``TestResponse`` does not have ``getBody()`` and ``setBody()`` methods, but rather uses the Response methods directly, e.g.: ``$body = $result->response()->getBody();`` Project Files -============= +************* Numerous 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. @@ -92,7 +104,7 @@ the project space: `Explore on Packagist `_ (based on PSR-12). -**Method Scope** +Breaking Changes +**************** The following methods were changed from "public" to "protected" to match their parent class methods and better align with their uses. +Method Scope +============ + If you relied on any of these methods being public (highly unlikely) adjust your code accordingly: * ``CodeIgniter\Database\MySQLi\Connection::execute()`` @@ -45,7 +49,7 @@ If you relied on any of these methods being public (highly unlikely) adjust your * ``CodeIgniter\Test\Mock\MockSecurity.php::sendCookie()`` Project Files -============= +************* All files in the project space were reformatted with the new coding style. This will not affect existing code but you may want to apply the updated coding style to your own projects to keep diff --git a/user_guide_src/source/installation/upgrade_415.rst b/user_guide_src/source/installation/upgrade_415.rst index ae10e90f6874..d23c21a362a3 100644 --- a/user_guide_src/source/installation/upgrade_415.rst +++ b/user_guide_src/source/installation/upgrade_415.rst @@ -24,7 +24,7 @@ and modified the ``set()`` method, then you need to change its definition from ``public function set($key, ?string $value = '', ?bool $escape = null)`` to ``public function set($key, $value = '', ?bool $escape = null)``. -Session DatabaseHandler's database table change +Session DatabaseHandler's Database Table Change ----------------------------------------------- The types of the following columns in the session table have been changed for optimization. @@ -60,7 +60,7 @@ Protecting **GET** method needs only when you use ``form_open()`` auto-generatio because :ref:`auto-routing-legacy` permits any HTTP method to access a controller. Accessing the controller with a method you don't expect could bypass the filter. -CURLRequest header change +CURLRequest Header Change ------------------------- In the previous version, if you didn't provide your own headers, ``CURLRequest`` would send the request-headers from the browser. @@ -68,7 +68,7 @@ The bug was fixed. If your requests depend on the headers, your requests might f In this case, add the necessary headers manually. See :ref:`CURLRequest Class ` for how to add. -Query Builder changes +Query Builder Changes --------------------- For optimization and a bug fix, the following behaviors, mostly used in testing, have been changed. @@ -81,7 +81,7 @@ Breaking Enhancements .. _upgrade-415-multiple-filters-for-a-route: -Multiple filters for a route +Multiple Filters for a Route ---------------------------- A new feature to set multiple filters for a route. diff --git a/user_guide_src/source/installation/upgrade_416.rst b/user_guide_src/source/installation/upgrade_416.rst index ce88d59582b7..3a5b31d1c5e8 100644 --- a/user_guide_src/source/installation/upgrade_416.rst +++ b/user_guide_src/source/installation/upgrade_416.rst @@ -15,7 +15,7 @@ Please refer to the upgrade instructions corresponding to your installation meth Breaking Changes **************** -Validation result changes +Validation Result Changes ========================= Due to a bug fix, the Validation now might change the validation results when you validate an array item (see :ref:`Changelog `). So check the validation results for all the code that validates the array. Validating multiple fields like ``contacts.*.name`` is not affected. From 83c7a415c5916940c39b46a5f9119943264eee39 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 10:47:37 +0900 Subject: [PATCH 033/118] docs: fix link --- user_guide_src/source/installation/upgrade_418.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_418.rst b/user_guide_src/source/installation/upgrade_418.rst index ee3973ba37bc..24f08dde1cca 100644 --- a/user_guide_src/source/installation/upgrade_418.rst +++ b/user_guide_src/source/installation/upgrade_418.rst @@ -15,4 +15,4 @@ Please refer to the upgrade instructions corresponding to your installation meth Breaking Changes **************** -- Due to a security issue in the ``API\ResponseTrait`` all trait methods are now scoped to ``protected``. See the `Security advisory` ` for more information. +- Due to a security issue in the ``API\ResponseTrait`` all trait methods are now scoped to ``protected``. See the `Security advisory GHSA-7528-7jg5-6g62 `_ for more information. From 823dfe98cbd966972340958dde09507e97ba5ce9 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 10:48:02 +0900 Subject: [PATCH 034/118] docs: decorate text --- user_guide_src/source/installation/upgrade_414.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_414.rst b/user_guide_src/source/installation/upgrade_414.rst index a7e52131ca5b..ca3f6020136f 100644 --- a/user_guide_src/source/installation/upgrade_414.rst +++ b/user_guide_src/source/installation/upgrade_414.rst @@ -18,10 +18,10 @@ This release focuses on code style. All changes (except those noted below) are c Breaking Changes **************** -The following methods were changed from "public" to "protected" to match their parent class methods and better align with their uses. Method Scope ============ +The following methods were changed from ``public`` to ``protected`` to match their parent class methods and better align with their uses. If you relied on any of these methods being public (highly unlikely) adjust your code accordingly: * ``CodeIgniter\Database\MySQLi\Connection::execute()`` From 44e3ede9759c56e42915f33375bbd84f43f33649 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 10:48:24 +0900 Subject: [PATCH 035/118] docs: fix expression --- 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 60eed82b58aa..ae0ba9d6fefc 100644 --- a/user_guide_src/source/installation/upgrade_412.rst +++ b/user_guide_src/source/installation/upgrade_412.rst @@ -45,7 +45,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==true``) and will return booleans for write-type queries. Review any use +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. 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 9654a8c00ba7b9c67c05c1b5ee791a568a400165 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 16:34:59 +0900 Subject: [PATCH 036/118] fix: link tag missing `type="application/rss+xml"` --- system/Helpers/html_helper.php | 19 +++++++++---- tests/system/Helpers/HTMLHelperTest.php | 38 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php index 6c04a86a56b6..74ffc441cfa2 100755 --- a/system/Helpers/html_helper.php +++ b/system/Helpers/html_helper.php @@ -222,13 +222,20 @@ function script_tag($src = '', bool $indexPage = false): string /** * Link * - * Generates link to a CSS file + * Generates link tag * - * @param array|string $href Stylesheet href or an array - * @param bool $indexPage should indexPage be added to the CSS path. + * @param array|string $href Stylesheet href or an array + * @param bool $indexPage should indexPage be added to the CSS path. */ - function link_tag($href = '', string $rel = 'stylesheet', string $type = 'text/css', string $title = '', string $media = '', bool $indexPage = false, string $hreflang = ''): string - { + function link_tag( + $href = '', + string $rel = 'stylesheet', + string $type = 'text/css', + string $title = '', + string $media = '', + bool $indexPage = false, + string $hreflang = '' + ): string { $link = 'assertSame($expected, link_tag($target, 'banana', 'fruit', 'Go away', 'VHS')); } + public function testLinkTagFavicon() + { + $tag = link_tag('favicon.ico', 'shortcut icon', 'image/ico'); + + $expected = ''; + $this->assertSame($expected, $tag); + } + + public function testLinkTagRss() + { + $tag = link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed'); + + $expected = ''; + $this->assertSame($expected, $tag); + } + + public function testLinkTagAlternate() + { + $tag = link_tag( + 'http://sp.example.com/', + 'alternate', + '', + '', + 'only screen and (max-width: 640px)' + ); + + $expected = ''; + $this->assertSame($expected, $tag); + } + + public function testLinkTagCanonical() + { + $tag = link_tag('http://www.example.com/', 'canonical'); + + $expected = ''; + $this->assertSame($expected, $tag); + } + public function testLinkTagArray() { $parms = [ From 28222928de32933bc3fee7eea6ce4c7c60dbae23 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 17:01:10 +0900 Subject: [PATCH 037/118] fix: support array with hreflang --- system/Helpers/html_helper.php | 2 +- tests/system/Helpers/HTMLHelperTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php index 74ffc441cfa2..cd0c021866cd 100755 --- a/system/Helpers/html_helper.php +++ b/system/Helpers/html_helper.php @@ -265,7 +265,7 @@ function link_tag( $link .= 'rel="' . $rel . '" '; - if ($type !== '' && $rel !== 'canonical') { + if ($type !== '' && $rel !== 'canonical' && $hreflang === '') { $link .= 'type="' . $type . '" '; } diff --git a/tests/system/Helpers/HTMLHelperTest.php b/tests/system/Helpers/HTMLHelperTest.php index e8489b61e9f2..16e9098ef7ab 100755 --- a/tests/system/Helpers/HTMLHelperTest.php +++ b/tests/system/Helpers/HTMLHelperTest.php @@ -367,6 +367,18 @@ public function testLinkTagArray() $this->assertSame($expected, link_tag($parms)); } + public function testLinkTagArrayHreflang() + { + $tag = link_tag([ + 'href' => 'https://example.com/en', + 'rel' => 'alternate', + 'hreflang' => 'x-default', + ]); + + $expected = ''; + $this->assertSame($expected, $tag); + } + public function testDocType() { $target = 'html4-strict'; From fb7649386f2bdcfc5d66ded07f58105e9bd7d55b Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 25 Dec 2022 17:27:06 +0900 Subject: [PATCH 038/118] fix: fix incorrect test and support other patterns --- system/Helpers/html_helper.php | 2 +- tests/system/Helpers/HTMLHelperTest.php | 30 +++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php index cd0c021866cd..c87c700256ff 100755 --- a/system/Helpers/html_helper.php +++ b/system/Helpers/html_helper.php @@ -265,7 +265,7 @@ function link_tag( $link .= 'rel="' . $rel . '" '; - if ($type !== '' && $rel !== 'canonical' && $hreflang === '') { + if ($type !== '' && $rel !== 'canonical' && $hreflang === '' && ! ($rel === 'alternate' && $media !== '')) { $link .= 'type="' . $type . '" '; } diff --git a/tests/system/Helpers/HTMLHelperTest.php b/tests/system/Helpers/HTMLHelperTest.php index 16e9098ef7ab..de141881107a 100755 --- a/tests/system/Helpers/HTMLHelperTest.php +++ b/tests/system/Helpers/HTMLHelperTest.php @@ -312,11 +312,21 @@ public function testLinkTag() $this->assertSame($expected, link_tag($target)); } - public function testLinkTagComplete() + public function testLinkTagMedia() { - $target = 'https://styles.com/css/mystyles.css'; - $expected = ''; - $this->assertSame($expected, link_tag($target, 'banana', 'fruit', 'Go away', 'VHS')); + $target = 'https://styles.com/css/mystyles.css'; + $tag = link_tag($target, 'stylesheet', 'text/css', '', 'print'); + + $expected = ''; + $this->assertSame($expected, $tag); + } + + public function testLinkTagTitle() + { + $tag = link_tag('default.css', 'stylesheet', 'text/css', 'Default Style'); + + $expected = ''; + $this->assertSame($expected, $tag); } public function testLinkTagFavicon() @@ -349,6 +359,18 @@ public function testLinkTagAlternate() $this->assertSame($expected, $tag); } + public function testLinkTagArrayAlternate() + { + $tag = link_tag([ + 'href' => 'http://sp.example.com/', + 'rel' => 'alternate', + 'media' => 'only screen and (max-width: 640px)', + ]); + + $expected = ''; + $this->assertSame($expected, $tag); + } + public function testLinkTagCanonical() { $tag = link_tag('http://www.example.com/', 'canonical'); From efd5fecb31e0cd0ea9037eb8fa58dd93720f53bb Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Sun, 25 Dec 2022 18:10:52 +0800 Subject: [PATCH 039/118] docs: replace mixed type in CacheInterface and BaseHandler file. --- system/Cache/CacheInterface.php | 14 +++++++------- system/Cache/Handlers/BaseHandler.php | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/system/Cache/CacheInterface.php b/system/Cache/CacheInterface.php index 72b3626d94cf..574814f6a16c 100644 --- a/system/Cache/CacheInterface.php +++ b/system/Cache/CacheInterface.php @@ -26,16 +26,16 @@ public function initialize(); * * @param string $key Cache item name * - * @return mixed + * @return array|bool|float|int|object|string|null */ public function get(string $key); /** * Saves an item to the cache store. * - * @param string $key Cache item name - * @param mixed $value The data to save - * @param int $ttl Time To Live, in seconds (default 60) + * @param string $key Cache item name + * @param array|bool|float|int|object|string|null $value The data to save + * @param int $ttl Time To Live, in seconds (default 60) * * @return bool Success or failure */ @@ -56,7 +56,7 @@ public function delete(string $key); * @param string $key Cache ID * @param int $offset Step/value to increase by * - * @return mixed + * @return bool|int */ public function increment(string $key, int $offset = 1); @@ -66,7 +66,7 @@ public function increment(string $key, int $offset = 1); * @param string $key Cache ID * @param int $offset Step/value to increase by * - * @return mixed + * @return bool|int */ public function decrement(string $key, int $offset = 1); @@ -83,7 +83,7 @@ public function clean(); * The information returned and the structure of the data * varies depending on the handler. * - * @return mixed + * @return array|bool|float|int|object|string|null */ public function getCacheInfo(); diff --git a/system/Cache/Handlers/BaseHandler.php b/system/Cache/Handlers/BaseHandler.php index 57120208ceeb..0c5ef170c9e0 100644 --- a/system/Cache/Handlers/BaseHandler.php +++ b/system/Cache/Handlers/BaseHandler.php @@ -77,7 +77,7 @@ public static function validateKey($key, $prefix = ''): string * @param int $ttl Time to live * @param Closure $callback Callback return value * - * @return mixed + * @return array|bool|float|int|object|string|null */ public function remember(string $key, int $ttl, Closure $callback) { From 9f81287e4b60dd30b5332cf183e9e8fc27402701 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Mon, 26 Dec 2022 16:34:53 +0800 Subject: [PATCH 040/118] change the comment out of getCacheInfo(). --- system/Cache/CacheInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Cache/CacheInterface.php b/system/Cache/CacheInterface.php index 574814f6a16c..e17ac33039ba 100644 --- a/system/Cache/CacheInterface.php +++ b/system/Cache/CacheInterface.php @@ -83,7 +83,7 @@ public function clean(); * The information returned and the structure of the data * varies depending on the handler. * - * @return array|bool|float|int|object|string|null + * @return array|bool|object|null */ public function getCacheInfo(); From 83c8e32decc76eecc74179f020d3c351da2c70b6 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Mon, 26 Dec 2022 16:57:41 +0800 Subject: [PATCH 041/118] change bool to false. --- system/Cache/CacheInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Cache/CacheInterface.php b/system/Cache/CacheInterface.php index e17ac33039ba..d50322e778f6 100644 --- a/system/Cache/CacheInterface.php +++ b/system/Cache/CacheInterface.php @@ -83,7 +83,7 @@ public function clean(); * The information returned and the structure of the data * varies depending on the handler. * - * @return array|bool|object|null + * @return array|false|object|null */ public function getCacheInfo(); From bbdabb3e3c139f94af95759c33c514e78c443d3a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Dec 2022 15:01:21 +0000 Subject: [PATCH 042/118] chore(deps-dev): update rector/rector requirement from 0.15.1 to 0.15.2 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.1...0.15.2) --- 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 3fb81f249591..af045e7968f7 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.1" + "rector/rector": "0.15.2" }, "suggest": { "ext-curl": "If you use CURLRequest class", From 8f7c50f306341f0977a1d85ba1307f37dc4215b5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 06:57:04 +0900 Subject: [PATCH 043/118] refactor: update sass output sass --no-source-map admin/css/debug-toolbar/toolbar.scss system/Debug/Toolbar/Views/toolbar.css --- system/Debug/Toolbar/Views/toolbar.css | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/system/Debug/Toolbar/Views/toolbar.css b/system/Debug/Toolbar/Views/toolbar.css index 4cb379cbb4cc..744d9392c2be 100644 --- a/system/Debug/Toolbar/Views/toolbar.css +++ b/system/Debug/Toolbar/Views/toolbar.css @@ -427,8 +427,8 @@ -webkit-box-shadow: 0 0 4px #DFDFDF; } #debug-icon a:active, -#debug-icon a:link, -#debug-icon a:visited { + #debug-icon a:link, + #debug-icon a:visited { color: #DD8615; } #debug-bar { @@ -436,17 +436,17 @@ color: #DFDFDF; } #debug-bar h1, -#debug-bar h2, -#debug-bar h3, -#debug-bar p, -#debug-bar a, -#debug-bar button, -#debug-bar table, -#debug-bar thead, -#debug-bar tr, -#debug-bar td, -#debug-bar button, -#debug-bar .toolbar { + #debug-bar h2, + #debug-bar h3, + #debug-bar p, + #debug-bar a, + #debug-bar button, + #debug-bar table, + #debug-bar thead, + #debug-bar tr, + #debug-bar td, + #debug-bar button, + #debug-bar .toolbar { background-color: transparent; color: #DFDFDF; } @@ -498,7 +498,7 @@ color: #DFDFDF; } #debug-bar #toolbar-position, -#debug-bar #toolbar-theme { + #debug-bar #toolbar-theme { filter: brightness(0) invert(0.6); } #debug-bar .ci-label.active { @@ -518,7 +518,7 @@ -webkit-box-shadow: 0 -1px 4px #434343; } #debug-bar .timeline th, -#debug-bar .timeline td { + #debug-bar .timeline td { border-color: #434343; } #debug-bar .timeline .timer { From 441356a0758f8e3e2fc44b3d231c1c5df6631fa4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 08:30:48 +0900 Subject: [PATCH 044/118] docs: fix instructions of Helper upgrading from 3.x --- .../source/installation/upgrade_4xx.rst | 18 ++++++++++++++++++ user_guide_src/source/outgoing/response.rst | 2 ++ 2 files changed, 20 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_4xx.rst b/user_guide_src/source/installation/upgrade_4xx.rst index 6eadd080a02c..7c39c3382a7d 100644 --- a/user_guide_src/source/installation/upgrade_4xx.rst +++ b/user_guide_src/source/installation/upgrade_4xx.rst @@ -109,6 +109,24 @@ Helpers ======= - Helpers are pretty much the same as before, though some have been simplified. +- Some helpers from CodeIgniter 3 no longer exists in Version 4. For all these + helpers, you have to find a new way to implement your functions. These + helpers are `CAPTCHA Helper `_, + `Email Helper `_. + `Path Helper `_. + and `Smiley Helper `_. +- `Download Helper `_ + in CI3 was removed. You need to use Response object where you are using ``force_download()``. + See :ref:`force-file-download`. +- `Language Helper `_ + in CI3 was removed. But ``lang()`` is always available in CI4. See :php:func:`lang()`. +- `Typography Helper `_ + in CI3 wll be :doc:`Typography Library <../libraries/typography>` in CI4. +- `Directory Helper `_ + and `File Helper `_ in CI3 + 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. - `redirect() Documentation CodeIgniter 3.X `_ - `redirect() Documentation CodeIgniter 4.X <../general/common_functions.html#redirect>`_ diff --git a/user_guide_src/source/outgoing/response.rst b/user_guide_src/source/outgoing/response.rst index 553acba21ea4..f3e0909487a4 100644 --- a/user_guide_src/source/outgoing/response.rst +++ b/user_guide_src/source/outgoing/response.rst @@ -59,6 +59,8 @@ parameter. This is not case-sensitive. .. literalinclude:: response/006.php +.. _force-file-download: + Force File Download =================== From efe105d7945bfb8ed3b038a7c57febf1d2d1d00e Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 08:52:11 +0900 Subject: [PATCH 045/118] docs: add links to other pages --- .../source/installation/upgrade_4xx.rst | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_4xx.rst b/user_guide_src/source/installation/upgrade_4xx.rst index 7c39c3382a7d..9e10c0b71b0f 100644 --- a/user_guide_src/source/installation/upgrade_4xx.rst +++ b/user_guide_src/source/installation/upgrade_4xx.rst @@ -35,8 +35,8 @@ General Adjustments Downloads ========= -- CI4 is still available as a ready-to-run zip or tarball. -- It can also be installed using Composer. +- CI4 is still available as a :doc:`ready-to-run zip or tarball <../installation/installing_manual>`. +- It can also be installed using :doc:`Composer <../installation/installing_composer>`. Namespaces ========== @@ -90,10 +90,10 @@ Class Loading - There is no longer a CodeIgniter "superobject", with framework component references magically injected as properties of your controller. -- Classes are instantiated where needed, and components are managed - by ``Services``. -- The class loader automatically handles PSR-4 style class locating, - within the ``App`` (**app**) and ``CodeIgniter`` (i.e., **system**) top level +- Classes are instantiated where needed, and framework components are managed + by :doc:`../concepts/services`. +- The :doc:`Autoloader <../concepts/autoloader>` automatically handles PSR-4 style class locating, + within the ``App`` (**app** folder) and ``CodeIgniter`` (i.e., **system** folder) top level 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. @@ -108,7 +108,7 @@ Libraries Helpers ======= -- Helpers are pretty much the same as before, though some have been simplified. +- :doc:`Helpers <../general/helpers>` are pretty much the same as before, though some have been simplified. - Some helpers from CodeIgniter 3 no longer exists in Version 4. For all these helpers, you have to find a new way to implement your functions. These helpers are `CAPTCHA Helper `_, @@ -134,7 +134,8 @@ Helpers Events ====== -- Hooks have been replaced by Events. +- `Hooks `_ have been + replaced by :doc:`../extending/events`. - Instead of CI3's ``$hook['post_controller_constructor']`` you now use ``Events::on('post_controller_constructor', ['MyClass', 'MyFunction']);``, with the namespace ``CodeIgniter\Events\Events;``. - Events are always enabled, and are available globally. @@ -149,6 +150,7 @@ Extending the Framework - Make any such classes where you like, and add appropriate service methods in **app/Config/Services.php** to load your components instead of the default ones. +- See :doc:`../extending/core_classes` for details. Upgrading Libraries ******************* From 3c933d58825ee1961dbf72940ae2d90814f50123 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 08:52:29 +0900 Subject: [PATCH 046/118] docs: fix classname sample The first letter must be uppercase. --- 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 9e10c0b71b0f..d5e31262dd09 100644 --- a/user_guide_src/source/installation/upgrade_4xx.rst +++ b/user_guide_src/source/installation/upgrade_4xx.rst @@ -145,7 +145,7 @@ Extending the Framework - You don't need a **core** folder to hold ``MY_...`` framework component extensions or replacements. -- You don't need ``MY_x`` classes inside your libraries folder +- You don't need ``MY_X`` classes inside your libraries folder to extend or replace CI4 pieces. - Make any such classes where you like, and add appropriate service methods in **app/Config/Services.php** to load From b1bb1e959fc6ba5e666def5975f6a4afa002ce71 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 08:57:05 +0900 Subject: [PATCH 047/118] docs: replace x with 'x' It is a string. --- user_guide_src/source/installation/upgrade_4xx.rst | 4 ++-- user_guide_src/source/installation/upgrade_models.rst | 2 +- user_guide_src/source/installation/upgrade_views.rst | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_4xx.rst b/user_guide_src/source/installation/upgrade_4xx.rst index d5e31262dd09..a87886545994 100644 --- a/user_guide_src/source/installation/upgrade_4xx.rst +++ b/user_guide_src/source/installation/upgrade_4xx.rst @@ -102,7 +102,7 @@ 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 +- Instead of CI3's ``$this->load->library('x');`` you can now use ``$this->x = new X();``, following namespaced conventions for your component. Helpers @@ -156,7 +156,7 @@ 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();``, +- Instead of CI3's ``$this->load->library('x');`` you can now use ``$this->x = new X();``, following namespaced conventions for your component. - 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 diff --git a/user_guide_src/source/installation/upgrade_models.rst b/user_guide_src/source/installation/upgrade_models.rst index 278a283c0343..5c57f082ff24 100644 --- a/user_guide_src/source/installation/upgrade_models.rst +++ b/user_guide_src/source/installation/upgrade_models.rst @@ -24,7 +24,7 @@ Upgrade Guide 2. Add this line just after the opening php tag: ``namespace App\Models;``. 3. Below the ``namespace App\Models;`` line add this line: ``use CodeIgniter\Model;``. 4. Replace ``extends CI_Model`` with ``extends Model``. -5. Instead of CI3's ``$this->load->model(x);``, you would now use ``$this->x = new X();``, following namespaced conventions for your component. Alternatively, you can use the :php:func:`model()` function: ``$this->x = model('X');``. +5. Instead of CI3's ``$this->load->model('x');``, you would now use ``$this->x = new X();``, following namespaced conventions for your component. Alternatively, you can use the :php:func:`model()` function: ``$this->x = model('X');``. If you use sub-directories in your model structure you have to change the namespace according to that. Example: You have a version 3 model located in **application/models/users/user_contact.php** the namespace has to be ``namespace App\Models\Users;`` and the model path in the version 4 should look like this: **app/Models/Users/UserContact.php** diff --git a/user_guide_src/source/installation/upgrade_views.rst b/user_guide_src/source/installation/upgrade_views.rst index 29dcace6ee62..668d93c73e18 100644 --- a/user_guide_src/source/installation/upgrade_views.rst +++ b/user_guide_src/source/installation/upgrade_views.rst @@ -15,7 +15,7 @@ What has been changed ===================== - Your views look much like before, but they are invoked differently ... instead of CI3's - ``$this->load->view(x);``, you can use ``return view(x);``. + ``$this->load->view('x');``, you can use ``return view('x');``. - CI4 supports *View Cells* to build your response in pieces, and *View Layouts* for page layout. - The template parser is still there, and substantially enhanced. From 98c6c6df54d380ddc80123ccbbda3a048dbe0709 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 09:05:14 +0900 Subject: [PATCH 048/118] docs: add links to other pages --- user_guide_src/source/installation/upgrade_views.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_views.rst b/user_guide_src/source/installation/upgrade_views.rst index 668d93c73e18..3e56735e3102 100644 --- a/user_guide_src/source/installation/upgrade_views.rst +++ b/user_guide_src/source/installation/upgrade_views.rst @@ -16,8 +16,9 @@ What has been changed - Your views look much like before, but they are invoked differently ... instead of CI3's ``$this->load->view('x');``, you can use ``return view('x');``. -- CI4 supports *View Cells* to build your response in pieces, and *View Layouts* for page layout. -- The template parser is still there, and substantially enhanced. +- CI4 supports :doc:`../outgoing/view_cells` to build your response in pieces, + and :doc:`../outgoing/view_layouts` for page layout. +- The :doc:`Template Parser <../outgoing/view_parser>` is still there, and substantially enhanced. Upgrade Guide ============= From 82a1d536b340890825b9467bf7874b8ad55ffdda Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 09:05:30 +0900 Subject: [PATCH 049/118] docs: replace `here` in the href with the page title --- user_guide_src/source/installation/upgrade_models.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_models.rst b/user_guide_src/source/installation/upgrade_models.rst index 5c57f082ff24..bc5fbf08292f 100644 --- a/user_guide_src/source/installation/upgrade_models.rst +++ b/user_guide_src/source/installation/upgrade_models.rst @@ -32,7 +32,7 @@ Example: You have a version 3 model located in **application/models/users/user_c The new Model in CI4 has a lot of built-in methods. For example, the ``find($id)`` method. With this you can find data where the primary key is equal to ``$id``. Inserting data is also easier than before. In CI4 there is an ``insert($data)`` method. You can optionally make use of all those built-in methods and migrate your code to the new methods. -You can find more information to those methods :doc:`here `. +You can find more information to those methods in :doc:`../models/model`. Code Example ============ From c704227a7d9780d0096b2946a0a34714f59db9a5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 09:08:59 +0900 Subject: [PATCH 050/118] docs: add missing `4` --- user_guide_src/source/installation/upgrade_controllers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_controllers.rst b/user_guide_src/source/installation/upgrade_controllers.rst index 1810ea615506..e35fa4abed6c 100644 --- a/user_guide_src/source/installation/upgrade_controllers.rst +++ b/user_guide_src/source/installation/upgrade_controllers.rst @@ -16,7 +16,7 @@ What has been changed - Since namespaces have been added to CodeIgniter 4, the controllers must be changed to support namespaces. - Controllers don't use constructors any more (to invoke CI 'magic') unless those are part of base controllers you make. -- CI provides Request and Response objects for you to work with - more powerful than the CI3-way. +- CI4 provides Request and Response objects for you to work with - more powerful than the CI3-way. - If you want a base controller (``MY_Controller`` in CI3), make it where you like, e.g., BaseController extends Controller, and then have your controllers extend it From bffd864672970c49382118571d9fc100eee0d1c8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 09:27:08 +0900 Subject: [PATCH 051/118] docs: update "What has been changed" in Upgrade Controllers --- user_guide_src/source/incoming/controllers.rst | 2 ++ .../source/installation/upgrade_controllers.rst | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/incoming/controllers.rst b/user_guide_src/source/incoming/controllers.rst index b9eaf738575c..cc9482384089 100644 --- a/user_guide_src/source/incoming/controllers.rst +++ b/user_guide_src/source/incoming/controllers.rst @@ -16,6 +16,8 @@ A Controller is simply a class file that handles a HTTP request. :doc:`URI Routi Every controller you create should extend ``BaseController`` class. This class provides several features that are available to all of your controllers. +.. _controller-constructor: + Constructor *********** diff --git a/user_guide_src/source/installation/upgrade_controllers.rst b/user_guide_src/source/installation/upgrade_controllers.rst index e35fa4abed6c..ca5555de85bb 100644 --- a/user_guide_src/source/installation/upgrade_controllers.rst +++ b/user_guide_src/source/installation/upgrade_controllers.rst @@ -15,10 +15,11 @@ What has been changed ===================== - Since namespaces have been added to CodeIgniter 4, the controllers must be changed to support namespaces. -- Controllers don't use constructors any more (to invoke CI 'magic') unless those are part of base controllers you make. -- CI4 provides Request and Response objects for you to work with - more powerful than the CI3-way. -- If you want a base controller (``MY_Controller`` in CI3), make it where you like, - e.g., BaseController extends Controller, and then have your controllers extend it +- The constructor of CI4 Controller does not automatically load core classes into the properties. +- CI4's Controller has a special constructor :ref:`initController() `. +- CI4 provides :doc:`Request ` and :doc:`Responses ` + objects for you to work with - more powerful than the CI3-way. +- If you want a base controller (``MY_Controller`` in CI3), use **app/Controllers/BaseController.php**. Upgrade Guide ============= From bc2bd33c79e435f241bd95b7b7eca4e3b966381d Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 09:32:39 +0900 Subject: [PATCH 052/118] docs: fix CI3 sample code Even when CI3 is used, protection against XSS is of course necessary. --- .../installation/upgrade_controllers/ci3sample/001.php | 2 +- .../source/installation/upgrade_views/ci3sample/001.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_controllers/ci3sample/001.php b/user_guide_src/source/installation/upgrade_controllers/ci3sample/001.php index d6a01bdea8b1..a0b22b6bb952 100644 --- a/user_guide_src/source/installation/upgrade_controllers/ci3sample/001.php +++ b/user_guide_src/source/installation/upgrade_controllers/ci3sample/001.php @@ -4,6 +4,6 @@ class Helloworld extends CI_Controller { public function index($name) { - echo "Hello $name! "; + echo 'Hello ' . html_escape($name) . '!'; } } diff --git a/user_guide_src/source/installation/upgrade_views/ci3sample/001.php b/user_guide_src/source/installation/upgrade_views/ci3sample/001.php index f0b7c348666d..bbabef2d1819 100644 --- a/user_guide_src/source/installation/upgrade_views/ci3sample/001.php +++ b/user_guide_src/source/installation/upgrade_views/ci3sample/001.php @@ -1,15 +1,15 @@ - <?php echo $title; ?> + <?php echo html_escape($title); ?> -

+

My Todo List

    -
  • +
From 4551956804e4db96695b02b2dd03a2d0106b6aee Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:19:39 +0900 Subject: [PATCH 053/118] docs: add links to other pages --- user_guide_src/source/installation/upgrade_database.rst | 3 ++- user_guide_src/source/installation/upgrade_security.rst | 2 +- user_guide_src/source/installation/upgrade_validations.rst | 2 +- user_guide_src/source/libraries/validation.rst | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_database.rst b/user_guide_src/source/installation/upgrade_database.rst index f62044d8a302..a5228af71e2d 100644 --- a/user_guide_src/source/installation/upgrade_database.rst +++ b/user_guide_src/source/installation/upgrade_database.rst @@ -14,7 +14,8 @@ Documentations What has been changed ===================== - The functionality in CI3 is basically the same as in CI4. -- The method names have changed to camelCase and the query builder now needs to be initialized before you can run queries on it. +- The method names have changed to camelCase and the :doc:`Query Builder <../database/query_builder>` + now needs to be initialized before you can run queries on it. Upgrade Guide ============= diff --git a/user_guide_src/source/installation/upgrade_security.rst b/user_guide_src/source/installation/upgrade_security.rst index c520b9c50350..2d262f5fef0f 100644 --- a/user_guide_src/source/installation/upgrade_security.rst +++ b/user_guide_src/source/installation/upgrade_security.rst @@ -12,7 +12,7 @@ Documentations - :doc:`Security Documentation CodeIgniter 4.X ` .. note:: - If you use the :doc:`form helper ` and enable the CSRF filter globally, then ``form_open()`` will automatically insert a hidden CSRF field in your forms. So you do not have to upgrade this by yourself. + If you use the :doc:`../helpers/form_helper` and enable the CSRF filter globally, then :php:func:`form_open()` will automatically insert a hidden CSRF field in your forms. So you do not have to upgrade this by yourself. What has been changed ===================== diff --git a/user_guide_src/source/installation/upgrade_validations.rst b/user_guide_src/source/installation/upgrade_validations.rst index 5bd6a2a1d514..82744c25630b 100644 --- a/user_guide_src/source/installation/upgrade_validations.rst +++ b/user_guide_src/source/installation/upgrade_validations.rst @@ -13,7 +13,7 @@ Documentations of Library What has been changed ===================== -- If you want to change validation error display, you have to set CI4 validation View templates. +- If you want to change validation error display, you have to set CI4 :ref:`validation View templates `. - CI4 validation has no Callbacks nor Callable in CI3. - CI4 validation format rules do not permit empty string. - CI4 validation never changes your data. diff --git a/user_guide_src/source/libraries/validation.rst b/user_guide_src/source/libraries/validation.rst index ec7f237d7172..8c624fc6d434 100644 --- a/user_guide_src/source/libraries/validation.rst +++ b/user_guide_src/source/libraries/validation.rst @@ -516,6 +516,8 @@ When specifying a field with a wildcard, all errors matching the mask will be ch .. literalinclude:: validation/029.php +.. _validation-customizing-error-display: + Customizing Error Display ************************* From 328a306df0dbc39a78219a7bac2335a6ab04c634 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:20:29 +0900 Subject: [PATCH 054/118] docs: add about main config file --- user_guide_src/source/installation/upgrade_configuration.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_configuration.rst b/user_guide_src/source/installation/upgrade_configuration.rst index aca4af05d4a7..f345cb8c77cd 100644 --- a/user_guide_src/source/installation/upgrade_configuration.rst +++ b/user_guide_src/source/installation/upgrade_configuration.rst @@ -15,6 +15,8 @@ What has been changed ===================== - In CI4, the configurations are now stored in classes which extend ``CodeIgniter\Config\BaseConfig``. +- The **application/config/config.php** in CI3 will be **app/Config/App.php** + and some other files like **app/Config/Security.php** for the specific classes. - Within the configuration class, the config values are stored in public class properties. - The method to fetch config values has been changed. From f512e605f4db2a9fe84bcfe809b847e79b4b239a Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:21:10 +0900 Subject: [PATCH 055/118] docs: replace `here` in href with the page title --- user_guide_src/source/installation/upgrade_responses.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_responses.rst b/user_guide_src/source/installation/upgrade_responses.rst index 6788468c0b57..2059647b230d 100644 --- a/user_guide_src/source/installation/upgrade_responses.rst +++ b/user_guide_src/source/installation/upgrade_responses.rst @@ -17,7 +17,7 @@ What has been changed Upgrade Guide ============= 1. The methods in the HTTP Responses class are named slightly different. The most important change in the naming is the switch from underscored method names to camelCase. The method ``set_content_type()`` from version 3 is now named ``setContentType()`` and so on. -2. In the most cases you have to change ``$this->output`` to ``$this->response`` followed by the method. You can find all methods :doc:`here `. +2. In the most cases you have to change ``$this->output`` to ``$this->response`` followed by the method. You can find all methods in :doc:`../outgoing/response`. Code Example ============ From de63e0cbaa952a73b718b302bedc7aa3cf7c1fb5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:21:46 +0900 Subject: [PATCH 056/118] docs: replace html with HTML --- user_guide_src/source/installation/upgrade_security.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_security.rst b/user_guide_src/source/installation/upgrade_security.rst index 2d262f5fef0f..81bf5e290d56 100644 --- a/user_guide_src/source/installation/upgrade_security.rst +++ b/user_guide_src/source/installation/upgrade_security.rst @@ -16,7 +16,7 @@ Documentations What has been changed ===================== -- The method to implement CSRF tokens to html forms has been changed. +- The method to implement CSRF tokens to HTML forms has been changed. Upgrade Guide ============= From 57e3a139ab77ab9bf746a3b3a35d88b82944e0d7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:22:15 +0900 Subject: [PATCH 057/118] docs: replace echo with return return is recommended. --- user_guide_src/source/installation/upgrade_validations.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_validations.rst b/user_guide_src/source/installation/upgrade_validations.rst index 82744c25630b..45325b3ae327 100644 --- a/user_guide_src/source/installation/upgrade_validations.rst +++ b/user_guide_src/source/installation/upgrade_validations.rst @@ -29,7 +29,7 @@ Upgrade Guide - ``$this->load->helper(array('form', 'url'));`` to ``helper(['form', 'url']);`` - remove the line ``$this->load->library('form_validation');`` - ``if ($this->form_validation->run() == FALSE)`` to ``if (! $this->validate([]))`` - - ``$this->load->view('myform');`` to ``echo view('myform', ['validation' => $this->validator,]);`` + - ``$this->load->view('myform');`` to ``return view('myform', ['validation' => $this->validator,]);`` 3. You have to change the validation rules. The new syntax is to set the rules as array in the controller: From e9cfa97d33c14803aa63f94e5f67bdb2e1229a0c Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:22:40 +0900 Subject: [PATCH 058/118] docs: fix sample config filename It is a classname, not a filename, os `File` is inappropriate. --- user_guide_src/source/installation/upgrade_configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_configuration.rst b/user_guide_src/source/installation/upgrade_configuration.rst index f345cb8c77cd..738473f80ae1 100644 --- a/user_guide_src/source/installation/upgrade_configuration.rst +++ b/user_guide_src/source/installation/upgrade_configuration.rst @@ -32,7 +32,7 @@ Upgrade Guide from the CI3 config into the new CI4 config class as public class properties. 4. Now, you have to change the config fetching syntax everywhere you fetch config values. The CI3 syntax is something like ``$this->config->item('item_name');``. - You have to change this into ``config('MyConfigFile')->item_name;``. + You have to change this into ``config('MyConfig')->item_name;``. Code Example ============ From fa612c89df796c2ed8444423a19c72a2d1a171d5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:23:55 +0900 Subject: [PATCH 059/118] docs: add filename to the Paths --- user_guide_src/source/installation/upgrade_configuration.rst | 4 ++-- .../source/installation/upgrade_configuration/001.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_configuration.rst b/user_guide_src/source/installation/upgrade_configuration.rst index 738473f80ae1..6150b9a01ff6 100644 --- a/user_guide_src/source/installation/upgrade_configuration.rst +++ b/user_guide_src/source/installation/upgrade_configuration.rst @@ -40,13 +40,13 @@ Code Example CodeIgniter Version 3.x ------------------------ -Path: **application/config**: +Path: **application/config/site.php**: .. literalinclude:: upgrade_configuration/ci3sample/001.php CodeIgniter Version 4.x ----------------------- -Path: **app/Config**: +Path: **app/Config/Site.php**: .. literalinclude:: upgrade_configuration/001.php diff --git a/user_guide_src/source/installation/upgrade_configuration/001.php b/user_guide_src/source/installation/upgrade_configuration/001.php index f62f19b7c5ad..fdbbfe4eff0a 100644 --- a/user_guide_src/source/installation/upgrade_configuration/001.php +++ b/user_guide_src/source/installation/upgrade_configuration/001.php @@ -4,7 +4,7 @@ use CodeIgniter\Config\BaseConfig; -class CustomClass extends BaseConfig +class Site extends BaseConfig { public $siteName = 'My Great Site'; public $siteEmail = 'webmaster@example.com'; From cbaf6bf8a1ef6f83ebff3bcd10f72b0b6de042d7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:25:40 +0900 Subject: [PATCH 060/118] docs: use array for validation rules It is easier to read. --- .../source/installation/upgrade_file_upload/001.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_file_upload/001.php b/user_guide_src/source/installation/upgrade_file_upload/001.php index a8b727c29745..c4c6d50db7b4 100644 --- a/user_guide_src/source/installation/upgrade_file_upload/001.php +++ b/user_guide_src/source/installation/upgrade_file_upload/001.php @@ -12,9 +12,13 @@ public function index() public function do_upload() { $this->validate([ - 'userfile' => 'uploaded[userfile]|max_size[userfile,100]' - . '|mime_in[userfile,image/png,image/jpg,image/gif]' - . '|ext_in[userfile,png,jpg,gif]|max_dims[userfile,1024,768]', + 'userfile' => [ + 'uploaded[userfile]', + 'max_size[userfile,100]', + 'mime_in[userfile,image/png,image/jpg,image/gif]', + 'ext_in[userfile,png,jpg,gif]', + 'max_dims[userfile,1024,768]', + ], ]); $file = $this->request->getFile('userfile'); From 39b47b407b565771eab658e0f7398d8ff4137419 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:26:23 +0900 Subject: [PATCH 061/118] docs: add empty line --- user_guide_src/source/installation/upgrade_security/001.php | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/installation/upgrade_security/001.php b/user_guide_src/source/installation/upgrade_security/001.php index 38536bd67cce..c7c907966f0b 100644 --- a/user_guide_src/source/installation/upgrade_security/001.php +++ b/user_guide_src/source/installation/upgrade_security/001.php @@ -14,5 +14,6 @@ class Filters extends BaseConfig 'csrf', ], ]; + // ... } From 427ba14d5ef5ac9667299169a30ac70a76b52a53 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:27:35 +0900 Subject: [PATCH 062/118] docs: replace echo with return --- .../source/installation/upgrade_validations/002.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_validations/002.php b/user_guide_src/source/installation/upgrade_validations/002.php index ddbed1ede5fc..916fae1484d4 100644 --- a/user_guide_src/source/installation/upgrade_validations/002.php +++ b/user_guide_src/source/installation/upgrade_validations/002.php @@ -13,11 +13,11 @@ public function index() if (! $this->validate([ // Validation rules ])) { - echo view('myform', [ + return view('myform', [ 'validation' => $this->validator, ]); - } else { - echo view('formsuccess'); } + + return view('formsuccess'); } } From 7ec0faf8d4bf25ea2143b55e9e88478bfe45c82e Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 10:27:57 +0900 Subject: [PATCH 063/118] docs: add comment --- user_guide_src/source/installation/upgrade_sessions/001.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_sessions/001.php b/user_guide_src/source/installation/upgrade_sessions/001.php index 0bfeeb7f9487..9ac867e4e814 100644 --- a/user_guide_src/source/installation/upgrade_sessions/001.php +++ b/user_guide_src/source/installation/upgrade_sessions/001.php @@ -2,7 +2,7 @@ $session = session(); -$_SESSION['item']; +$_SESSION['item']; // But we do not recommend to use superglobal directly. $session->get('item'); $session->item; session('item'); From 52ac433989db19a6defda17b97913092d94a4d3b Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 17:15:27 +0900 Subject: [PATCH 064/118] fix: ValueError on CLI [ValueError] The arguments array must contain 4 items, 1 given at SYSTEMPATH/HTTP/RequestTrait.php:121 --- system/HTTP/RequestTrait.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/system/HTTP/RequestTrait.php b/system/HTTP/RequestTrait.php index 8c6307bde5fa..2dbc05671797 100644 --- a/system/HTTP/RequestTrait.php +++ b/system/HTTP/RequestTrait.php @@ -73,6 +73,11 @@ public function getIPAddress(): string $this->ipAddress = $this->getServer('REMOTE_ADDR'); + // If this is a CLI request, $this->ipAddress is null. + if ($this->ipAddress === null) { + return $this->ipAddress = '0.0.0.0'; + } + if ($proxyIPs) { // @TODO Extract all this IP address logic to another class. foreach ($proxyIPs as $proxyIP => $header) { From 2c6109170a90327c364cbd3ba9fc9a10f9e5b188 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 17:16:34 +0900 Subject: [PATCH 065/118] refactor: $this->ipAddress is never emtpy Because empty values do not pass the validation. --- system/HTTP/RequestTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/HTTP/RequestTrait.php b/system/HTTP/RequestTrait.php index 2dbc05671797..5dc0359b3488 100644 --- a/system/HTTP/RequestTrait.php +++ b/system/HTTP/RequestTrait.php @@ -44,7 +44,7 @@ trait RequestTrait /** * Gets the user's IP address. * - * @return string IP address if it can be detected, or empty string. + * @return string IP address if it can be detected. * If the IP address is not a valid IP address, * then will return '0.0.0.0'. */ @@ -156,7 +156,7 @@ public function getIPAddress(): string return $this->ipAddress = '0.0.0.0'; } - return empty($this->ipAddress) ? '' : $this->ipAddress; + return $this->ipAddress; } /** From 445438088d36b047e082e6c22a90e0f62b26d300 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 27 Dec 2022 17:18:25 +0900 Subject: [PATCH 066/118] docs: fix incorrect description null is not a valid IP address, so it will be 0.0.0.0. --- user_guide_src/source/incoming/request.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/incoming/request.rst b/user_guide_src/source/incoming/request.rst index 0b6128a4bd19..8f2b52c67815 100644 --- a/user_guide_src/source/incoming/request.rst +++ b/user_guide_src/source/incoming/request.rst @@ -19,8 +19,8 @@ Class Reference .. php:method:: getIPAddress() - :returns: The user's IP Address, if it can be detected, or null. If the IP address - is not a valid IP address, then will return 0.0.0.0 + :returns: The user's IP Address, if it can be detected. If the IP address + is not a valid IP address, then will return 0.0.0.0. :rtype: string Returns the IP address for the current user. If the IP address is not valid, the method From c63a3e02c0c121a719a8a84f23a4045a12996a34 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Mon, 26 Dec 2022 21:41:12 +0700 Subject: [PATCH 067/118] chore: secure workflows permission --- .github/workflows/deploy-apidocs.yml | 4 ++++ .github/workflows/deploy-distributables.yml | 14 ++++++++++++++ .github/workflows/deploy-userguide-latest.yml | 4 ++++ .github/workflows/test-autoreview.yml | 3 +++ .github/workflows/test-coding-standards.yml | 3 +++ .github/workflows/test-deptrac.yml | 3 +++ .github/workflows/test-phpcpd.yml | 3 +++ .github/workflows/test-phpstan.yml | 3 +++ .github/workflows/test-phpunit.yml | 3 +++ .github/workflows/test-rector.yml | 3 +++ .github/workflows/test-scss.yml | 3 +++ .github/workflows/test-userguide.yml | 3 +++ 12 files changed, 49 insertions(+) diff --git a/.github/workflows/deploy-apidocs.yml b/.github/workflows/deploy-apidocs.yml index 41633244cb52..5fbe748beca6 100644 --- a/.github/workflows/deploy-apidocs.yml +++ b/.github/workflows/deploy-apidocs.yml @@ -11,6 +11,10 @@ on: - 'system/**' - '.github/workflows/deploy-apidocs.yml' +permissions: + contents: write + pull-requests: write + jobs: build: name: Deploy to api diff --git a/.github/workflows/deploy-distributables.yml b/.github/workflows/deploy-distributables.yml index d00ebc5a9f36..e53cb814a3c2 100644 --- a/.github/workflows/deploy-distributables.yml +++ b/.github/workflows/deploy-distributables.yml @@ -9,6 +9,8 @@ on: jobs: check-version: name: Check for updated version + permissions: + contents: read runs-on: ubuntu-22.04 steps: @@ -31,6 +33,10 @@ jobs: framework: name: Deploy to framework + permissions: + # Allow actions/github-script to create release + contents: write + pull-requests: write if: github.repository == 'codeigniter4/CodeIgniter4' runs-on: ubuntu-22.04 needs: check-version @@ -78,6 +84,10 @@ jobs: appstarter: name: Deploy to appstarter + permissions: + # Allow actions/github-script to create release + contents: write + pull-requests: write if: github.repository == 'codeigniter4/CodeIgniter4' runs-on: ubuntu-22.04 needs: check-version @@ -125,6 +135,10 @@ jobs: userguide: name: Deploy to userguide + permissions: + # Allow actions/github-script to create release + contents: write + pull-requests: write if: github.repository == 'codeigniter4/CodeIgniter4' runs-on: ubuntu-22.04 needs: check-version diff --git a/.github/workflows/deploy-userguide-latest.yml b/.github/workflows/deploy-userguide-latest.yml index 4ba79a8b341b..94f6391a32e7 100644 --- a/.github/workflows/deploy-userguide-latest.yml +++ b/.github/workflows/deploy-userguide-latest.yml @@ -15,6 +15,10 @@ on: jobs: build: name: Deploy to gh-pages + permissions: + # Allow ad-m/github-push-action to push commit to branch gh-pages + contents: write + pull-requests: write if: (github.repository == 'codeigniter4/CodeIgniter4') runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test-autoreview.yml b/.github/workflows/test-autoreview.yml index b78180249e73..dfe4892bdebe 100644 --- a/.github/workflows/test-autoreview.yml +++ b/.github/workflows/test-autoreview.yml @@ -18,6 +18,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: auto-review-tests: uses: ./.github/workflows/reusable-serviceless-phpunit-test.yml # @TODO Extract to codeigniter4/.github repo diff --git a/.github/workflows/test-coding-standards.yml b/.github/workflows/test-coding-standards.yml index 99e6bd4a3b14..a38e3ab85cd9 100644 --- a/.github/workflows/test-coding-standards.yml +++ b/.github/workflows/test-coding-standards.yml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: lint: name: PHP ${{ matrix.php-version }} Lint with PHP CS Fixer diff --git a/.github/workflows/test-deptrac.yml b/.github/workflows/test-deptrac.yml index a7c755e58492..e6b92346972b 100644 --- a/.github/workflows/test-deptrac.yml +++ b/.github/workflows/test-deptrac.yml @@ -28,6 +28,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: build: name: Architectural Inspection diff --git a/.github/workflows/test-phpcpd.yml b/.github/workflows/test-phpcpd.yml index 9fe3764dfcb1..c4365f7b1e63 100644 --- a/.github/workflows/test-phpcpd.yml +++ b/.github/workflows/test-phpcpd.yml @@ -27,6 +27,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: build: name: Duplicate Code Detection diff --git a/.github/workflows/test-phpstan.yml b/.github/workflows/test-phpstan.yml index 796d78bdba9a..cb793c356d94 100644 --- a/.github/workflows/test-phpstan.yml +++ b/.github/workflows/test-phpstan.yml @@ -31,6 +31,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: build: name: PHP ${{ matrix.php-versions }} Static Analysis diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml index 7c6182cac13c..66dc091f7b0d 100644 --- a/.github/workflows/test-phpunit.yml +++ b/.github/workflows/test-phpunit.yml @@ -31,6 +31,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: # Any environment variables set in an env context defined at the workflow level # in the caller workflow are not propagated to the called workflow. diff --git a/.github/workflows/test-rector.yml b/.github/workflows/test-rector.yml index 7d8c11d61362..89f211120d0d 100644 --- a/.github/workflows/test-rector.yml +++ b/.github/workflows/test-rector.yml @@ -33,6 +33,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: build: name: PHP ${{ matrix.php-versions }} Analyze code (Rector) on ${{ matrix.paths }} diff --git a/.github/workflows/test-scss.yml b/.github/workflows/test-scss.yml index 797bd3e42ea9..26a679719156 100644 --- a/.github/workflows/test-scss.yml +++ b/.github/workflows/test-scss.yml @@ -23,6 +23,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: build: name: Compilation of SCSS (Dart Sass) diff --git a/.github/workflows/test-userguide.yml b/.github/workflows/test-userguide.yml index d3cc4c9d25ea..b188080996db 100644 --- a/.github/workflows/test-userguide.yml +++ b/.github/workflows/test-userguide.yml @@ -14,6 +14,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + jobs: syntax_check: name: Check User Guide syntax From d6336e8143427b3b5ae5b27e29c25dbc4eee401b Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Tue, 27 Dec 2022 20:57:21 +0700 Subject: [PATCH 068/118] correction permission to remove pull-request --- .github/workflows/deploy-apidocs.yml | 6 ++---- .github/workflows/deploy-distributables.yml | 3 --- .github/workflows/deploy-userguide-latest.yml | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-apidocs.yml b/.github/workflows/deploy-apidocs.yml index 5fbe748beca6..9a65a017bea1 100644 --- a/.github/workflows/deploy-apidocs.yml +++ b/.github/workflows/deploy-apidocs.yml @@ -11,13 +11,11 @@ on: - 'system/**' - '.github/workflows/deploy-apidocs.yml' -permissions: - contents: write - pull-requests: write - jobs: build: name: Deploy to api + permissions: + contents: write if: github.repository == 'codeigniter4/CodeIgniter4' runs-on: ubuntu-22.04 diff --git a/.github/workflows/deploy-distributables.yml b/.github/workflows/deploy-distributables.yml index e53cb814a3c2..9e93dd9e3cac 100644 --- a/.github/workflows/deploy-distributables.yml +++ b/.github/workflows/deploy-distributables.yml @@ -36,7 +36,6 @@ jobs: permissions: # Allow actions/github-script to create release contents: write - pull-requests: write if: github.repository == 'codeigniter4/CodeIgniter4' runs-on: ubuntu-22.04 needs: check-version @@ -87,7 +86,6 @@ jobs: permissions: # Allow actions/github-script to create release contents: write - pull-requests: write if: github.repository == 'codeigniter4/CodeIgniter4' runs-on: ubuntu-22.04 needs: check-version @@ -138,7 +136,6 @@ jobs: permissions: # Allow actions/github-script to create release contents: write - pull-requests: write if: github.repository == 'codeigniter4/CodeIgniter4' runs-on: ubuntu-22.04 needs: check-version diff --git a/.github/workflows/deploy-userguide-latest.yml b/.github/workflows/deploy-userguide-latest.yml index 94f6391a32e7..eb0cd8d227ac 100644 --- a/.github/workflows/deploy-userguide-latest.yml +++ b/.github/workflows/deploy-userguide-latest.yml @@ -18,7 +18,6 @@ jobs: permissions: # Allow ad-m/github-push-action to push commit to branch gh-pages contents: write - pull-requests: write if: (github.repository == 'codeigniter4/CodeIgniter4') runs-on: ubuntu-latest steps: From 9b1c61be9c69775f9a7e61c05e7b93abf8564894 Mon Sep 17 00:00:00 2001 From: ddevsr Date: Wed, 28 Dec 2022 08:46:34 +0700 Subject: [PATCH 069/118] set top-level permission with default read --- .github/workflows/deploy-apidocs.yml | 3 +++ .github/workflows/deploy-distributables.yml | 5 +++-- .github/workflows/deploy-userguide-latest.yml | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-apidocs.yml b/.github/workflows/deploy-apidocs.yml index 9a65a017bea1..b117e3dad72b 100644 --- a/.github/workflows/deploy-apidocs.yml +++ b/.github/workflows/deploy-apidocs.yml @@ -11,6 +11,9 @@ on: - 'system/**' - '.github/workflows/deploy-apidocs.yml' +permissions: + contents: read + jobs: build: name: Deploy to api diff --git a/.github/workflows/deploy-distributables.yml b/.github/workflows/deploy-distributables.yml index 9e93dd9e3cac..e279abad2dd7 100644 --- a/.github/workflows/deploy-distributables.yml +++ b/.github/workflows/deploy-distributables.yml @@ -6,11 +6,12 @@ on: release: types: [published] +permissions: + contents: read + jobs: check-version: name: Check for updated version - permissions: - contents: read runs-on: ubuntu-22.04 steps: diff --git a/.github/workflows/deploy-userguide-latest.yml b/.github/workflows/deploy-userguide-latest.yml index eb0cd8d227ac..58e5e731ed18 100644 --- a/.github/workflows/deploy-userguide-latest.yml +++ b/.github/workflows/deploy-userguide-latest.yml @@ -12,6 +12,9 @@ on: paths: - 'user_guide_src/**' +permissions: + contents: read + jobs: build: name: Deploy to gh-pages From 87897ec6db8e4049e4edfcb1cf561b0225a168e6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 28 Dec 2022 15:27:50 +0900 Subject: [PATCH 070/118] docs: fix section title underline --- user_guide_src/source/general/helpers.rst | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/user_guide_src/source/general/helpers.rst b/user_guide_src/source/general/helpers.rst index 684ca021f70e..df4aab4f2329 100644 --- a/user_guide_src/source/general/helpers.rst +++ b/user_guide_src/source/general/helpers.rst @@ -29,8 +29,9 @@ Helpers are typically stored in your **system/Helpers**, or specified helper is not located there CI will instead look in your global **system/Helpers** directory. +**************** Loading a Helper -================ +**************** .. note:: The URL helper is always loaded so you do not need to load it yourself. @@ -50,7 +51,7 @@ For example, to load the **Cookie Helper** file, which is named don't try to assign it to a variable. Just use it as shown. Loading Multiple Helpers ------------------------- +======================== If you need to load more than one helper at a time, you can pass an array of file names in and all of them will be loaded: @@ -58,7 +59,7 @@ an array of file names in and all of them will be loaded: .. literalinclude:: helpers/003.php Loading in a Controller ------------------------ +======================= A helper can be loaded anywhere within your controller methods (or even within your View files, although that's not a good practice), as @@ -75,7 +76,7 @@ property in Controller instead. See :ref:`Controllers `. .. _helpers-loading-from-non-standard-locations: Loading from Non-standard Locations ------------------------------------ +=================================== Helpers can be loaded from directories outside of **app/Helpers** and **system/Helpers**, as long as that path can be found through a namespace that @@ -100,8 +101,9 @@ You can also use the following way: .. note:: The functions within files loaded this way are not truly namespaced. The namespace is simply used as a convenient way to locate the files. +************** Using a Helper -============== +************** Once you've loaded the Helper File containing the function you intend to use, you'll call it the way you would a standard PHP function. @@ -114,8 +116,9 @@ your view files you would do this: Where ``Click Here`` is the name of the link, and ``blog/comments`` is the URI to the controller/method you wish to link to. +******************* "Extending" Helpers -=================== +******************* To "extend" Helpers, create a file in your **app/Helpers/** folder with an identical name to the existing Helper. @@ -145,8 +148,9 @@ is as follows: 2. {namespace}/Helpers - All namespaces are looped through in the order they are defined. 3. system/Helpers - The base file is loaded last +********* Now What? -========= +********* In the Table of Contents, you'll find a list of all the available :doc:`Helpers <../helpers/index>`. Browse each one to see what they do. From e2b83e5dd8fdb86992a80f305c03b068ee53f96f Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 28 Dec 2022 15:33:02 +0900 Subject: [PATCH 071/118] docs: make function name linkable --- user_guide_src/source/general/helpers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/general/helpers.rst b/user_guide_src/source/general/helpers.rst index df4aab4f2329..ebccf0dc5546 100644 --- a/user_guide_src/source/general/helpers.rst +++ b/user_guide_src/source/general/helpers.rst @@ -139,7 +139,7 @@ functions: .. literalinclude:: helpers/006.php -The ``helper()`` function will scan through all PSR-4 namespaces defined in **app/Config/Autoload.php** +The :php:func:`helper()` function will scan through all PSR-4 namespaces defined in **app/Config/Autoload.php** and load in ALL matching helpers of the same name. This allows any module's helpers to be loaded, as well as any helpers you've created specifically for this application. The load order is as follows: From 1eea7f1c3a29fa78a08acf3445726ef10c6c89ae Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 28 Dec 2022 15:33:28 +0900 Subject: [PATCH 072/118] docs: add section title --- user_guide_src/source/general/helpers.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/general/helpers.rst b/user_guide_src/source/general/helpers.rst index ebccf0dc5546..77c4b542124b 100644 --- a/user_guide_src/source/general/helpers.rst +++ b/user_guide_src/source/general/helpers.rst @@ -2,6 +2,14 @@ Helper Functions ################ +.. contents:: + :local: + :depth: 2 + +***************** +What are Helpers? +***************** + Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category. There are **URL Helpers**, that assist in creating links, there are **Form Helpers** that help @@ -9,10 +17,6 @@ you create form elements, **Text Helpers** perform various text formatting routines, **Cookie Helpers** set and read cookies, **File Helpers** help you deal with files, etc. -.. contents:: - :local: - :depth: 2 - Unlike most other systems in CodeIgniter, Helpers are not written in an Object Oriented format. They are simple, procedural functions. Each helper function performs one specific task, with no dependence on other From 9a42d42b4652b1e5198d188f0a8ced8eb3106745 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 28 Dec 2022 15:46:35 +0900 Subject: [PATCH 073/118] dpcs: add note for case sensitive file system --- user_guide_src/source/general/helpers.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/user_guide_src/source/general/helpers.rst b/user_guide_src/source/general/helpers.rst index 77c4b542124b..c4836a3a220b 100644 --- a/user_guide_src/source/general/helpers.rst +++ b/user_guide_src/source/general/helpers.rst @@ -46,6 +46,10 @@ Loading a helper file is quite simple using the following method: Where ``name`` is the file name of the helper, without the "**.php**" file extension or the "**_helper**" part. +.. important:: CodeIgniter helper file names are all lowercase. + Therefore, ``helper('Name')`` will not work on case-sensitive file systems + such as Linux. + For example, to load the **Cookie Helper** file, which is named **cookie_helper.php**, you would do this: From 6f9030af2c150b4f0855ae362a53e4a62824f20f Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 28 Dec 2022 17:02:28 +0900 Subject: [PATCH 074/118] docs: add note on namespace --- user_guide_src/source/general/helpers.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/general/helpers.rst b/user_guide_src/source/general/helpers.rst index c4836a3a220b..8bdd95fe2ec2 100644 --- a/user_guide_src/source/general/helpers.rst +++ b/user_guide_src/source/general/helpers.rst @@ -147,6 +147,8 @@ functions: .. literalinclude:: helpers/006.php +.. important:: Do not specify the namespace ``App\Helpers``. + The :php:func:`helper()` function will scan through all PSR-4 namespaces defined in **app/Config/Autoload.php** and load in ALL matching helpers of the same name. This allows any module's helpers to be loaded, as well as any helpers you've created specifically for this application. The load order From f0c828901dd3c4894abe94ced50f5177be608ed8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 09:09:46 +0900 Subject: [PATCH 075/118] docs: fix description for Timestamp Format --- app/Config/Migrations.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Config/Migrations.php b/app/Config/Migrations.php index 91e80b4a9074..cb9697a63c15 100644 --- a/app/Config/Migrations.php +++ b/app/Config/Migrations.php @@ -44,7 +44,10 @@ class Migrations extends BaseConfig * using the CLI command: * > php spark migrate:create * - * Typical formats: + * Note: if you set an unsupported format, migration runner will not find + * your migration files. + * + * Supported formats: * - YmdHis_ * - Y-m-d-His_ * - Y_m_d_His_ From 1ce498beb629123528efe5bfbc4004b2572f2104 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 10:02:54 +0900 Subject: [PATCH 076/118] docs: add general instruction and section title --- user_guide_src/source/installation/upgrade_423.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_423.rst b/user_guide_src/source/installation/upgrade_423.rst index 980c8b3ed3ed..c78ddb38d77b 100644 --- a/user_guide_src/source/installation/upgrade_423.rst +++ b/user_guide_src/source/installation/upgrade_423.rst @@ -2,8 +2,17 @@ Upgrading from 4.2.2 to 4.2.3 ############################# +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 +Project Files +************* + Version ``4.2.3`` is an internal change for security measures and requires no intervention in projects. From 61a6aa3e0b2c563a216441fb3bb2225ebd7d3df1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 10:04:02 +0900 Subject: [PATCH 077/118] docs: add changelog for v4.2.12 --- user_guide_src/source/changelogs/index.rst | 1 + user_guide_src/source/changelogs/v4.2.12.rst | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 user_guide_src/source/changelogs/v4.2.12.rst diff --git a/user_guide_src/source/changelogs/index.rst b/user_guide_src/source/changelogs/index.rst index 27896bd83847..a9539b9a4649 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.2.12 v4.2.11 v4.2.10 v4.2.9 diff --git a/user_guide_src/source/changelogs/v4.2.12.rst b/user_guide_src/source/changelogs/v4.2.12.rst new file mode 100644 index 000000000000..38b18be92308 --- /dev/null +++ b/user_guide_src/source/changelogs/v4.2.12.rst @@ -0,0 +1,18 @@ +Version 4.2.12 +############## + +Release Date: Unreleased + +**4.2.12 release of CodeIgniter4** + +.. contents:: + :local: + :depth: 2 + +Bugs Fixed +********** + +- Fixed ``Request::getIPaddress()`` causes an error on CLI. +- Fixed ``link_tag()`` missing ``type="application/rss+xml"``. + +See the repo's `CHANGELOG.md `_ for a complete list of bugs fixed. From cd9a1ab4c031ac4f0ddf307310d413db190bd887 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 10:04:22 +0900 Subject: [PATCH 078/118] docs: add upgrading guide for v4.2.12 --- .../source/installation/upgrade_4212.rst | 27 +++++++++++++++++++ .../source/installation/upgrading.rst | 1 + 2 files changed, 28 insertions(+) create mode 100644 user_guide_src/source/installation/upgrade_4212.rst diff --git a/user_guide_src/source/installation/upgrade_4212.rst b/user_guide_src/source/installation/upgrade_4212.rst new file mode 100644 index 000000000000..233f8881ce96 --- /dev/null +++ b/user_guide_src/source/installation/upgrade_4212.rst @@ -0,0 +1,27 @@ +############################### +Upgrading from 4.2.11 to 4.2.12 +############################### + +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 + +Project Files +************* + +Version ``4.2.12`` did not alter any executable code in project files. + +All Changes +=========== + +This is a list of all files in the **project space** that received changes; +many will be simple comments or formatting that have no effect on the runtime: + +* app/Controllers/BaseController.php +* composer.json diff --git a/user_guide_src/source/installation/upgrading.rst b/user_guide_src/source/installation/upgrading.rst index 6a759f93a232..242ac80d1b16 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_4212 upgrade_4211 upgrade_4210 upgrade_428 From 518cab411be11715cd7b572aa39db56ed9f6bc66 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 12:54:31 +0900 Subject: [PATCH 079/118] docs: add about DB caching --- user_guide_src/source/installation/upgrade_database.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_database.rst b/user_guide_src/source/installation/upgrade_database.rst index a5228af71e2d..35efbbeb2042 100644 --- a/user_guide_src/source/installation/upgrade_database.rst +++ b/user_guide_src/source/installation/upgrade_database.rst @@ -14,6 +14,7 @@ Documentations What has been changed ===================== - The functionality in CI3 is basically the same as in CI4. +- `Database Caching `_ in CI3 is removed. - The method names have changed to camelCase and the :doc:`Query Builder <../database/query_builder>` now needs to be initialized before you can run queries on it. @@ -40,6 +41,8 @@ Upgrade Guide - ``$this->db->select_max('age');`` to ``$builder->selectMax('age');`` - ``$this->db->join('comments', 'comments.id = blogs.id');`` to ``$builder->join('comments', 'comments.id = blogs.id');`` - ``$this->db->having('user_id', 45);`` to ``$builder->having('user_id', 45);`` +6. CI4 does not provide `Database Caching `_ + in CI3, so if you need to cache the result, use :doc:`../libraries/caching` instead. Code Example ============ From 4fc6a757f711ec93550376aefc358be6f6d5bb24 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 13:55:44 +0900 Subject: [PATCH 080/118] docs: update deprecated command Co-authored-by: Pooya Parsa Dadashi --- app/Config/Migrations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Config/Migrations.php b/app/Config/Migrations.php index cb9697a63c15..604e059a1cf7 100644 --- a/app/Config/Migrations.php +++ b/app/Config/Migrations.php @@ -42,7 +42,7 @@ class Migrations extends BaseConfig * * This is the format that will be used when creating new migrations * using the CLI command: - * > php spark migrate:create + * > php spark make:migration * * Note: if you set an unsupported format, migration runner will not find * your migration files. From 928bfd338ea7ba13f578f4f3e9c6222cf6a6a220 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 14:00:08 +0900 Subject: [PATCH 081/118] docs: replace deprecated command in examples --- user_guide_src/source/cli/cli_commands.rst | 10 +++++----- user_guide_src/source/cli/cli_commands/001.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/user_guide_src/source/cli/cli_commands.rst b/user_guide_src/source/cli/cli_commands.rst index 7e00cb340e4c..e14a7063cf93 100644 --- a/user_guide_src/source/cli/cli_commands.rst +++ b/user_guide_src/source/cli/cli_commands.rst @@ -22,11 +22,11 @@ and must extend ``CodeIgniter\CLI\BaseCommand``, and implement the ``run()`` met The following properties should be used in order to get listed in CLI commands and to add help functionality to your command: * ``$group``: a string to describe the group the command is lumped under when listing commands. For example: ``Database`` -* ``$name``: a string to describe the command's name. For example: ``migrate:create`` -* ``$description``: a string to describe the command. For example: ``Creates a new migration file.`` -* ``$usage``: a string to describe the command usage. For example: ``migrate:create [name] [options]`` -* ``$arguments``: an array of strings to describe each command argument. For example: ``'name' => 'The migration file name'`` -* ``$options``: an array of strings to describe each command option. For example: ``'-n' => 'Set migration namespace'`` +* ``$name``: a string to describe the command's name. For example: ``make:controller`` +* ``$description``: a string to describe the command. For example: ``Generates a new controller file.`` +* ``$usage``: a string to describe the command usage. For example: ``make:controller [options]`` +* ``$arguments``: an array of strings to describe each command argument. For example: ``'name' => 'The controller class name.'`` +* ``$options``: an array of strings to describe each command option. For example: ``'--force' => 'Force overwrite existing file.'`` **Help description will be automatically generated according to the above parameters.** diff --git a/user_guide_src/source/cli/cli_commands/001.php b/user_guide_src/source/cli/cli_commands/001.php index 0069c7247d43..fb2640fcf01f 100644 --- a/user_guide_src/source/cli/cli_commands/001.php +++ b/user_guide_src/source/cli/cli_commands/001.php @@ -1,3 +1,3 @@ Date: Thu, 29 Dec 2022 14:01:54 +0900 Subject: [PATCH 082/118] docs: update note for deprecated command --- user_guide_src/source/cli/cli_generators.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/cli/cli_generators.rst b/user_guide_src/source/cli/cli_generators.rst index d50665fb6e04..0384c4f3cbaa 100644 --- a/user_guide_src/source/cli/cli_generators.rst +++ b/user_guide_src/source/cli/cli_generators.rst @@ -34,7 +34,7 @@ where ```` will be replaced with the command to check. namespace defined in your ``$psr4`` array in ``Config\Autoload`` or defined in your composer autoload file. Otherwise, code generation will be interrupted. -.. important:: Use of ``migrate:create`` to create migration files is now deprecated. It will be removed in +.. important:: Since v4.0.5, use of ``migrate:create`` to create migration files has been deprecated. It will be removed in future releases. Please use ``make:migration`` as replacement. Also, please use ``make:migration --session`` to use instead of the deprecated ``session:migration``. From 171244de9f71cb020fbec0a4a3d40f4935d2a0ca Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 14:56:09 +0900 Subject: [PATCH 083/118] test: add tests for MigrationRunner::getMigrationName() --- .../Migrations/MigrationRunnerTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/system/Database/Migrations/MigrationRunnerTest.php b/tests/system/Database/Migrations/MigrationRunnerTest.php index 28d9a2301fe5..aa5fdd80c6ff 100644 --- a/tests/system/Database/Migrations/MigrationRunnerTest.php +++ b/tests/system/Database/Migrations/MigrationRunnerTest.php @@ -186,6 +186,24 @@ public function testGetMigrationNumberReturnsZeroIfNoneFound() $this->assertSame('0', $method('Foo')); } + public function testGetMigrationNameDashes() + { + $runner = new MigrationRunner($this->config); + + $method = $this->getPrivateMethodInvoker($runner, 'getMigrationName'); + + $this->assertSame('Foo', $method('2019-08-06-235100_Foo')); + } + + public function testGetMigrationNameUnderscores() + { + $runner = new MigrationRunner($this->config); + + $method = $this->getPrivateMethodInvoker($runner, 'getMigrationName'); + + $this->assertSame('Foo', $method('2019_08_06_235100_Foo')); + } + public function testSetSilentStoresValue() { $runner = new MigrationRunner($this->config); From 2f02ec0085c2fe0b11788c1eee6b3bddb858d841 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 14:59:01 +0900 Subject: [PATCH 084/118] docs: add @param --- system/Database/MigrationRunner.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index 6eb92125237f..3902f5903160 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -448,6 +448,8 @@ public function findNamespaceMigrations(string $namespace): array /** * Create a migration object from a file path. * + * @param string $path Full path to a valid migration file. + * * @return false|object Returns the migration object, or false on failure */ protected function migrationFromFile(string $path, string $namespace) @@ -525,6 +527,8 @@ public function setSilent(bool $silent) /** * Extracts the migration number from a filename + * + * @param string $migration A migration filename w/o path. */ protected function getMigrationNumber(string $migration): string { From 351277eb11eda59f9cd0bbe218aa8928592eac2d Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 14:59:37 +0900 Subject: [PATCH 085/118] refactor: rename variable --- system/Database/MigrationRunner.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index 3902f5903160..4c99d42d8bfa 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -458,9 +458,9 @@ protected function migrationFromFile(string $path, string $namespace) return false; } - $name = basename($path, '.php'); + $filename = basename($path, '.php'); - if (! preg_match($this->regex, $name)) { + if (! preg_match($this->regex, $filename)) { return false; } @@ -468,8 +468,8 @@ protected function migrationFromFile(string $path, string $namespace) $migration = new stdClass(); - $migration->version = $this->getMigrationNumber($name); - $migration->name = $this->getMigrationName($name); + $migration->version = $this->getMigrationNumber($filename); + $migration->name = $this->getMigrationName($filename); $migration->path = $path; $migration->class = $locator->getClassname($path); $migration->namespace = $namespace; From 7e73bab00f59edd5253fe6a6370dee0b08d6bc2f Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 15:00:48 +0900 Subject: [PATCH 086/118] fix: getMigrationName() does not take care of underscore seperator --- system/Database/MigrationRunner.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index 4c99d42d8bfa..e534c763001a 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -538,14 +538,18 @@ protected function getMigrationNumber(string $migration): string } /** - * Extracts the migration class name from a filename + * Extracts the migration name from a filename + * + * Note: The migration name should be the classname, but maybe they are + * different. + * + * @param string $migration A migration filename w/o path. */ protected function getMigrationName(string $migration): string { $parts = explode('_', $migration); - array_shift($parts); - return implode('_', $parts); + return array_pop($parts); } /** From e51b0977890073867e7e61858031baf85162d983 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 15:26:46 +0900 Subject: [PATCH 087/118] docs: fix by proofreading Co-authored-by: Michal Sniatala --- user_guide_src/source/installation/upgrade_database.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_database.rst b/user_guide_src/source/installation/upgrade_database.rst index 35efbbeb2042..b39a6a84ca8d 100644 --- a/user_guide_src/source/installation/upgrade_database.rst +++ b/user_guide_src/source/installation/upgrade_database.rst @@ -42,7 +42,7 @@ Upgrade Guide - ``$this->db->join('comments', 'comments.id = blogs.id');`` to ``$builder->join('comments', 'comments.id = blogs.id');`` - ``$this->db->having('user_id', 45);`` to ``$builder->having('user_id', 45);`` 6. CI4 does not provide `Database Caching `_ - in CI3, so if you need to cache the result, use :doc:`../libraries/caching` instead. + layer known from CI3, so if you need to cache the result, use :doc:`../libraries/caching` instead. Code Example ============ From e6559695f68a4432ab864b981e3b630b489fb9ba Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 15:39:33 +0900 Subject: [PATCH 088/118] fix: getMigrationName() logic --- system/Database/MigrationRunner.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index e534c763001a..5550f8765a9d 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -67,7 +67,7 @@ class MigrationRunner * * @var string */ - protected $regex = '/^\d{4}[_-]?\d{2}[_-]?\d{2}[_-]?\d{6}_(\w+)$/'; + protected $regex = '/\A(\d{4}[_-]?\d{2}[_-]?\d{2}[_-]?\d{6})_(\w+)\z/'; /** * The main database connection. Used to store @@ -547,9 +547,9 @@ protected function getMigrationNumber(string $migration): string */ protected function getMigrationName(string $migration): string { - $parts = explode('_', $migration); + preg_match($this->regex, $migration, $matches); - return array_pop($parts); + return count($matches) ? $matches[2] : ''; } /** From 1496d43bf2b55f3d5a112b0671b96e19951cf39e Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 15:47:00 +0900 Subject: [PATCH 089/118] refactor: use $this->regex --- system/Database/MigrationRunner.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index 5550f8765a9d..569be22807e0 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -532,9 +532,9 @@ public function setSilent(bool $silent) */ protected function getMigrationNumber(string $migration): string { - preg_match('/^\d{4}[_-]?\d{2}[_-]?\d{2}[_-]?\d{6}/', $migration, $matches); + preg_match($this->regex, $migration, $matches); - return count($matches) ? $matches[0] : '0'; + return count($matches) ? $matches[1] : '0'; } /** From 1f71d41266edee43bef4ea4fcbb1d94df4d35295 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 15:51:09 +0900 Subject: [PATCH 090/118] test: update test cases --- tests/system/Database/Migrations/MigrationRunnerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/system/Database/Migrations/MigrationRunnerTest.php b/tests/system/Database/Migrations/MigrationRunnerTest.php index aa5fdd80c6ff..9872080b8719 100644 --- a/tests/system/Database/Migrations/MigrationRunnerTest.php +++ b/tests/system/Database/Migrations/MigrationRunnerTest.php @@ -192,7 +192,7 @@ public function testGetMigrationNameDashes() $method = $this->getPrivateMethodInvoker($runner, 'getMigrationName'); - $this->assertSame('Foo', $method('2019-08-06-235100_Foo')); + $this->assertSame('Foo_bar', $method('2019-08-06-235100_Foo_bar')); } public function testGetMigrationNameUnderscores() @@ -201,7 +201,7 @@ public function testGetMigrationNameUnderscores() $method = $this->getPrivateMethodInvoker($runner, 'getMigrationName'); - $this->assertSame('Foo', $method('2019_08_06_235100_Foo')); + $this->assertSame('Foo_bar', $method('2019_08_06_235100_Foo_bar')); } public function testSetSilentStoresValue() From ea126107453df5ae48af0caa6ff3cba02cebb3df Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 29 Dec 2022 15:58:22 +0900 Subject: [PATCH 091/118] docs: fix by proofreading Co-authored-by: Michal Sniatala --- user_guide_src/source/installation/upgrade_database.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/upgrade_database.rst b/user_guide_src/source/installation/upgrade_database.rst index b39a6a84ca8d..5dc22ddda820 100644 --- a/user_guide_src/source/installation/upgrade_database.rst +++ b/user_guide_src/source/installation/upgrade_database.rst @@ -14,7 +14,7 @@ Documentations What has been changed ===================== - The functionality in CI3 is basically the same as in CI4. -- `Database Caching `_ in CI3 is removed. +- `Database Caching `_ functionality known from CI3 was removed. - The method names have changed to camelCase and the :doc:`Query Builder <../database/query_builder>` now needs to be initialized before you can run queries on it. From e9b627f8c1f248407bc1290c7007fccd71067376 Mon Sep 17 00:00:00 2001 From: michalsn Date: Fri, 30 Dec 2022 08:55:38 +0100 Subject: [PATCH 092/118] fix: save object when useAutoIncrement is disabled --- system/Model.php | 8 ++++++-- tests/system/Models/SaveModelTest.php | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/system/Model.php b/system/Model.php index 55b3b881de37..d91433914a1b 100644 --- a/system/Model.php +++ b/system/Model.php @@ -685,8 +685,12 @@ public function insert($data = null, bool $returnID = true) } } - if ($this->useAutoIncrement === false && isset($data[$this->primaryKey])) { - $this->tempPrimaryKeyValue = $data[$this->primaryKey]; + if ($this->useAutoIncrement === false) { + if (is_array($data) && isset($data[$this->primaryKey])) { + $this->tempPrimaryKeyValue = $data[$this->primaryKey]; + } elseif (is_object($data) && isset($data->{$this->primaryKey})) { + $this->tempPrimaryKeyValue = $data->{$this->primaryKey}; + } } $this->escape = $this->tempData['escape'] ?? []; diff --git a/tests/system/Models/SaveModelTest.php b/tests/system/Models/SaveModelTest.php index 287e96bec275..ad9311cec0e9 100644 --- a/tests/system/Models/SaveModelTest.php +++ b/tests/system/Models/SaveModelTest.php @@ -322,4 +322,27 @@ public function testUseAutoIncrementSetToFalseSave(): void $this->assertSame($insert['key'], $this->model->getInsertID()); $this->seeInDatabase('without_auto_increment', $update); } + + public function testUseAutoIncrementSetToFalseSaveObject(): void + { + $this->createModel(WithoutAutoIncrementModel::class); + + $insert = [ + 'key' => 'some_random_key', + 'value' => 'some value', + ]; + $this->model->save((object) $insert); + + $this->assertSame($insert['key'], $this->model->getInsertID()); + $this->seeInDatabase('without_auto_increment', $insert); + + $update = [ + 'key' => 'some_random_key', + 'value' => 'some different value', + ]; + $this->model->save((object) $update); + + $this->assertSame($insert['key'], $this->model->getInsertID()); + $this->seeInDatabase('without_auto_increment', $update); + } } From a93b8de14c669fae6ecbd66eef9f11efc61df070 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 31 Dec 2022 08:58:02 +0900 Subject: [PATCH 093/118] docs: add two bug fixes --- user_guide_src/source/changelogs/v4.2.12.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/changelogs/v4.2.12.rst b/user_guide_src/source/changelogs/v4.2.12.rst index 38b18be92308..1b60f46dd481 100644 --- a/user_guide_src/source/changelogs/v4.2.12.rst +++ b/user_guide_src/source/changelogs/v4.2.12.rst @@ -14,5 +14,7 @@ Bugs Fixed - Fixed ``Request::getIPaddress()`` causes an error on CLI. - Fixed ``link_tag()`` missing ``type="application/rss+xml"``. +- 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. From 174f5f0c0d2081caa2b5de757e36eff18a389c7d Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 31 Dec 2022 17:35:26 +0900 Subject: [PATCH 094/118] chore: add PHP 8.2 and remove 7.3 --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 975c611a61c3..17e6b415ba0d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -25,10 +25,10 @@ body: description: Which PHP versions did you run your code? multiple: true options: - - '7.3' - '7.4' - '8.0' - '8.1' + - '8.2' validations: required: true From fae617951793156f24d6cf263d447a37f6b3c6d5 Mon Sep 17 00:00:00 2001 From: obozdag Date: Sun, 1 Jan 2023 00:39:05 +0100 Subject: [PATCH 095/118] Typo: Products to Helloworld Typo: Changed the controller name "Products" to "Helloworld" as described in explanation. --- user_guide_src/source/incoming/controllers/007.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/incoming/controllers/007.php b/user_guide_src/source/incoming/controllers/007.php index 7c2e9b7091ea..e943c78bfcca 100644 --- a/user_guide_src/source/incoming/controllers/007.php +++ b/user_guide_src/source/incoming/controllers/007.php @@ -2,7 +2,7 @@ namespace App\Controllers; -class Products extends BaseController +class Helloworld extends BaseController { protected function utility() { From 5764d0c75565443315026731db1e113ece1af371 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Tue, 3 Jan 2023 19:22:27 +0800 Subject: [PATCH 096/118] refactor: change getFile() function to static. --- system/Events/Events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Events/Events.php b/system/Events/Events.php index 3117969882df..064f01ab4104 100644 --- a/system/Events/Events.php +++ b/system/Events/Events.php @@ -246,7 +246,7 @@ public static function setFiles(array $files) * * @return string[] */ - public function getFiles() + public static function getFiles() { return static::$files; } From 5148921b3a730411d70af92663cfb5b43a337118 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Tue, 3 Jan 2023 20:29:46 +0800 Subject: [PATCH 097/118] refactor: replace $this->manange to MockEvents --- tests/system/Events/EventsTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/system/Events/EventsTest.php b/tests/system/Events/EventsTest.php index b6a8aa1a4cb7..82f4580f21e7 100644 --- a/tests/system/Events/EventsTest.php +++ b/tests/system/Events/EventsTest.php @@ -55,21 +55,21 @@ public function testInitialize() // it should start out empty MockEvents::setFiles([]); - $this->assertEmpty($this->manager->getFiles()); + $this->assertEmpty(MockEvents::getFiles()); // make sure we have a default events file $default = [APPPATH . 'Config' . DIRECTORY_SEPARATOR . 'Events.php']; $this->manager->unInitialize(); MockEvents::initialize(); - $this->assertSame($default, $this->manager->getFiles()); + $this->assertSame($default, MockEvents::getFiles()); // but we should be able to change it through the backdoor MockEvents::setFiles(['/peanuts']); - $this->assertSame(['/peanuts'], $this->manager->getFiles()); + $this->assertSame(['/peanuts'], MockEvents::getFiles()); // re-initializing should have no effect MockEvents::initialize(); - $this->assertSame(['/peanuts'], $this->manager->getFiles()); + $this->assertSame(['/peanuts'], MockEvents::getFiles()); } public function testPerformance() From 76610375748e7c90e86b7e086e1c1769d7761dd2 Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Wed, 4 Jan 2023 20:36:32 +0800 Subject: [PATCH 098/118] Revert "refactor: replace $this->manange to MockEvents" This reverts commit 5148921b3a730411d70af92663cfb5b43a337118. --- tests/system/Events/EventsTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/system/Events/EventsTest.php b/tests/system/Events/EventsTest.php index 82f4580f21e7..b6a8aa1a4cb7 100644 --- a/tests/system/Events/EventsTest.php +++ b/tests/system/Events/EventsTest.php @@ -55,21 +55,21 @@ public function testInitialize() // it should start out empty MockEvents::setFiles([]); - $this->assertEmpty(MockEvents::getFiles()); + $this->assertEmpty($this->manager->getFiles()); // make sure we have a default events file $default = [APPPATH . 'Config' . DIRECTORY_SEPARATOR . 'Events.php']; $this->manager->unInitialize(); MockEvents::initialize(); - $this->assertSame($default, MockEvents::getFiles()); + $this->assertSame($default, $this->manager->getFiles()); // but we should be able to change it through the backdoor MockEvents::setFiles(['/peanuts']); - $this->assertSame(['/peanuts'], MockEvents::getFiles()); + $this->assertSame(['/peanuts'], $this->manager->getFiles()); // re-initializing should have no effect MockEvents::initialize(); - $this->assertSame(['/peanuts'], MockEvents::getFiles()); + $this->assertSame(['/peanuts'], $this->manager->getFiles()); } public function testPerformance() From 71d4b5bb85f9d4cf2000f721d0e700ef94e27d6e Mon Sep 17 00:00:00 2001 From: ping-yee <611077101@mail.nknu.edu.tw> Date: Wed, 4 Jan 2023 23:26:11 +0800 Subject: [PATCH 099/118] refactor: change $this->manage to Event class. --- tests/system/Events/EventsTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/system/Events/EventsTest.php b/tests/system/Events/EventsTest.php index b6a8aa1a4cb7..1a106aca3548 100644 --- a/tests/system/Events/EventsTest.php +++ b/tests/system/Events/EventsTest.php @@ -55,21 +55,21 @@ public function testInitialize() // it should start out empty MockEvents::setFiles([]); - $this->assertEmpty($this->manager->getFiles()); + $this->assertEmpty(Events::getFiles()); // make sure we have a default events file $default = [APPPATH . 'Config' . DIRECTORY_SEPARATOR . 'Events.php']; $this->manager->unInitialize(); MockEvents::initialize(); - $this->assertSame($default, $this->manager->getFiles()); + $this->assertSame($default, Events::getFiles()); // but we should be able to change it through the backdoor MockEvents::setFiles(['/peanuts']); - $this->assertSame(['/peanuts'], $this->manager->getFiles()); + $this->assertSame(['/peanuts'], Events::getFiles()); // re-initializing should have no effect MockEvents::initialize(); - $this->assertSame(['/peanuts'], $this->manager->getFiles()); + $this->assertSame(['/peanuts'], Events::getFiles()); } public function testPerformance() From e329c1e28c3a4f876c437f06013869cda112266a Mon Sep 17 00:00:00 2001 From: Mostafa Khudair <59371810+mostafakhudair@users.noreply.github.com> Date: Wed, 4 Jan 2023 22:12:14 +0200 Subject: [PATCH 100/118] tada New Year 2022 tada --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 31425034e8e9..0119e5f554b3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ The MIT License (MIT) Copyright (c) 2014-2019 British Columbia Institute of Technology -Copyright (c) 2019-2022 CodeIgniter Foundation +Copyright (c) 2019-2023 CodeIgniter Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From ec9a589c5939f9e7b24d1bf1f64c1fd1bdf1e668 Mon Sep 17 00:00:00 2001 From: Mostafa Khudair <59371810+mostafakhudair@users.noreply.github.com> Date: Wed, 4 Jan 2023 22:15:14 +0200 Subject: [PATCH 101/118] New Year 2023 --- user_guide_src/source/license.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/license.rst b/user_guide_src/source/license.rst index 40505f1b73ba..4320bd96ccae 100644 --- a/user_guide_src/source/license.rst +++ b/user_guide_src/source/license.rst @@ -3,7 +3,7 @@ The MIT License (MIT) ##################### | Copyright (c) 2014-2019 British Columbia Institute of Technology -| Copyright (c) 2019-2022 CodeIgniter Foundation +| Copyright (c) 2019-2023 CodeIgniter Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From e035451da3eb295446e538e7a1a4366560415420 Mon Sep 17 00:00:00 2001 From: Mostafa Khudair <59371810+mostafakhudair@users.noreply.github.com> Date: Wed, 4 Jan 2023 22:19:54 +0200 Subject: [PATCH 102/118] New Year 2023 --- user_guide_src/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index b5c4bcbc8c12..a839d7225716 100644 --- a/user_guide_src/source/conf.py +++ b/user_guide_src/source/conf.py @@ -18,7 +18,7 @@ project = 'CodeIgniter' author = 'CodeIgniter Foundation' -copyright = '2019-2022 CodeIgniter Foundation' +copyright = '2019-2023 CodeIgniter Foundation' # The short X.Y version. version = '4.2' From 265a0477ba2d8a04e4d3ce7fb090cf4900927112 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Thu, 5 Jan 2023 08:23:00 +0700 Subject: [PATCH 103/118] docs: fix boolean type to follow PSR-5 --- app/Config/Cache.php | 2 +- system/Encryption/Encryption.php | 2 +- system/Test/Interfaces/FabricatorModel.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Config/Cache.php b/app/Config/Cache.php index 2d1fea90c9d1..e76c02d8ff0b 100644 --- a/app/Config/Cache.php +++ b/app/Config/Cache.php @@ -134,7 +134,7 @@ class Cache extends BaseConfig * * @see https://codeigniter.com/user_guide/libraries/caching.html#memcached * - * @var array + * @var array */ public $memcached = [ 'host' => '127.0.0.1', diff --git a/system/Encryption/Encryption.php b/system/Encryption/Encryption.php index 35eb323b0469..81b25eeff5f5 100644 --- a/system/Encryption/Encryption.php +++ b/system/Encryption/Encryption.php @@ -71,7 +71,7 @@ class Encryption /** * Handlers that are to be installed * - * @var array + * @var array */ protected $handlers = []; diff --git a/system/Test/Interfaces/FabricatorModel.php b/system/Test/Interfaces/FabricatorModel.php index 04976a07d24c..7173838a6a2e 100644 --- a/system/Test/Interfaces/FabricatorModel.php +++ b/system/Test/Interfaces/FabricatorModel.php @@ -67,7 +67,7 @@ public function insert($data = null, bool $returnID = true); * Sets $useSoftDeletes value so that we can temporarily override * the softdeletes settings. Can be used for all find* methods. * - * @param boolean $val + * @param bool $val * * @return Model */ From ed85aa522c5715b1a53559903ca86d1afecceda7 Mon Sep 17 00:00:00 2001 From: Jozef Rebjak Date: Thu, 5 Jan 2023 10:14:59 +0100 Subject: [PATCH 104/118] fix: define of STDOUT in CLI init() --- system/CLI/CLI.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index ff1d32995a0b..5d359276eb7c 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -164,7 +164,9 @@ public static function init() } else { // If the command is being called from a controller // we need to define STDOUT ourselves - define('STDOUT', 'php://output'); // @codeCoverageIgnore + if (! defined('STDOUT')) { + define('STDOUT', 'php://output'); // @codeCoverageIgnore + } } } From 6c49d2d1b6ead557de443d4561218fc1c7629b98 Mon Sep 17 00:00:00 2001 From: Jozef Rebjak Date: Thu, 5 Jan 2023 10:47:25 +0100 Subject: [PATCH 105/118] style: run rector --- system/CLI/CLI.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 5d359276eb7c..d9dc58fe9378 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -150,23 +150,16 @@ public static function init() // much more bash-like. // http://www.php.net/manual/en/readline.installation.php static::$readline_support = extension_loaded('readline'); - // clear segments & options to keep testing clean static::$segments = []; static::$options = []; - // Check our stream resource for color support static::$isColored = static::hasColorSupport(STDOUT); - static::parseCommandLine(); - static::$initialized = true; - } else { - // If the command is being called from a controller - // we need to define STDOUT ourselves - if (! defined('STDOUT')) { - define('STDOUT', 'php://output'); // @codeCoverageIgnore - } + } elseif (! defined('STDOUT')) { + define('STDOUT', 'php://output'); + // @codeCoverageIgnore } } From 018c84fb3f82c4ce87f1ca5840afb0734ef5cdc7 Mon Sep 17 00:00:00 2001 From: Jozef Rebjak Date: Thu, 5 Jan 2023 12:18:51 +0100 Subject: [PATCH 106/118] revert line deletion --- system/CLI/CLI.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index d9dc58fe9378..c3c561087eba 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -150,16 +150,22 @@ public static function init() // much more bash-like. // http://www.php.net/manual/en/readline.installation.php static::$readline_support = extension_loaded('readline'); + // clear segments & options to keep testing clean static::$segments = []; static::$options = []; + // Check our stream resource for color support static::$isColored = static::hasColorSupport(STDOUT); + static::parseCommandLine(); + static::$initialized = true; + // See: https://github.com/codeigniter4/CodeIgniter4/issues/7047 } elseif (! defined('STDOUT')) { + // @codeCoverageIgnoreStart define('STDOUT', 'php://output'); - // @codeCoverageIgnore + // @codeCoverageIgnoreEnd } } From 378340a621c18418f631767f05b9425b02884102 Mon Sep 17 00:00:00 2001 From: Jozef Rebjak Date: Thu, 5 Jan 2023 12:21:11 +0100 Subject: [PATCH 107/118] add comments --- system/CLI/CLI.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index c3c561087eba..92e695a310a6 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -161,8 +161,10 @@ public static function init() static::parseCommandLine(); static::$initialized = true; - // See: https://github.com/codeigniter4/CodeIgniter4/issues/7047 } elseif (! defined('STDOUT')) { + // If the command is being called from a controller + // we need to define STDOUT ourselves + // For "! defined('STDOUT')" see: https://github.com/codeigniter4/CodeIgniter4/issues/7047 // @codeCoverageIgnoreStart define('STDOUT', 'php://output'); // @codeCoverageIgnoreEnd From 06a1ce9b89b55273399cdb0fbb0242097d2e5966 Mon Sep 17 00:00:00 2001 From: Jozef Rebjak Date: Thu, 5 Jan 2023 13:57:11 +0100 Subject: [PATCH 108/118] @codeCoverageIgnore beside define --- system/CLI/CLI.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 92e695a310a6..f3488f50265a 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -165,9 +165,7 @@ public static function init() // If the command is being called from a controller // we need to define STDOUT ourselves // For "! defined('STDOUT')" see: https://github.com/codeigniter4/CodeIgniter4/issues/7047 - // @codeCoverageIgnoreStart - define('STDOUT', 'php://output'); - // @codeCoverageIgnoreEnd + define('STDOUT', 'php://output'); // @codeCoverageIgnore } } From 5137cb65b98c93a69c335e6008842da9cf84c89f Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 6 Jan 2023 09:23:20 +0900 Subject: [PATCH 109/118] fix: add fallback to use gethostname() [127.0.0.1] is not valid domain parameter. --- system/Email/Email.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/system/Email/Email.php b/system/Email/Email.php index 384d22fcc63b..dffe4e0e6803 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -2101,6 +2101,11 @@ protected function getHostname() return '[' . $_SERVER['SERVER_ADDR'] . ']'; } + $hostname = gethostname(); + if ($hostname !== false) { + return $hostname; + } + return '[127.0.0.1]'; } From 7e5d886a0257134f3aa74ce69a6319c0dca72d8d Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 6 Jan 2023 20:16:55 +0900 Subject: [PATCH 110/118] chore: update copyright year --- user_guide_src/source/conf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index a839d7225716..2c5f54865d00 100644 --- a/user_guide_src/source/conf.py +++ b/user_guide_src/source/conf.py @@ -12,13 +12,15 @@ # # import os # import sys +import datetime # sys.path.insert(0, os.path.abspath('.')) # -- Project information ----------------------------------------------------- project = 'CodeIgniter' author = 'CodeIgniter Foundation' -copyright = '2019-2023 CodeIgniter Foundation' +year_now = datetime.date.today().year +copyright = '2019-' + str(year_now) + ' CodeIgniter Foundation' # The short X.Y version. version = '4.2' @@ -137,4 +139,4 @@ epub_title = 'CodeIgniter4' epub_author = 'CodeIgniter Foundation' epub_publisher = 'CodeIgniter Foundation' -epub_copyright = '2019-2022 CodeIgniter Foundation' +epub_copyright = copyright From 06357d439a26d00b282a3393b7e68ef4dd12a7fc Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 7 Jan 2023 09:40:02 +0900 Subject: [PATCH 111/118] chore: copy files from codeigniter4/userguide --- admin/userguide/.github/scripts/deploy | 15 +++++++++++++ admin/userguide/.github/workflows/deploy.yml | 22 +++++++++++++++++++ admin/userguide/.gitignore | 17 +++++++++++++++ admin/userguide/LICENSE | 21 ++++++++++++++++++ admin/userguide/README.md | 23 ++++++++------------ admin/userguide/composer.json | 16 -------------- 6 files changed, 84 insertions(+), 30 deletions(-) create mode 100755 admin/userguide/.github/scripts/deploy create mode 100644 admin/userguide/.github/workflows/deploy.yml create mode 100644 admin/userguide/.gitignore create mode 100644 admin/userguide/LICENSE delete mode 100644 admin/userguide/composer.json diff --git a/admin/userguide/.github/scripts/deploy b/admin/userguide/.github/scripts/deploy new file mode 100755 index 000000000000..0347c004dfff --- /dev/null +++ b/admin/userguide/.github/scripts/deploy @@ -0,0 +1,15 @@ +#!/bin/sh -e + +# Deploys the User Guide to the production +# website. Triggered by updates to the GitHub +# repo's master branch. + +REPO=/opt/userguide +SITE=/home/public_html/userguides/userguide4 + +cd "$REPO" +git switch master +git pull + +rm -rf "$SITE" +cp -R "$REPO/docs" "$SITE" diff --git a/admin/userguide/.github/workflows/deploy.yml b/admin/userguide/.github/workflows/deploy.yml new file mode 100644 index 000000000000..ac8027fc7410 --- /dev/null +++ b/admin/userguide/.github/workflows/deploy.yml @@ -0,0 +1,22 @@ +# Deploys the User Guide to the production +# website whenever master branch is updated +name: Deploy Production + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: executing remote ssh commands using ssh key + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + script: /opt/userguide/.github/scripts/deploy diff --git a/admin/userguide/.gitignore b/admin/userguide/.gitignore new file mode 100644 index 000000000000..bfea17cdc5bb --- /dev/null +++ b/admin/userguide/.gitignore @@ -0,0 +1,17 @@ +*/config/development +*/logs/log-*.php +!*/logs/index.html +*/cache/* +!*/cache/index.html +!*/cache/.htaccess + +user_guide_src/build/* +user_guide_src/cilexer/build/* +user_guide_src/cilexer/dist/* +user_guide_src/cilexer/pycilexer.egg-info/* + +#codeigniter 3 +application/logs/* +!application/logs/index.html +!application/logs/.htaccess +/vendor/ diff --git a/admin/userguide/LICENSE b/admin/userguide/LICENSE new file mode 100644 index 000000000000..81ddccc3d847 --- /dev/null +++ b/admin/userguide/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 CodeIgniter 4 web framework + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/admin/userguide/README.md b/admin/userguide/README.md index 10d85692bc38..0ea07075db61 100644 --- a/admin/userguide/README.md +++ b/admin/userguide/README.md @@ -1,20 +1,15 @@ # CodeIgniter 4 User Guide -## What is CodeIgniter? - -CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure. +CodeIgniter 4 is a PHP web framework that is light, fast, flexible, and secure. More information can be found at the [official site](http://codeigniter.com). -This repository holds a composer-installable pre-built user guide for the framework. -It has been built from the -[development repository](https://github.com/codeigniter4/CodeIgniter4). - -More information about the plans for version 4 can be found in [the announcement](http://forum.codeigniter.com/thread-62615.html) on the forums. - -## Installation & updates +**This is a read-only repository used to publish the user guide for the current release.** +It is built automatically as part of the framework release workflow, and pull +requests are not accepted here. -`composer require codeigniter4/userguide` will install a copy -of the user guide inside your project, at -`vendor/codeigniter4/userguide`. You can then `composer update` whenever -there is a new release of the framework. +Development is done in the [main repository](https://github.com/codeigniter4/codeigniter4). +If you find problems with the user guide, please submit a correcting pull request there. +If you feel that features are missing or unclear, please comment on our +[forum](https://forum.codeigniter.com/index.php), +in the appropriate CodeIgniter4 subforum. diff --git a/admin/userguide/composer.json b/admin/userguide/composer.json deleted file mode 100644 index 007664b9b2ec..000000000000 --- a/admin/userguide/composer.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "codeigniter4/userguide", - "type": "project", - "description": "CodeIgniter4 user guide", - "homepage": "https://codeigniter.com", - "license": "MIT", - "require": { - "php": "^7.4 || ^8.0", - "codeigniter4/framework": "^4" - }, - "support": { - "forum": "https://forum.codeigniter.com/", - "source": "https://github.com/codeigniter4/CodeIgniter4", - "slack": "https://codeigniterchat.slack.com" - } -} From 4c4dc80b40b9b38b468643bd2400ef7b849b79df Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 7 Jan 2023 09:45:26 +0900 Subject: [PATCH 112/118] chore: copy files in this repo to userguide --- .github/scripts/deploy-userguide | 6 ++++++ admin/userguide/LICENSE | 21 --------------------- 2 files changed, 6 insertions(+), 21 deletions(-) delete mode 100644 admin/userguide/LICENSE diff --git a/.github/scripts/deploy-userguide b/.github/scripts/deploy-userguide index abbb768a5017..7ad20ba82e2d 100755 --- a/.github/scripts/deploy-userguide +++ b/.github/scripts/deploy-userguide @@ -23,6 +23,12 @@ cd $TARGET git checkout master rm -rf docs +# Copy common files +cp -Rf ${SOURCE}/LICENSE ./ + +# Copy repo-specific files +cp -Rf ${SOURCE}/admin/userguid/. ./ + # Copy files cp -Rf ${SOURCE}/user_guide_src/build/html ./docs cp -Rf ${SOURCE}/user_guide_src/build/epub/CodeIgniter.epub ./CodeIgniter${VERSION}.epub diff --git a/admin/userguide/LICENSE b/admin/userguide/LICENSE deleted file mode 100644 index 81ddccc3d847..000000000000 --- a/admin/userguide/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 CodeIgniter 4 web framework - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. From bb2aea6c65a18c638fd008614ab09cb5c3b11c92 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 7 Jan 2023 10:09:33 +0900 Subject: [PATCH 113/118] chore: remove items for codeigniter 3 --- admin/userguide/.gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/admin/userguide/.gitignore b/admin/userguide/.gitignore index bfea17cdc5bb..d0eba7f4bdaa 100644 --- a/admin/userguide/.gitignore +++ b/admin/userguide/.gitignore @@ -10,8 +10,4 @@ user_guide_src/cilexer/build/* user_guide_src/cilexer/dist/* user_guide_src/cilexer/pycilexer.egg-info/* -#codeigniter 3 -application/logs/* -!application/logs/index.html -!application/logs/.htaccess /vendor/ From a0eb83124c43a53c47d62817a059f71cadf73868 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 7 Jan 2023 10:10:46 +0900 Subject: [PATCH 114/118] chore: fix typo --- .github/scripts/deploy-userguide | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/deploy-userguide b/.github/scripts/deploy-userguide index 7ad20ba82e2d..b67c1da94c13 100755 --- a/.github/scripts/deploy-userguide +++ b/.github/scripts/deploy-userguide @@ -27,7 +27,7 @@ rm -rf docs cp -Rf ${SOURCE}/LICENSE ./ # Copy repo-specific files -cp -Rf ${SOURCE}/admin/userguid/. ./ +cp -Rf ${SOURCE}/admin/userguide/. ./ # Copy files cp -Rf ${SOURCE}/user_guide_src/build/html ./docs From fa27b951ee256ee6126182e2d6bcbf510edc94d0 Mon Sep 17 00:00:00 2001 From: baycik Date: Sat, 7 Jan 2023 13:47:14 +0300 Subject: [PATCH 115/118] Fixing bug with legacy autoRoute When legacy autoRoute is used in case of using controller that sits in sub directory, that directory is determined and stored in $this->directory and new AutoRouter class. But if we subsequently try to load controller without that is not in a directory, then codeigniter can't find it because the $this->directory var in AutoRoute instance is still holding reference to previous directory. This only happens when we load several controllers from console. In my case after upgrading to 4.2.11 my tests fail because of it. I suggest to remove this return; statement to reset directory in AutoRoute instance also. --- system/Router/Router.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/system/Router/Router.php b/system/Router/Router.php index 0be0e4383032..8593cdfd0266 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -574,8 +574,6 @@ public function setDirectory(?string $dir = null, bool $append = false, bool $va { if (empty($dir)) { $this->directory = null; - - return; } if ($this->autoRouter instanceof AutoRouter) { From 6efb825624cbbcc0c15a8b1d1dc034b0604da568 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 7 Jan 2023 21:29:52 +0900 Subject: [PATCH 116/118] docs: add link --- user_guide_src/source/general/urls.rst | 2 ++ user_guide_src/source/installation/troubleshooting.rst | 1 + 2 files changed, 3 insertions(+) diff --git a/user_guide_src/source/general/urls.rst b/user_guide_src/source/general/urls.rst index ec8ce76c15af..25d7b577d977 100644 --- a/user_guide_src/source/general/urls.rst +++ b/user_guide_src/source/general/urls.rst @@ -50,6 +50,8 @@ Route /blog/news/2022/10 Query page=2 ======== ==================================== +.. _urls-remove-index-php: + Removing the index.php file =========================== diff --git a/user_guide_src/source/installation/troubleshooting.rst b/user_guide_src/source/installation/troubleshooting.rst index 426769938a49..30a8d0f55184 100644 --- a/user_guide_src/source/installation/troubleshooting.rst +++ b/user_guide_src/source/installation/troubleshooting.rst @@ -27,6 +27,7 @@ If a URL like ``/mypage/find/apple`` doesn't work, but the similar URL ``/index.php/mypage/find/apple`` does, that sounds like your **.htaccess** rules (for Apache) are not set up properly, or the ``mod_rewrite`` extension in Apache's **httpd.conf** is commented out. +See :ref:`urls-remove-index-php`. Only the default page loads --------------------------- From a7f85d345aa29a211f0473e19cf76856c9bbf9c1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 9 Jan 2023 09:28:26 +0900 Subject: [PATCH 117/118] Prep for 4.2.12 release --- CHANGELOG.md | 19 +++++++++++++++++++ system/CodeIgniter.php | 2 +- user_guide_src/source/changelogs/v4.2.12.rst | 2 +- user_guide_src/source/conf.py | 2 +- .../source/installation/upgrade_4212.rst | 6 ++++-- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f245bfd6b062..7837363ab950 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## [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) diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index e7076c4ba167..79c9ebbf5eae 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.2.11'; + public const CI_VERSION = '4.2.12'; /** * App startup time. diff --git a/user_guide_src/source/changelogs/v4.2.12.rst b/user_guide_src/source/changelogs/v4.2.12.rst index 1b60f46dd481..d3239378f431 100644 --- a/user_guide_src/source/changelogs/v4.2.12.rst +++ b/user_guide_src/source/changelogs/v4.2.12.rst @@ -1,7 +1,7 @@ Version 4.2.12 ############## -Release Date: Unreleased +Release Date: January 9, 2023 **4.2.12 release of CodeIgniter4** diff --git a/user_guide_src/source/conf.py b/user_guide_src/source/conf.py index 2c5f54865d00..89b2532c015d 100644 --- a/user_guide_src/source/conf.py +++ b/user_guide_src/source/conf.py @@ -26,7 +26,7 @@ version = '4.2' # The full version, including alpha/beta/rc tags. -release = '4.2.11' +release = '4.2.12' # -- General configuration --------------------------------------------------- diff --git a/user_guide_src/source/installation/upgrade_4212.rst b/user_guide_src/source/installation/upgrade_4212.rst index 233f8881ce96..ff6005d641d3 100644 --- a/user_guide_src/source/installation/upgrade_4212.rst +++ b/user_guide_src/source/installation/upgrade_4212.rst @@ -23,5 +23,7 @@ All Changes This is a list of all files in the **project space** that received changes; many will be simple comments or formatting that have no effect on the runtime: -* app/Controllers/BaseController.php -* composer.json +* app/Config/Cache.php +* app/Config/Migrations.php +* app/Controllers/BaseController.php +* composer.json From 32beca197ceb53ea99815a7f04f56a2026630452 Mon Sep 17 00:00:00 2001 From: Noritaka IZUMI Date: Mon, 9 Jan 2023 11:24:42 +0900 Subject: [PATCH 118/118] docs: fix the expression of the validation rule "is_unique" --- 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 8c624fc6d434..773cf16f6749 100644 --- a/user_guide_src/source/libraries/validation.rst +++ b/user_guide_src/source/libraries/validation.rst @@ -668,8 +668,8 @@ is_not_unique Yes Checks the database to see if the given value filter (currently accept only one filter). is_unique Yes Checks if this field value exists in the is_unique[table.field,ignore_field,ignore_value] database. Optionally set a column and value - value to ignore, useful when updating records - to ignore itself. + to ignore, useful when updating records to + ignore itself. less_than Yes Fails if field is greater than or equal to less_than[8] the parameter value or not numeric. less_than_equal_to Yes Fails if field is greater than the parameter less_than_equal_to[8]