From 37f7c5f4f1deb7b4059748a2b7efbefe9a6c4ccd Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 20 Feb 2024 10:16:09 +0900 Subject: [PATCH 01/17] docs: add "What are Configuration Classes?" --- .../source/general/configuration.rst | 18 ++++++++++++++++++ .../source/libraries/official_packages.rst | 2 ++ 2 files changed, 20 insertions(+) diff --git a/user_guide_src/source/general/configuration.rst b/user_guide_src/source/general/configuration.rst index f7d6c2d78d34..3209510dc7ef 100644 --- a/user_guide_src/source/general/configuration.rst +++ b/user_guide_src/source/general/configuration.rst @@ -15,6 +15,24 @@ the application configuration files in the **app/Config** folder. :local: :depth: 2 + +What are Configuration Classes? +******************************* + +Configuration classes are utilized to define system default configuration values. +System configuration values are typically *static*. Configuration classes are +intended to retain the settings that configure how the application operates, +rather than responding to each user's individual settings. + +It is not recommended to alter values set during the instantiation of a +configuration class later during execution. In other words, it is recommended to +treat configuration classes as immutable or readonly classes. This is especially +important if you utilize :ref:`factories-config-caching`. + +Configuration values can be retrieved from environment variables, hard-coded +within the class files, or stored in a database using the :ref:`Settings ` +library. + Working with Configuration Files ******************************** diff --git a/user_guide_src/source/libraries/official_packages.rst b/user_guide_src/source/libraries/official_packages.rst index 6da2f41fd2b7..ccadc81599bc 100644 --- a/user_guide_src/source/libraries/official_packages.rst +++ b/user_guide_src/source/libraries/official_packages.rst @@ -29,6 +29,8 @@ Among the many features, it includes: * Per-user permission overrides, * and more... +.. _settings: + ******** Settings ******** From 5c8bc0339556782cbbf2eb5d339a6fa9f6ebafe7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 20 Feb 2024 21:27:11 +0900 Subject: [PATCH 02/17] docs: remove misleading description --- user_guide_src/source/general/configuration.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/general/configuration.rst b/user_guide_src/source/general/configuration.rst index 3209510dc7ef..13b412ff3e1e 100644 --- a/user_guide_src/source/general/configuration.rst +++ b/user_guide_src/source/general/configuration.rst @@ -29,9 +29,8 @@ configuration class later during execution. In other words, it is recommended to treat configuration classes as immutable or readonly classes. This is especially important if you utilize :ref:`factories-config-caching`. -Configuration values can be retrieved from environment variables, hard-coded -within the class files, or stored in a database using the :ref:`Settings ` -library. +Configuration values can be hard-coded in the class files or obtained from +environment variables at instantiation. Working with Configuration Files ******************************** From c85cd6d0c4946d380065b9f348dc1598bc66ffc6 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Sun, 31 Dec 2023 02:19:02 +0800 Subject: [PATCH 03/17] test: ensure cleanup of sqlite3 db files after test --- tests/system/Database/Live/SQLite3/GetFieldDataTest.php | 2 +- tests/system/Database/Live/SQLite3/GetIndexDataTest.php | 2 +- tests/system/Database/Migrations/MigrationRunnerTest.php | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/system/Database/Live/SQLite3/GetFieldDataTest.php b/tests/system/Database/Live/SQLite3/GetFieldDataTest.php index 319706a90e53..f2e6b7244511 100644 --- a/tests/system/Database/Live/SQLite3/GetFieldDataTest.php +++ b/tests/system/Database/Live/SQLite3/GetFieldDataTest.php @@ -32,7 +32,7 @@ protected function createForge(): void 'database' => 'database.db', 'DBDebug' => true, ]; - $this->db = db_connect($config); + $this->db = db_connect($config, false); $this->forge = Database::forge($config); } diff --git a/tests/system/Database/Live/SQLite3/GetIndexDataTest.php b/tests/system/Database/Live/SQLite3/GetIndexDataTest.php index cf05b7a7f07b..4fa2a4f31167 100644 --- a/tests/system/Database/Live/SQLite3/GetIndexDataTest.php +++ b/tests/system/Database/Live/SQLite3/GetIndexDataTest.php @@ -45,7 +45,7 @@ protected function setUp(): void 'database' => 'database.db', 'DBDebug' => true, ]; - $this->db = db_connect($config); + $this->db = db_connect($config, false); $this->forge = Database::forge($config); } diff --git a/tests/system/Database/Migrations/MigrationRunnerTest.php b/tests/system/Database/Migrations/MigrationRunnerTest.php index aac42778b9f8..af9fa2a6104f 100644 --- a/tests/system/Database/Migrations/MigrationRunnerTest.php +++ b/tests/system/Database/Migrations/MigrationRunnerTest.php @@ -470,6 +470,10 @@ public function testMigrationUsesSameConnectionAsMigrationRunner(): void $this->assertCount(2, $tables); $this->assertSame('migrations', $tables[0]); $this->assertSame('foo', $tables[1]); + + if (is_file($config['database'])) { + unlink($config['database']); + } } protected function resetTables($db = null): void From 020770011dcc4b2b8e045f7340b68635e6fabb50 Mon Sep 17 00:00:00 2001 From: justbyitself Date: Tue, 12 Mar 2024 22:53:49 +0100 Subject: [PATCH 04/17] refactor: apply early return pattern More readable and a bit shorter --- .../Routes/ControllerMethodReader.php | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/system/Commands/Utilities/Routes/ControllerMethodReader.php b/system/Commands/Utilities/Routes/ControllerMethodReader.php index 31bcde12dfb8..4365cb27dfd1 100644 --- a/system/Commands/Utilities/Routes/ControllerMethodReader.php +++ b/system/Commands/Utilities/Routes/ControllerMethodReader.php @@ -159,19 +159,17 @@ private function getRouteWithoutController( string $classname, string $methodName ): array { - $output = []; - - if ($classShortname === $defaultController) { - $pattern = '#' . preg_quote(lcfirst($defaultController), '#') . '\z#'; - $routeWithoutController = rtrim(preg_replace($pattern, '', $uriByClass), '/'); - $routeWithoutController = $routeWithoutController ?: '/'; - - $output[] = [ - 'route' => $routeWithoutController, - 'handler' => '\\' . $classname . '::' . $methodName, - ]; + if ($classShortname !== $defaultController) { + return []; } - return $output; + $pattern = '#' . preg_quote(lcfirst($defaultController), '#') . '\z#'; + $routeWithoutController = rtrim(preg_replace($pattern, '', $uriByClass), '/'); + $routeWithoutController = $routeWithoutController ?: '/'; + + return [ + 'route' => $routeWithoutController, + 'handler' => '\\' . $classname . '::' . $methodName, + ]; } } From 647d20b96967f5bb6bde71097d0236bda272d5e9 Mon Sep 17 00:00:00 2001 From: justbyitself Date: Tue, 12 Mar 2024 23:17:22 +0100 Subject: [PATCH 05/17] refactor: apply early return pattern (fix) Fix. --- system/Commands/Utilities/Routes/ControllerMethodReader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Commands/Utilities/Routes/ControllerMethodReader.php b/system/Commands/Utilities/Routes/ControllerMethodReader.php index 4365cb27dfd1..4a37b9560324 100644 --- a/system/Commands/Utilities/Routes/ControllerMethodReader.php +++ b/system/Commands/Utilities/Routes/ControllerMethodReader.php @@ -167,9 +167,9 @@ private function getRouteWithoutController( $routeWithoutController = rtrim(preg_replace($pattern, '', $uriByClass), '/'); $routeWithoutController = $routeWithoutController ?: '/'; - return [ + return [[ 'route' => $routeWithoutController, 'handler' => '\\' . $classname . '::' . $methodName, - ]; + ]]; } } From 9c38271a3057c535c1ece114cc6c9dd501911056 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Mar 2024 08:53:22 +0900 Subject: [PATCH 06/17] refactor: move footer info to top It is useful when reporting errors. --- app/Views/errors/html/debug.css | 5 +---- app/Views/errors/html/error_exception.php | 19 ++++++------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/app/Views/errors/html/debug.css b/app/Views/errors/html/debug.css index 98f54dbc8a01..63c3c662cbaa 100644 --- a/app/Views/errors/html/debug.css +++ b/app/Views/errors/html/debug.css @@ -65,13 +65,10 @@ p.lead { display: inline; } -.footer { +.environment { background: var(--dark-bg-color); color: var(--light-text-color); -} -.footer .container { border-top: 1px solid #e7e7e7; - margin-top: 1rem; text-align: center; } diff --git a/app/Views/errors/html/error_exception.php b/app/Views/errors/html/error_exception.php index 406b48ec6772..047c2f4cd987 100644 --- a/app/Views/errors/html/error_exception.php +++ b/app/Views/errors/html/error_exception.php @@ -23,6 +23,12 @@
+
+ Displayed at — + PHP: — + CodeIgniter: -- + Environment: +

