From fb1256a5b009b6264fbc85be44e0d97654d3fcd9 Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Sun, 6 Nov 2022 16:13:43 +0200 Subject: [PATCH 1/4] Adding PHP 8.2 support --- .github/workflows/test-phpunit.yml | 20 +++++++++++++++++++- system/core/Loader.php | 1 + system/core/URI.php | 7 +++++++ system/database/DB_driver.php | 1 + system/libraries/Driver.php | 1 + system/libraries/Table.php | 4 ++-- tests/codeigniter/core/Loader_test.php | 2 +- tests/codeigniter/libraries/Upload_test.php | 7 ++++--- tests/mocks/ci_testcase.php | 1 + 9 files changed, 37 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml index e5ad97a4416..bd7ad8133b5 100644 --- a/.github/workflows/test-phpunit.yml +++ b/.github/workflows/test-phpunit.yml @@ -12,10 +12,28 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1', '8.0', '7.4', '7.3', '7.2', '7.1', '7.0', '5.6', '5.5', '5.4'] + php: [ '8.2', '8.1', '8.0', '7.4', '7.3', '7.2', '7.1', '7.0', '5.6', '5.5', '5.4'] DB: [ 'pdo/mysql', 'pdo/pgsql', 'pdo/sqlite', 'mysqli', 'pgsql', 'sqlite' ] compiler: [ default ] include: + - php: '8.2' + DB: 'pdo/mysql' + compiler: jit + - php: '8.2' + DB: 'pdo/pgsql' + compiler: jit + - php: '8.2' + DB: 'pdo/sqlite' + compiler: jit + - php: '8.2' + DB: 'mysqli' + compiler: jit + - php: '8.2' + DB: 'pgsql' + compiler: jit + - php: '8.2' + DB: 'sqlite' + compiler: jit - php: '8.1' DB: 'pdo/mysql' compiler: jit diff --git a/system/core/Loader.php b/system/core/Loader.php index 648b7cfc7c2..32f3873262d 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -49,6 +49,7 @@ * @author EllisLab Dev Team * @link https://codeigniter.com/userguide3/libraries/loader.html */ +#[AllowDynamicProperties] class CI_Loader { // All these are set automatically. Don't mess with them. diff --git a/system/core/URI.php b/system/core/URI.php index 1e948588354..95b9c926c96 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -51,6 +51,13 @@ */ class CI_URI { + /** + * CI_Config instance + * + * @var CI_Config + */ + public $config; + /** * List of cached URI segments * diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index de03a418567..6cbd7026e91 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -51,6 +51,7 @@ * @author EllisLab Dev Team * @link https://codeigniter.com/userguide3/database/ */ +#[AllowDynamicProperties] abstract class CI_DB_driver { /** diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 84f0b6c3e76..23f4d23f3d0 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -50,6 +50,7 @@ * @author EllisLab Dev Team * @link */ +#[AllowDynamicProperties] class CI_Driver_Library { /** diff --git a/system/libraries/Table.php b/system/libraries/Table.php index a033ced212c..60b9fddcf84 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -490,12 +490,12 @@ protected function _compile_template() return; } - $this->temp = $this->_default_template(); + $temp = $this->_default_template(); foreach (array('table_open', 'thead_open', 'thead_close', 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'tbody_open', 'tbody_close', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close') as $val) { if ( ! isset($this->template[$val])) { - $this->template[$val] = $this->temp[$val]; + $this->template[$val] = $temp[$val]; } } } diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index df9c9f44b68..b14b7178019 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -125,7 +125,7 @@ public function test_library_config() // Create library in VFS $lib = 'unit_test_config_lib'; $class = 'CI_'.ucfirst($lib); - $content = 'config = $params; } }'; + $content = "config = $params; } }'; $this->ci_vfs_create(ucfirst($lib), $content, $this->ci_base_root, 'libraries'); // Create config file diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php index 74a7d2c22df..b660d0ec85f 100644 --- a/tests/codeigniter/libraries/Upload_test.php +++ b/tests/codeigniter/libraries/Upload_test.php @@ -59,9 +59,6 @@ function test_data() $data = array( 'file_name' => 'hello.txt', 'file_type' => 'text/plain', - 'file_path' => '/tmp/', - 'full_path' => '/tmp/hello.txt', - 'raw_name' => 'hello', 'orig_name' => 'hello.txt', 'client_name' => '', 'file_ext' => '.txt', @@ -80,6 +77,10 @@ function test_data() $this->upload->{$k} = $v; } + $data['file_path'] = '/tmp/'; + $data['full_path'] = '/tmp/hello.txt'; + $data['raw_name'] = 'hello'; + $this->assertEquals('hello.txt', $this->upload->data('file_name')); $this->assertEquals($data, $this->upload->data()); } diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php index de46f6df656..5d863edf936 100644 --- a/tests/mocks/ci_testcase.php +++ b/tests/mocks/ci_testcase.php @@ -1,5 +1,6 @@ Date: Fri, 27 Jan 2023 03:03:47 +0200 Subject: [PATCH 2/4] Adds $uri prop in Router, and AllowDynamicProps attribute for CI_Controller --- system/core/Controller.php | 1 + system/core/Router.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/system/core/Controller.php b/system/core/Controller.php index aeccd60ee4c..3713ae06308 100644 --- a/system/core/Controller.php +++ b/system/core/Controller.php @@ -50,6 +50,7 @@ * @author EllisLab Dev Team * @link https://codeigniter.com/userguide3/general/controllers.html */ +#[AllowDynamicProperties] class CI_Controller { /** diff --git a/system/core/Router.php b/system/core/Router.php index e15ceff713d..299f5588792 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -58,6 +58,13 @@ class CI_Router { */ public $config; + /** + * CI_URI class object + * + * @var object + */ + public $uri; + /** * List of routes * From d3c610ba85f3d41121b210a6954c72c7b544ea34 Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Wed, 1 Mar 2023 03:56:43 +0200 Subject: [PATCH 3/4] Adding missing `dest_image` property in CI_Image_lib --- system/libraries/Image_lib.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 4e5fc7be6fc..9067eff692f 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -85,6 +85,14 @@ class CI_Image_lib { */ public $new_image = ''; + + /** + * Path to destination image + * + * @var string + */ + public $dest_image = ''; + /** * Image width * From 2fc2d480d0d3fc778a46ded0e093fef7a0d84257 Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Fri, 3 Nov 2023 11:59:40 +0200 Subject: [PATCH 4/4] Fixes the usage of `_create_table_if` in Postgres forge class --- system/database/drivers/postgre/postgre_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php index 2857fd51727..291a705baf4 100644 --- a/system/database/drivers/postgre/postgre_forge.php +++ b/system/database/drivers/postgre/postgre_forge.php @@ -87,7 +87,7 @@ public function __construct(&$db) if (version_compare($this->db->version(), '9.0', '>')) { - $this->create_table_if = 'CREATE TABLE IF NOT EXISTS'; + $this->_create_table_if = 'CREATE TABLE IF NOT EXISTS'; } }