diff --git a/app/Config/Email.php b/app/Config/Email.php index 729e8957..01350186 100644 --- a/app/Config/Email.php +++ b/app/Config/Email.php @@ -6,9 +6,9 @@ class Email extends BaseConfig { - public string $fromEmail; - public string $fromName; - public string $recipients; + public string $fromEmail = ''; + public string $fromName = ''; + public string $recipients = ''; /** * The "user agent" @@ -28,17 +28,17 @@ class Email extends BaseConfig /** * SMTP Server Address */ - public string $SMTPHost; + public string $SMTPHost = ''; /** * SMTP Username */ - public string $SMTPUser; + public string $SMTPUser = ''; /** * SMTP Password */ - public string $SMTPPass; + public string $SMTPPass = ''; /** * SMTP Port diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index 0041937c..0f1d91eb 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -373,6 +373,14 @@ private function loadComposerNamespaces(ClassLoader $composer, array $composerPa unset($namespacePaths['CodeIgniter\\']); } + if (! method_exists(InstalledVersions::class, 'getAllRawData')) { + throw new RuntimeException( + 'Your Composer version is too old.' + . ' Please update Composer (run `composer self-update`) to v2.0.14 or later' + . ' and remove your vendor/ directory, and run `composer update`.' + ); + } + // This method requires Composer 2.0.14 or later. $packageList = InstalledVersions::getAllRawData()[0]['versions']; // Check config for $composerPackages. diff --git a/system/Cache/Handlers/MemcachedHandler.php b/system/Cache/Handlers/MemcachedHandler.php index f7d5ec8b..5053b1a6 100644 --- a/system/Cache/Handlers/MemcachedHandler.php +++ b/system/Cache/Handlers/MemcachedHandler.php @@ -124,7 +124,8 @@ public function initialize() */ public function get(string $key) { - $key = static::validateKey($key, $this->prefix); + $data = []; + $key = static::validateKey($key, $this->prefix); if ($this->memcached instanceof Memcached) { $data = $this->memcached->get($key); diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 43f4caad..5cb98c43 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -47,7 +47,7 @@ class CodeIgniter /** * The current version of CodeIgniter Framework */ - public const CI_VERSION = '4.3.0'; + public const CI_VERSION = '4.3.1'; /** * App startup time. diff --git a/system/Commands/Generators/MigrationGenerator.php b/system/Commands/Generators/MigrationGenerator.php index 5cc3b6df..817c1688 100644 --- a/system/Commands/Generators/MigrationGenerator.php +++ b/system/Commands/Generators/MigrationGenerator.php @@ -97,6 +97,7 @@ public function run(array $params) */ protected function prepare(string $class): string { + $data = []; $data['session'] = false; if ($this->getOption('session')) { diff --git a/system/Commands/Generators/SessionMigrationGenerator.php b/system/Commands/Generators/SessionMigrationGenerator.php index a1e02a13..fbfb2d3d 100644 --- a/system/Commands/Generators/SessionMigrationGenerator.php +++ b/system/Commands/Generators/SessionMigrationGenerator.php @@ -89,6 +89,7 @@ public function run(array $params) */ protected function prepare(string $class): string { + $data = []; $data['session'] = true; $data['table'] = $this->getOption('t'); $data['DBGroup'] = $this->getOption('g'); diff --git a/system/Commands/Utilities/FilterCheck.php b/system/Commands/Utilities/FilterCheck.php index 15f66e97..d2eb2fb7 100644 --- a/system/Commands/Utilities/FilterCheck.php +++ b/system/Commands/Utilities/FilterCheck.php @@ -72,6 +72,7 @@ class FilterCheck extends BaseCommand */ public function run(array $params) { + $tbody = []; if (! isset($params[0], $params[1])) { CLI::error('You must specify a HTTP verb and a route.'); CLI::write(' Usage: ' . $this->usage); diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 3142aa18..9e2c634c 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -1423,6 +1423,7 @@ public function orHaving($key, $value = null, ?bool $escape = null) */ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = null) { + $qbOrderBy = []; if (empty($orderBy)) { return $this; } @@ -3274,7 +3275,7 @@ protected function isLiteral(string $str): bool * * @return $this */ - public function resetQueryAsData() + public function resetQuery() { $this->resetSelect(); $this->resetWrite(); @@ -3456,7 +3457,7 @@ protected function setBind(string $key, $value = null, bool $escape = true): str */ protected function cleanClone() { - return (clone $this)->from([], true)->resetQueryAsData(); + return (clone $this)->from([], true)->resetQuery(); } /** diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php index b7443503..5d9b208d 100755 --- a/system/Database/SQLSRV/Connection.php +++ b/system/Database/SQLSRV/Connection.php @@ -529,6 +529,7 @@ public function getPlatform(): string */ public function getVersion(): string { + $info = []; if (isset($this->dataCache['version'])) { return $this->dataCache['version']; } diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index 2670732d..bcce589d 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -80,6 +80,8 @@ public function __construct(ExceptionsConfig $config, $request, ResponseInterfac $this->response = $response; // workaround for upgraded users + // This causes "Deprecated: Creation of dynamic property" in PHP 8.2. + // @TODO remove this after dropping PHP 8.1 support. if (! isset($this->config->sensitiveDataInTrace)) { $this->config->sensitiveDataInTrace = []; } diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 10dad0f4..17e67aa8 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -76,6 +76,7 @@ public function __construct(ToolbarConfig $config) */ public function run(float $startTime, float $totalTime, RequestInterface $request, ResponseInterface $response): string { + $data = []; // Data items used within the view. $data['url'] = current_url(); $data['method'] = strtoupper($request->getMethod()); diff --git a/system/Debug/Toolbar/Collectors/Database.php b/system/Debug/Toolbar/Collectors/Database.php index 2991840c..c7ed6703 100644 --- a/system/Debug/Toolbar/Collectors/Database.php +++ b/system/Debug/Toolbar/Collectors/Database.php @@ -140,6 +140,7 @@ protected function formatTimelineData(): array */ public function display(): array { + $data = []; $data['queries'] = array_map(static function (array $query) { $isDuplicate = $query['duplicate'] === true; diff --git a/system/Email/Email.php b/system/Email/Email.php index d113398d..488a5ee7 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -1539,7 +1539,11 @@ public function send($autoClear = true) $this->setReplyTo($this->headers['From']); } - if (empty($this->recipients) && ! isset($this->headers['To']) && empty($this->BCCArray) && ! isset($this->headers['Bcc']) && ! isset($this->headers['Cc'])) { + if ( + empty($this->recipients) && ! isset($this->headers['To']) + && empty($this->BCCArray) && ! isset($this->headers['Bcc']) + && ! isset($this->headers['Cc']) + ) { $this->setErrorMessage(lang('Email.noRecipients')); return false; diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php index 979aae1b..c7a36e27 100755 --- a/system/Helpers/html_helper.php +++ b/system/Helpers/html_helper.php @@ -236,6 +236,7 @@ function link_tag( bool $indexPage = false, string $hreflang = '' ): string { + $attributes = []; // extract fields if needed if (is_array($href)) { $rel = $href['rel'] ?? $rel; diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 1f2db240..682830ba 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -56,12 +56,10 @@ function _get_uri(string $relativePath = '', ?App $config = null): URI // Build the full URL based on $config and $relativePath $request = Services::request(); - if ($request instanceof CLIRequest) { - /** @var App $config */ - $url = rtrim($config->baseURL, '/ ') . '/'; - } else { - $url = $request->getUri()->getBaseURL(); - } + /** @var App $config */ + $url = $request instanceof CLIRequest + ? rtrim($config->baseURL, '/ ') . '/' + : $request->getUri()->getBaseURL(); // Check for an index page if ($config->indexPage !== '') { @@ -329,6 +327,7 @@ function mailto(string $email, string $title = '', $attributes = ''): string */ function safe_mailto(string $email, string $title = '', $attributes = ''): string { + $count = 0; if (trim($title) === '') { $title = $email; } diff --git a/system/Images/Handlers/ImageMagickHandler.php b/system/Images/Handlers/ImageMagickHandler.php index b96fdc06..41274c6a 100644 --- a/system/Images/Handlers/ImageMagickHandler.php +++ b/system/Images/Handlers/ImageMagickHandler.php @@ -322,7 +322,10 @@ protected function supportedFormatCheck() */ protected function _text(string $text, array $options = []) { - $cmd = ''; + $xAxis = 0; + $yAxis = 0; + $gravity = ''; + $cmd = ''; // Reverse the vertical offset // When the image is positioned at the bottom diff --git a/system/Model.php b/system/Model.php index 0278be4e..de646c6f 100644 --- a/system/Model.php +++ b/system/Model.php @@ -427,6 +427,7 @@ protected function doUpdateBatch(?array $set = null, ?string $index = null, int */ protected function doDelete($id = null, bool $purge = false) { + $set = []; $builder = $this->builder(); if ($id) { diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index 40a5955b..93b86ea6 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -86,7 +86,11 @@ public function greater_than_equal_to(?string $str, string $min): bool public function is_not_unique(?string $str, string $field, array $data): bool { // Grab any data for exclusion of a single row. - [$field, $whereField, $whereValue] = array_pad(explode(',', $field), 3, null); + [$field, $whereField, $whereValue] = array_pad( + explode(',', $field), + 3, + null + ); // Break the table and field apart sscanf($field, '%[^.].%[^.]', $table, $field); @@ -97,7 +101,10 @@ public function is_not_unique(?string $str, string $field, array $data): bool ->where($field, $str) ->limit(1); - if (! empty($whereField) && ! empty($whereValue) && ! preg_match('/^\{(\w+)\}$/', $whereValue)) { + if ( + ! empty($whereField) && ! empty($whereValue) + && ! preg_match('/^\{(\w+)\}$/', $whereValue) + ) { $row = $row->where($whereField, $whereValue); } @@ -125,7 +132,11 @@ public function in_list(?string $value, string $list): bool */ public function is_unique(?string $str, string $field, array $data): bool { - [$field, $ignoreField, $ignoreValue] = array_pad(explode(',', $field), 3, null); + [$field, $ignoreField, $ignoreValue] = array_pad( + explode(',', $field), + 3, + null + ); sscanf($field, '%[^.].%[^.]', $table, $field); @@ -135,7 +146,10 @@ public function is_unique(?string $str, string $field, array $data): bool ->where($field, $str) ->limit(1); - if (! empty($ignoreField) && ! empty($ignoreValue) && ! preg_match('/^\{(\w+)\}$/', $ignoreValue)) { + if ( + ! empty($ignoreField) && ! empty($ignoreValue) + && ! preg_match('/^\{(\w+)\}$/', $ignoreValue) + ) { $row = $row->where("{$ignoreField} !=", $ignoreValue); } diff --git a/system/Validation/StrictRules/Rules.php b/system/Validation/StrictRules/Rules.php index 47dbee9b..f95bbe7d 100644 --- a/system/Validation/StrictRules/Rules.php +++ b/system/Validation/StrictRules/Rules.php @@ -75,7 +75,7 @@ public function exact_length($str, string $val): bool */ public function greater_than($str, string $min): bool { - if (is_int($str)) { + if (is_int($str) || is_float($str)) { $str = (string) $str; } @@ -93,7 +93,7 @@ public function greater_than($str, string $min): bool */ public function greater_than_equal_to($str, string $min): bool { - if (is_int($str)) { + if (is_int($str) || is_float($str)) { $str = (string) $str; } @@ -117,7 +117,34 @@ public function greater_than_equal_to($str, string $min): bool */ public function is_not_unique($str, string $field, array $data): bool { - return $this->nonStrictRules->is_not_unique($str, $field, $data); + if (is_object($str) || is_array($str)) { + return false; + } + + // Grab any data for exclusion of a single row. + [$field, $whereField, $whereValue] = array_pad( + explode(',', $field), + 3, + null + ); + + // Break the table and field apart + sscanf($field, '%[^.].%[^.]', $table, $field); + + $row = Database::connect($data['DBGroup'] ?? null) + ->table($table) + ->select('1') + ->where($field, $str) + ->limit(1); + + if ( + ! empty($whereField) && ! empty($whereValue) + && ! preg_match('/^\{(\w+)\}$/', $whereValue) + ) { + $row = $row->where($whereField, $whereValue); + } + + return $row->get()->getRow() !== null; } /** @@ -151,7 +178,32 @@ public function in_list($value, string $list): bool */ public function is_unique($str, string $field, array $data): bool { - return $this->nonStrictRules->is_unique($str, $field, $data); + if (is_object($str) || is_array($str)) { + return false; + } + + [$field, $ignoreField, $ignoreValue] = array_pad( + explode(',', $field), + 3, + null + ); + + sscanf($field, '%[^.].%[^.]', $table, $field); + + $row = Database::connect($data['DBGroup'] ?? null) + ->table($table) + ->select('1') + ->where($field, $str) + ->limit(1); + + if ( + ! empty($ignoreField) && ! empty($ignoreValue) + && ! preg_match('/^\{(\w+)\}$/', $ignoreValue) + ) { + $row = $row->where("{$ignoreField} !=", $ignoreValue); + } + + return $row->get()->getRow() === null; } /** @@ -161,7 +213,7 @@ public function is_unique($str, string $field, array $data): bool */ public function less_than($str, string $max): bool { - if (is_int($str)) { + if (is_int($str) || is_float($str)) { $str = (string) $str; } @@ -179,7 +231,7 @@ public function less_than($str, string $max): bool */ public function less_than_equal_to($str, string $max): bool { - if (is_int($str)) { + if (is_int($str) || is_float($str)) { $str = (string) $str; }