getCode() ? ' #' . $exception->getCode() : '') ?>

@@ -401,18 +407,5 @@

- - From 89f7ede4ec314a20b106fc7bcaab3ba59e621191 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Mar 2024 09:14:47 +0900 Subject: [PATCH 07/17] fix: remove invalid letter-spacing --- app/Views/errors/html/debug.css | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Views/errors/html/debug.css b/app/Views/errors/html/debug.css index 63c3c662cbaa..c233c6a63a3c 100644 --- a/app/Views/errors/html/debug.css +++ b/app/Views/errors/html/debug.css @@ -19,7 +19,6 @@ body { } h1 { font-weight: lighter; - letter-spacing: 0.8; font-size: 3rem; color: var(--dark-text-color); margin: 0; From 93fe3adafced03f237d295af6515951d2b0185a1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Mar 2024 09:16:22 +0900 Subject: [PATCH 08/17] refactor: remove redundant rem --- app/Views/errors/html/debug.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Views/errors/html/debug.css b/app/Views/errors/html/debug.css index c233c6a63a3c..b133b054584f 100644 --- a/app/Views/errors/html/debug.css +++ b/app/Views/errors/html/debug.css @@ -108,7 +108,7 @@ p.lead { } .tabs a:link, .tabs a:visited { - padding: 0rem 1rem; + padding: 0 1rem; line-height: 2.7; text-decoration: none; color: var(--dark-text-color); From 2f009ca5e2db50554d2033e4d9e90dc37fa97679 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Mar 2024 09:18:16 +0900 Subject: [PATCH 09/17] refactor: tweaks css --- app/Views/errors/html/debug.css | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/Views/errors/html/debug.css b/app/Views/errors/html/debug.css index b133b054584f..bbff6bf84e54 100644 --- a/app/Views/errors/html/debug.css +++ b/app/Views/errors/html/debug.css @@ -43,7 +43,7 @@ p.lead { color: var(--dark-text-color); } .header .container { - padding: 1rem 1.75rem 1.75rem 1.75rem; + padding: 1rem; } .header h1 { font-size: 2.5rem; @@ -148,9 +148,6 @@ p.lead { border-radius: 5px; color: #31708f; } -ul, ol { - line-height: 1.8; -} table { width: 100%; From 50409e80fcada8f8ef5157918f83ddc11ced80c9 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Mar 2024 10:54:51 +0900 Subject: [PATCH 10/17] refactor: remove border-top --- app/Views/errors/html/debug.css | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Views/errors/html/debug.css b/app/Views/errors/html/debug.css index bbff6bf84e54..500013df49f1 100644 --- a/app/Views/errors/html/debug.css +++ b/app/Views/errors/html/debug.css @@ -67,7 +67,6 @@ p.lead { .environment { background: var(--dark-bg-color); color: var(--light-text-color); - border-top: 1px solid #e7e7e7; text-align: center; } From 199e3855b72ba60e78450b59ed0b209dde2cc0b3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Mar 2024 11:00:50 +0900 Subject: [PATCH 11/17] docs: add upgrade_447 --- user_guide_src/source/installation/upgrade_447.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/user_guide_src/source/installation/upgrade_447.rst b/user_guide_src/source/installation/upgrade_447.rst index 07f85330b4ed..45eed909332e 100644 --- a/user_guide_src/source/installation/upgrade_447.rst +++ b/user_guide_src/source/installation/upgrade_447.rst @@ -16,6 +16,14 @@ Please refer to the upgrade instructions corresponding to your installation meth Mandatory File Changes ********************** +Error Files +=========== + +The error page has been updated. Please update the following files: + +- app/Views/errors/html/debug.css +- app/Views/errors/html/error_exception.php + **************** Breaking Changes **************** From d8945671f6b8cb44b210d16175dfde9a87c13eeb Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 15 Mar 2024 11:56:19 +0900 Subject: [PATCH 12/17] refactor: add padding to environment class --- app/Views/errors/html/debug.css | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Views/errors/html/debug.css b/app/Views/errors/html/debug.css index 500013df49f1..6a050c8bb462 100644 --- a/app/Views/errors/html/debug.css +++ b/app/Views/errors/html/debug.css @@ -68,6 +68,7 @@ p.lead { background: var(--dark-bg-color); color: var(--light-text-color); text-align: center; + padding: 0.2rem; } .source { From 5516b731804d41e504613571cd487be2ebe9b8b1 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean <97607754+ddevsr@users.noreply.github.com> Date: Fri, 15 Mar 2024 11:37:29 +0700 Subject: [PATCH 13/17] Update test-deptrac.yml --- .github/workflows/test-deptrac.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-deptrac.yml b/.github/workflows/test-deptrac.yml index 0f369a5c6786..fecb289b1b63 100644 --- a/.github/workflows/test-deptrac.yml +++ b/.github/workflows/test-deptrac.yml @@ -43,7 +43,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: '8.1' - tools: composer, phive + tools: composer extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 - name: Validate composer.json From 176a50ff365cb7db369b656ad68e5f934ef70675 Mon Sep 17 00:00:00 2001 From: Mattias Sandstrom <1013635+tangix@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:32:17 +0100 Subject: [PATCH 14/17] Update connection docs with information on how to connect to a MySQL server over a socket. --- .../source/database/configuration.rst | 10 +++++++++ .../source/database/configuration/011.php | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 user_guide_src/source/database/configuration/011.php diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 128e28d9eeef..3e58c0db4326 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -66,6 +66,16 @@ add the config variables as a query string: database character set), which are present in the rest of the configuration fields, CodeIgniter will append them. +Configuring a MySQL socket connection +------------------------------------- + +To connect to a MySQL server over a filesystem socket, the path to the socket should be specified in +the ``'hostname'`` setting. CodeIgniter's MySQLi driver will notice this and configure the +connection properly. + +.. literalinclude:: configuration/011.php + :lines: 11-18 + Failovers --------- diff --git a/user_guide_src/source/database/configuration/011.php b/user_guide_src/source/database/configuration/011.php new file mode 100644 index 000000000000..dbdc9d133433 --- /dev/null +++ b/user_guide_src/source/database/configuration/011.php @@ -0,0 +1,21 @@ + '/cloudsql/toolbox-tests:europe-north1:toolbox-db"', + // ... + 'DBDriver' => 'MySQLi', + // ... + ]; + + // ... +} From 5750dc84faeb6a7a6f9e559ee54ef11f5873e163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Sandstr=C3=B6m?= <1013635+tangix@users.noreply.github.com> Date: Sat, 16 Mar 2024 09:49:29 +0100 Subject: [PATCH 15/17] Update user_guide_src/source/database/configuration/011.php Co-authored-by: kenjis --- user_guide_src/source/database/configuration/011.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/database/configuration/011.php b/user_guide_src/source/database/configuration/011.php index dbdc9d133433..01a0e876a3c8 100644 --- a/user_guide_src/source/database/configuration/011.php +++ b/user_guide_src/source/database/configuration/011.php @@ -11,7 +11,7 @@ class Database extends Config // MySQLi over a socket public array $default = [ // ... - 'hostname' => '/cloudsql/toolbox-tests:europe-north1:toolbox-db"', + 'hostname' => '/cloudsql/toolbox-tests:europe-north1:toolbox-db', // ... 'DBDriver' => 'MySQLi', // ... From 343cc457a07ab11d2887dc32f98ce4923dbc14e3 Mon Sep 17 00:00:00 2001 From: Mattias Sandstrom <1013635+tangix@users.noreply.github.com> Date: Sat, 16 Mar 2024 09:52:52 +0100 Subject: [PATCH 16/17] Applied kenjis' changes --- user_guide_src/source/database/configuration.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 3e58c0db4326..9bfda4699c57 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -200,3 +200,19 @@ Explanation of Values: etc.) not all values will be needed. For example, when using ``SQLite3`` you will not need to supply a username or password, and the database name will be the path to your database file. + +MySQLi +====== + +hostname +-------- + +Configuring a Socket Connection +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To connect to a MySQL server over a filesystem socket, the path to the socket should be specified in +the ``'hostname'`` setting. CodeIgniter's MySQLi driver will notice this and configure the +connection properly. + +.. literalinclude:: configuration/011.php + :lines: 11-18 \ No newline at end of file From 2ae662807b0197d84203c844d3a5d9e03fae61ba Mon Sep 17 00:00:00 2001 From: Mattias Sandstrom <1013635+tangix@users.noreply.github.com> Date: Sat, 16 Mar 2024 09:53:57 +0100 Subject: [PATCH 17/17] Applied them again... --- user_guide_src/source/database/configuration.rst | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index 9bfda4699c57..2239c65799e2 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -66,16 +66,6 @@ add the config variables as a query string: database character set), which are present in the rest of the configuration fields, CodeIgniter will append them. -Configuring a MySQL socket connection -------------------------------------- - -To connect to a MySQL server over a filesystem socket, the path to the socket should be specified in -the ``'hostname'`` setting. CodeIgniter's MySQLi driver will notice this and configure the -connection properly. - -.. literalinclude:: configuration/011.php - :lines: 11-18 - Failovers ---------