From 13702a4f1bb8b472b37f51d53d0e7b1948939395 Mon Sep 17 00:00:00 2001 From: obozdag Date: Tue, 30 Apr 2024 17:12:16 +0200 Subject: [PATCH 01/19] docs: Fix typos in libraries/caching.rst Fix typos in libraries/caching.rst --- user_guide_src/source/libraries/caching.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index dd735a8a12c0..a09f6e9f385b 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -67,7 +67,7 @@ This is an array of settings specific to the ``File`` handler to determine how $memcached ========== -This is an array of servers that will be used when using the ``Memcache(d)`` handler. +This is an array of servers that will be used when using the ``Memcached`` handler. $redis ====== @@ -155,7 +155,7 @@ Class Reference .. literalinclude:: caching/004.php - .. note:: The ``$raw`` parameter is only utilized by Memcache, + .. note:: The ``$raw`` parameter is only utilized by Memcached, in order to allow usage of ``increment()`` and ``decrement()``. .. php:method:: delete($key): bool @@ -280,7 +280,7 @@ Drivers File-based Caching ================== -Unlike caching from the Output Class, the driver file-based caching +Unlike caching from the Output Class, the file-based caching allows for pieces of view files to be cached. Use this with care, and make sure to benchmark your application, as a point can come where disk I/O will negate positive gains by caching. This requires a cache From 723af86bfca9c856e712289ae897cdaea4dd0cd1 Mon Sep 17 00:00:00 2001 From: obozdag Date: Wed, 1 May 2024 10:23:39 +0200 Subject: [PATCH 02/19] docs: Fix sentence in File-based Caching in libraries/caching.rst Fix sentence in File-based Caching in libraries/caching.rst --- user_guide_src/source/libraries/caching.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index a09f6e9f385b..fa27a2c53397 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -280,8 +280,7 @@ Drivers File-based Caching ================== -Unlike caching from the Output Class, the file-based caching -allows for pieces of view files to be cached. Use this with care, and +File-based caching allows for pieces of view files to be cached. Use this with care, and make sure to benchmark your application, as a point can come where disk I/O will negate positive gains by caching. This requires a cache directory to be really writable by the application. From 99baa7376e0ffaf8e243abae68a5a57c1717a8ea Mon Sep 17 00:00:00 2001 From: obozdag Date: Thu, 2 May 2024 09:49:51 +0200 Subject: [PATCH 03/19] docs: Change some decorations libraries/caching.rst Change some decorations libraries/caching.rst --- user_guide_src/source/libraries/caching.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index fa27a2c53397..3b4fdc5d4c53 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -36,14 +36,14 @@ $handler ======== The is the name of the handler that should be used as the primary handler when starting up the engine. -Available names are: dummy, file, memcached, redis, predis, wincache. +Available names are: dummy, file, memcached, redis, predis, wincache. This is commonly the **File** handler +since the file system is always available, but may not fit more complex, multi-server setups. $backupHandler ============== In the case that the first choice ``$handler`` is not available, this is the next cache handler to load. -This is commonly the ``File`` handler since the file system is always available, but may not fit -more complex, multi-server setups. +The default backup handler is **dummy**. $prefix ======= @@ -62,17 +62,17 @@ to projects and modules. This will replace the hard-coded value in a future rele $file ===== -This is an array of settings specific to the ``File`` handler to determine how it should save the cache files. +This is an array of settings specific to the **File** handler to determine how it should save the cache files. $memcached ========== -This is an array of servers that will be used when using the ``Memcached`` handler. +This is an array of servers that will be used when using the **Memcached** handler. $redis ====== -The settings for the Redis server that you wish to use when using the ``Redis`` and ``Predis`` handler. +The settings for the Redis server that you wish to use when using the **Redis** and **Predis** handler. ****************** Command-Line Tools From 6056e30953e4ddc35a2adb87de65638ffbb4b555 Mon Sep 17 00:00:00 2001 From: obozdag Date: Thu, 2 May 2024 10:05:02 +0200 Subject: [PATCH 04/19] docs: Remove $raw parameter from save method in libraries/caching.rst Remove $raw parameter from save method in libraries/caching.rst --- user_guide_src/source/libraries/caching.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index 3b4fdc5d4c53..908e429d543d 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -139,12 +139,11 @@ Class Reference Gets an item from the cache. If ``null`` was returned, this will invoke the callback and save the result. Either way, this will return the value. - .. php:method:: save(string $key, $data[, int $ttl = 60[, $raw = false]]) + .. php:method:: save(string $key, $data[, int $ttl = 60]) :param string $key: Cache item name :param mixed $data: the data to save :param int $ttl: Time To Live, in seconds (default 60) - :param bool $raw: Whether to store the raw value :returns: ``true`` on success, ``false`` on failure :rtype: bool @@ -155,9 +154,6 @@ Class Reference .. literalinclude:: caching/004.php - .. note:: The ``$raw`` parameter is only utilized by Memcached, - in order to allow usage of ``increment()`` and ``decrement()``. - .. php:method:: delete($key): bool :param string $key: name of cached item From 4a8866b6da96927da31d96da42457dcad38d5d8d Mon Sep 17 00:00:00 2001 From: obozdag Date: Sun, 5 May 2024 09:21:49 +0200 Subject: [PATCH 05/19] docs: Remove mistakenly changed sentence in libraries/caching.rst Remove mistakenly changed sentence in libraries/caching.rst --- user_guide_src/source/libraries/caching.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index 908e429d543d..f0a702ddc4fb 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -36,8 +36,7 @@ $handler ======== The is the name of the handler that should be used as the primary handler when starting up the engine. -Available names are: dummy, file, memcached, redis, predis, wincache. This is commonly the **File** handler -since the file system is always available, but may not fit more complex, multi-server setups. +Available names are: dummy, file, memcached, redis, predis, wincache. $backupHandler ============== From 33edee13fe0eeb00707076e2f77d78847e7ae39e Mon Sep 17 00:00:00 2001 From: obozdag Date: Sun, 5 May 2024 10:22:07 +0200 Subject: [PATCH 06/19] docs: Updated File-based Caching in libraries/caching.rst Updated File-based Caching in libraries/caching.rst --- user_guide_src/source/libraries/caching.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index f0a702ddc4fb..647055749923 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -275,10 +275,10 @@ Drivers File-based Caching ================== -File-based caching allows for pieces of view files to be cached. Use this with care, and -make sure to benchmark your application, as a point can come where disk -I/O will negate positive gains by caching. This requires a cache -directory to be really writable by the application. +This requires a cache directory to be really writable by the application. + +Use this with care, and make sure to benchmark your application, as a point can +come where disk I/O will negate positive gains by caching. Memcached Caching ================= From 0a45ea8a35afdecc51020553faadec29310a7ec1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 25 May 2024 09:33:37 +0900 Subject: [PATCH 07/19] test: add test for Postgre error message --- .../Database/Live/Postgre/ConnectTest.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/system/Database/Live/Postgre/ConnectTest.php diff --git a/tests/system/Database/Live/Postgre/ConnectTest.php b/tests/system/Database/Live/Postgre/ConnectTest.php new file mode 100644 index 000000000000..29de0976eb21 --- /dev/null +++ b/tests/system/Database/Live/Postgre/ConnectTest.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace CodeIgniter\Database\Live\Postgre; + +use CodeIgniter\Database\Exceptions\DatabaseException; +use CodeIgniter\Test\CIUnitTestCase; +use Config\Database; +use PHPUnit\Framework\Attributes\Group; + +/** + * @internal + */ +#[Group('DatabaseLive')] +final class ConnectTest extends CIUnitTestCase +{ + protected function setUp(): void + { + parent::setUp(); + + $this->db = Database::connect($this->DBGroup); + + if ($this->db->DBDriver !== 'Postgre') { + $this->markTestSkipped('This test is only for Postgre.'); + } + } + + public function testShowErrorMessageWhenSettingInvalidCharset(): void + { + $this->expectException(DatabaseException::class); + $this->expectExceptionMessage( + 'Unable to connect to the database. +Main connection [Postgre]: ERROR: invalid value for parameter "client_encoding": "utf8mb4"' + ); + + $config = config('Database'); + $group = $config->tests; + // Sets invalid charset. + $group['charset'] = 'utf8mb4'; + $db = Database::connect($group); + + // Actually connect to DB. + $db->initialize(); + } +} From 35dc6429c364cb3c9c8a294de97eecbd0e0433a6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 25 May 2024 09:15:53 +0900 Subject: [PATCH 08/19] fix: missing Postgre error message --- system/Database/BaseConnection.php | 1 + system/Database/Postgre/Connection.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 77c9bd39ef3e..6325fd691093 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -420,6 +420,7 @@ public function initialize() // Connect to the database and set the connection ID $this->connID = $this->connect($this->pConnect); } catch (Throwable $e) { + $this->connID = false; $connectionErrors[] = sprintf('Main connection [%s]: %s', $this->DBDriver, $e->getMessage()); log_message('error', 'Error connecting to the database: ' . $e); } diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index 126aa98bb1c2..b1b41d411b7e 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -80,7 +80,9 @@ public function connect(bool $persistent = false) if ($this->connID !== false) { if ($persistent === true && pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD && pg_ping($this->connID) === false ) { - return false; + $error = pg_last_error($this->connID); + + throw new DatabaseException($error); } if (! empty($this->schema)) { @@ -88,7 +90,9 @@ public function connect(bool $persistent = false) } if ($this->setClientEncoding($this->charset) === false) { - return false; + $error = pg_last_error($this->connID); + + throw new DatabaseException($error); } } From 8b3e4e377c2a7cd995781468b27882adbe73d6fe Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 25 May 2024 09:20:20 +0900 Subject: [PATCH 09/19] style: break long lines --- system/Database/BaseConnection.php | 13 +++++++++++-- system/Database/Postgre/Connection.php | 5 ++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 6325fd691093..57c37d8a0a6c 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -421,7 +421,11 @@ public function initialize() $this->connID = $this->connect($this->pConnect); } catch (Throwable $e) { $this->connID = false; - $connectionErrors[] = sprintf('Main connection [%s]: %s', $this->DBDriver, $e->getMessage()); + $connectionErrors[] = sprintf( + 'Main connection [%s]: %s', + $this->DBDriver, + $e->getMessage() + ); log_message('error', 'Error connecting to the database: ' . $e); } @@ -442,7 +446,12 @@ public function initialize() // Try to connect $this->connID = $this->connect($this->pConnect); } catch (Throwable $e) { - $connectionErrors[] = sprintf('Failover #%d [%s]: %s', ++$index, $this->DBDriver, $e->getMessage()); + $connectionErrors[] = sprintf( + 'Failover #%d [%s]: %s', + ++$index, + $this->DBDriver, + $e->getMessage() + ); log_message('error', 'Error connecting to the database: ' . $e); } diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index b1b41d411b7e..c22dc8605f56 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -78,7 +78,10 @@ public function connect(bool $persistent = false) $this->connID = $persistent === true ? pg_pconnect($this->DSN) : pg_connect($this->DSN); if ($this->connID !== false) { - if ($persistent === true && pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD && pg_ping($this->connID) === false + if ( + $persistent === true + && pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD + && pg_ping($this->connID) === false ) { $error = pg_last_error($this->connID); From 8af1608752ffd6305e16137f480ee3e2f10fa630 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 27 May 2024 10:24:32 +0900 Subject: [PATCH 10/19] docs: make description more detailed --- user_guide_src/source/models/model.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/models/model.rst b/user_guide_src/source/models/model.rst index edc4139a4d42..bf91f0a98ce3 100644 --- a/user_guide_src/source/models/model.rst +++ b/user_guide_src/source/models/model.rst @@ -659,9 +659,14 @@ prior to saving to the database with the ``insert()``, ``update()``, or ``save() .. important:: When you update data, by default, the validation in the model class only validates provided fields. This is to avoid validation errors when updating only some fields. - But this means ``required*`` rules do not work as expected when updating. - If you want to check required fields, you can change the behavior by configuration. - See :ref:`clean-validation-rules` for details. + However, this means that not all validation rules you set will be checked + during updates. Thus, incomplete data may pass the validation. + + For example, ``required*`` rules or ``is_unique`` rule that require the + values of other fields may not work as expected. + + To avoid such glitches, this behavior can be changed by configuration. See + :ref:`clean-validation-rules` for details. Setting Validation Rules ------------------------ From e19fc097b912afc4c389c4ba31b0a7ee74bd2fff Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 27 May 2024 10:25:14 +0900 Subject: [PATCH 11/19] docs: add link to section --- user_guide_src/source/models/model.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/models/model.rst b/user_guide_src/source/models/model.rst index bf91f0a98ce3..c77e68cb81b8 100644 --- a/user_guide_src/source/models/model.rst +++ b/user_guide_src/source/models/model.rst @@ -38,7 +38,7 @@ CodeIgniter does provide a model class that has a few nice features, including: - automatic database connection - basic CRUD methods -- in-model validation +- :ref:`in-model validation ` - :ref:`automatic pagination ` - and more From 6b0dfb19f4e7cb7e63d6540e0094eadc786528b5 Mon Sep 17 00:00:00 2001 From: obozdag Date: Mon, 27 May 2024 05:20:31 +0200 Subject: [PATCH 12/19] docs: Rollback the backuphandler explanation in libraries/caching.rst Rollback the backuphandler explanation in libraries/caching.rst --- user_guide_src/source/libraries/caching.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index 647055749923..169fc681f6e6 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -42,7 +42,8 @@ $backupHandler ============== In the case that the first choice ``$handler`` is not available, this is the next cache handler to load. -The default backup handler is **dummy**. +This is commonly the ``File`` handler since the file system is always available, but may not fit +more complex, multi-server setups. $prefix ======= From 798d0554046e81ef300f5dbfb53d1097b90a1941 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 28 May 2024 21:37:32 +0900 Subject: [PATCH 13/19] style: remove unneeded x permissions --- admin/starter/tests/.htaccess | 0 admin/starter/tests/index.html | 0 app/Config/DocTypes.php | 0 system/Database/SQLSRV/Builder.php | 0 system/Database/SQLSRV/Connection.php | 0 system/Database/SQLSRV/Forge.php | 0 system/Database/SQLSRV/PreparedQuery.php | 0 system/Database/SQLSRV/Result.php | 0 system/Database/SQLSRV/Utils.php | 0 system/HTTP/IncomingRequest.php | 0 system/Helpers/cookie_helper.php | 0 system/Helpers/html_helper.php | 0 system/Helpers/inflector_helper.php | 0 system/Helpers/text_helper.php | 0 system/Test/Mock/MockResponse.php | 0 tests/system/Helpers/CookieHelperTest.php | 0 tests/system/Helpers/HTMLHelperTest.php | 0 tests/system/Helpers/InflectorHelperTest.php | 0 tests/system/Helpers/NumberHelperTest.php | 0 tests/system/Helpers/TextHelperTest.php | 0 user_guide_src/source/database/query_builder.rst | 0 user_guide_src/source/general/common_functions.rst | 0 user_guide_src/source/helpers/cookie_helper.rst | 0 user_guide_src/source/helpers/html_helper.rst | 0 user_guide_src/source/helpers/inflector_helper.rst | 0 user_guide_src/source/helpers/text_helper.rst | 0 writable/.htaccess | 0 writable/cache/index.html | 0 writable/debugbar/index.html | 0 writable/index.html | 0 writable/logs/index.html | 0 writable/session/index.html | 0 writable/uploads/index.html | 0 33 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 admin/starter/tests/.htaccess mode change 100755 => 100644 admin/starter/tests/index.html mode change 100755 => 100644 app/Config/DocTypes.php mode change 100755 => 100644 system/Database/SQLSRV/Builder.php mode change 100755 => 100644 system/Database/SQLSRV/Connection.php mode change 100755 => 100644 system/Database/SQLSRV/Forge.php mode change 100755 => 100644 system/Database/SQLSRV/PreparedQuery.php mode change 100755 => 100644 system/Database/SQLSRV/Result.php mode change 100755 => 100644 system/Database/SQLSRV/Utils.php mode change 100755 => 100644 system/HTTP/IncomingRequest.php mode change 100755 => 100644 system/Helpers/cookie_helper.php mode change 100755 => 100644 system/Helpers/html_helper.php mode change 100755 => 100644 system/Helpers/inflector_helper.php mode change 100755 => 100644 system/Helpers/text_helper.php mode change 100755 => 100644 system/Test/Mock/MockResponse.php mode change 100755 => 100644 tests/system/Helpers/CookieHelperTest.php mode change 100755 => 100644 tests/system/Helpers/HTMLHelperTest.php mode change 100755 => 100644 tests/system/Helpers/InflectorHelperTest.php mode change 100755 => 100644 tests/system/Helpers/NumberHelperTest.php mode change 100755 => 100644 tests/system/Helpers/TextHelperTest.php mode change 100755 => 100644 user_guide_src/source/database/query_builder.rst mode change 100755 => 100644 user_guide_src/source/general/common_functions.rst mode change 100755 => 100644 user_guide_src/source/helpers/cookie_helper.rst mode change 100755 => 100644 user_guide_src/source/helpers/html_helper.rst mode change 100755 => 100644 user_guide_src/source/helpers/inflector_helper.rst mode change 100755 => 100644 user_guide_src/source/helpers/text_helper.rst mode change 100755 => 100644 writable/.htaccess mode change 100755 => 100644 writable/cache/index.html mode change 100755 => 100644 writable/debugbar/index.html mode change 100755 => 100644 writable/index.html mode change 100755 => 100644 writable/logs/index.html mode change 100755 => 100644 writable/session/index.html mode change 100755 => 100644 writable/uploads/index.html diff --git a/admin/starter/tests/.htaccess b/admin/starter/tests/.htaccess old mode 100755 new mode 100644 diff --git a/admin/starter/tests/index.html b/admin/starter/tests/index.html old mode 100755 new mode 100644 diff --git a/app/Config/DocTypes.php b/app/Config/DocTypes.php old mode 100755 new mode 100644 diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php old mode 100755 new mode 100644 diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php old mode 100755 new mode 100644 diff --git a/system/Database/SQLSRV/Forge.php b/system/Database/SQLSRV/Forge.php old mode 100755 new mode 100644 diff --git a/system/Database/SQLSRV/PreparedQuery.php b/system/Database/SQLSRV/PreparedQuery.php old mode 100755 new mode 100644 diff --git a/system/Database/SQLSRV/Result.php b/system/Database/SQLSRV/Result.php old mode 100755 new mode 100644 diff --git a/system/Database/SQLSRV/Utils.php b/system/Database/SQLSRV/Utils.php old mode 100755 new mode 100644 diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php old mode 100755 new mode 100644 diff --git a/system/Helpers/cookie_helper.php b/system/Helpers/cookie_helper.php old mode 100755 new mode 100644 diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php old mode 100755 new mode 100644 diff --git a/system/Helpers/inflector_helper.php b/system/Helpers/inflector_helper.php old mode 100755 new mode 100644 diff --git a/system/Helpers/text_helper.php b/system/Helpers/text_helper.php old mode 100755 new mode 100644 diff --git a/system/Test/Mock/MockResponse.php b/system/Test/Mock/MockResponse.php old mode 100755 new mode 100644 diff --git a/tests/system/Helpers/CookieHelperTest.php b/tests/system/Helpers/CookieHelperTest.php old mode 100755 new mode 100644 diff --git a/tests/system/Helpers/HTMLHelperTest.php b/tests/system/Helpers/HTMLHelperTest.php old mode 100755 new mode 100644 diff --git a/tests/system/Helpers/InflectorHelperTest.php b/tests/system/Helpers/InflectorHelperTest.php old mode 100755 new mode 100644 diff --git a/tests/system/Helpers/NumberHelperTest.php b/tests/system/Helpers/NumberHelperTest.php old mode 100755 new mode 100644 diff --git a/tests/system/Helpers/TextHelperTest.php b/tests/system/Helpers/TextHelperTest.php old mode 100755 new mode 100644 diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst old mode 100755 new mode 100644 diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst old mode 100755 new mode 100644 diff --git a/user_guide_src/source/helpers/cookie_helper.rst b/user_guide_src/source/helpers/cookie_helper.rst old mode 100755 new mode 100644 diff --git a/user_guide_src/source/helpers/html_helper.rst b/user_guide_src/source/helpers/html_helper.rst old mode 100755 new mode 100644 diff --git a/user_guide_src/source/helpers/inflector_helper.rst b/user_guide_src/source/helpers/inflector_helper.rst old mode 100755 new mode 100644 diff --git a/user_guide_src/source/helpers/text_helper.rst b/user_guide_src/source/helpers/text_helper.rst old mode 100755 new mode 100644 diff --git a/writable/.htaccess b/writable/.htaccess old mode 100755 new mode 100644 diff --git a/writable/cache/index.html b/writable/cache/index.html old mode 100755 new mode 100644 diff --git a/writable/debugbar/index.html b/writable/debugbar/index.html old mode 100755 new mode 100644 diff --git a/writable/index.html b/writable/index.html old mode 100755 new mode 100644 diff --git a/writable/logs/index.html b/writable/logs/index.html old mode 100755 new mode 100644 diff --git a/writable/session/index.html b/writable/session/index.html old mode 100755 new mode 100644 diff --git a/writable/uploads/index.html b/writable/uploads/index.html old mode 100755 new mode 100644 From 3e90a29e6fd97942874e6c3901abb2bce8bfdab2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 29 May 2024 17:39:03 +0700 Subject: [PATCH 14/19] chore: remove JsonThrowOnErrorRector and FinalizePublicClassConstantRector from skip() config as no longer part of sets --- rector.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/rector.php b/rector.php index b9d51f872fdc..596eb7a3da65 100644 --- a/rector.php +++ b/rector.php @@ -44,11 +44,9 @@ use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php70\Rector\FuncCall\RandomFunctionRector; -use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\Php80\Rector\FunctionLike\MixedTypeRector; -use Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector; use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector; @@ -107,7 +105,6 @@ __DIR__ . '/tests/_support/Commands/Foobar.php', __DIR__ . '/tests/_support/View', - JsonThrowOnErrorRector::class, YieldDataProviderRector::class, RemoveUnusedPromotedPropertyRector::class => [ @@ -174,16 +171,6 @@ ], MixedTypeRector::class, - // PHP 8.1 features but cause breaking changes - FinalizePublicClassConstantRector::class => [ - __DIR__ . '/system/Cache/Handlers/BaseHandler.php', - __DIR__ . '/system/Cache/Handlers/FileHandler.php', - __DIR__ . '/system/CodeIgniter.php', - __DIR__ . '/system/Events/Events.php', - __DIR__ . '/system/Log/Handlers/ChromeLoggerHandler.php', - __DIR__ . '/system/Log/Handlers/ErrorlogHandler.php', - __DIR__ . '/system/Security/Security.php', - ], ReturnNeverTypeRector::class => [ __DIR__ . '/system/Cache/Handlers/BaseHandler.php', __DIR__ . '/system/Cache/Handlers/MemcachedHandler.php', From e0d2cff888575d70a2a5d4e4633df250f6be6a86 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 30 May 2024 11:30:49 +0900 Subject: [PATCH 15/19] chore: add file permission check workflow --- .github/workflows/test-file-permissions.yml | 24 ++++++ utils/check_permission_x.php | 95 +++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 .github/workflows/test-file-permissions.yml create mode 100644 utils/check_permission_x.php diff --git a/.github/workflows/test-file-permissions.yml b/.github/workflows/test-file-permissions.yml new file mode 100644 index 000000000000..e6ad5949d8b4 --- /dev/null +++ b/.github/workflows/test-file-permissions.yml @@ -0,0 +1,24 @@ +name: Check File Permissions + +on: + pull_request: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + permission-check: + name: Check File Permission + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Detect unnecessary execution permissions + run: php utils/check_permission_x.php diff --git a/utils/check_permission_x.php b/utils/check_permission_x.php new file mode 100644 index 000000000000..219ec5cc64e4 --- /dev/null +++ b/utils/check_permission_x.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Utils; + +require __DIR__ . '/../system/Test/bootstrap.php'; + +use CodeIgniter\CLI\CLI; +use RecursiveDirectoryIterator; +use RecursiveIteratorIterator; +use RuntimeException; + +function findExecutableFiles($dir) +{ + $execFileList = [ + 'admin/release-userguide', + 'admin/release-deploy', + 'admin/apibot', + 'admin/alldocs', + 'admin/release', + 'admin/docbot', + 'admin/release-notes.bb', + 'admin/release-revert', + 'admin/starter/builds', + 'user_guide_src/add-edit-this-page', + ]; + + $executableFiles = []; + + // Check if the directory exists + if (! is_dir($dir)) { + throw new RuntimeException('No such directory: ' . $dir); + } + + // Create a Recursive Directory Iterator + $iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($dir) + ); + + // Iterate over each item in the directory + foreach ($iterator as $fileinfo) { + // Check if the item is a file and is executable + if ($fileinfo->isFile() && is_executable($fileinfo->getPathname())) { + $filePath = $fileinfo->getPathname(); + + // Check allow list + if (in_array($filePath, $execFileList, true)) { + continue; + } + + if (str_ends_with($filePath, '.sh')) { + continue; + } + + $executableFiles[] = $filePath; + } + } + + return $executableFiles; +} + +// Main +chdir(__DIR__ . '/../'); + +$dirs = ['admin', 'app', 'system', 'tests', 'user_guide_src', 'utils', 'writable']; + +$executableFiles = []; + +foreach ($dirs as $dir) { + $executableFiles = array_merge($executableFiles, findExecutableFiles($dir)); +} + +if ($executableFiles !== []) { + CLI::write('Files with unnecessary execution permissions were detected:', 'light_gray', 'red'); + + foreach ($executableFiles as $file) { + CLI::write('- ' . $file); + } + + exit(1); +} + +CLI::write('No files with unnecessary execution permissions were detected.', 'black', 'green'); + +exit(0); From ab796767a89167d15e04ec06cf3796aeda42e392 Mon Sep 17 00:00:00 2001 From: obozdag Date: Thu, 30 May 2024 08:19:11 +0200 Subject: [PATCH 16/19] docs: Prevent text-wrap for span.pre in user guide citheme.css Add span.pre to span.std to prevent text-wrap in user guide citheme.css --- user_guide_src/source/_static/css/citheme.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/_static/css/citheme.css b/user_guide_src/source/_static/css/citheme.css index b3264e096336..fae4909dd62c 100644 --- a/user_guide_src/source/_static/css/citheme.css +++ b/user_guide_src/source/_static/css/citheme.css @@ -245,7 +245,8 @@ html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not( background-color: #fffff0; } -span.std { +span.std, +span.pre { text-wrap: nowrap; } From 4a65e2a818859c2de275004ad9d1b5ffbe5858bd Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 30 May 2024 21:42:02 +0900 Subject: [PATCH 17/19] docs: add note for View Cells typed properties --- user_guide_src/source/outgoing/view_cells.rst | 4 ++++ user_guide_src/source/outgoing/view_cells/023.php | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 user_guide_src/source/outgoing/view_cells/023.php diff --git a/user_guide_src/source/outgoing/view_cells.rst b/user_guide_src/source/outgoing/view_cells.rst index f940bc99ea17..e01bdcd53343 100644 --- a/user_guide_src/source/outgoing/view_cells.rst +++ b/user_guide_src/source/outgoing/view_cells.rst @@ -101,6 +101,10 @@ Implementing the AlertMessage from above as a Controlled Cell would look like th .. literalinclude:: view_cells/010.php +.. note:: If you use typed properties, you must set the initial values: + + .. literalinclude:: view_cells/023.php + .. _generating-cell-via-command: Generating Cell via Command diff --git a/user_guide_src/source/outgoing/view_cells/023.php b/user_guide_src/source/outgoing/view_cells/023.php new file mode 100644 index 000000000000..c892fcd683a7 --- /dev/null +++ b/user_guide_src/source/outgoing/view_cells/023.php @@ -0,0 +1,13 @@ + Date: Thu, 30 May 2024 22:48:09 +0700 Subject: [PATCH 18/19] chore: remove unused path parameter on PhpStreamWrapper::stream_open() --- system/Test/PhpStreamWrapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Test/PhpStreamWrapper.php b/system/Test/PhpStreamWrapper.php index 980d5424ab62..a6be8dd1329c 100644 --- a/system/Test/PhpStreamWrapper.php +++ b/system/Test/PhpStreamWrapper.php @@ -46,7 +46,7 @@ public static function restore() stream_wrapper_restore('php'); } - public function stream_open(string $path): bool + public function stream_open(): bool { return true; } From 2ba2c45139c643bce4072e0d3f92bb5e445f42fc Mon Sep 17 00:00:00 2001 From: obozdag Date: Thu, 30 May 2024 22:34:39 +0200 Subject: [PATCH 19/19] docs: Small typo in testing/overview.rst Small typo in testing/overview.rst --- user_guide_src/source/testing/overview.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/testing/overview.rst b/user_guide_src/source/testing/overview.rst index 4052269c4ee4..8a94d6bc382c 100644 --- a/user_guide_src/source/testing/overview.rst +++ b/user_guide_src/source/testing/overview.rst @@ -76,14 +76,14 @@ There are no rules for how test files must be placed. However, we recommend that you establish placement rules in advance so that you can quickly understand where the test files are located. -In this document, we will place the test files corresponding to the classes in -the **app** directory in the **tests/app** directory. To test a new library, +In this document, the test files corresponding to the classes in the **app** directory +will be placed in the **tests/app** directory. To test a new library, **app/Libraries/Foo.php**, you would create a new file at **tests/app/Libraries/FooTest.php**: .. literalinclude:: overview/001.php -To test one of your models, **app/Models/UserMode.php**, you might end up with +To test one of your models, **app/Models/UserModel.php**, you might end up with something like this in **tests/app/Models/UserModelTest.php**: .. literalinclude:: overview/002.php @@ -121,7 +121,7 @@ parent as well so extended test cases do not interfere with staging: Traits ------ -A common way to enhance your tests is by using traits to consolidate staging across different +A common way to enhance your tests is using traits to consolidate staging across different test cases. ``CIUnitTestCase`` will detect any class traits and look for staging methods to run named for the trait itself (i.e. `setUp{NameOfTrait}()` and `tearDown{NameOfTrait}()`).