Skip to content

Commit

Permalink
Release v4.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jan 14, 2023
1 parent f83c211 commit b1e5c64
Show file tree
Hide file tree
Showing 19 changed files with 120 additions and 28 deletions.
12 changes: 6 additions & 6 deletions app/Config/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions system/Autoloader/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion system/Cache/Handlers/MemcachedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions system/Commands/Generators/MigrationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function run(array $params)
*/
protected function prepare(string $class): string
{
$data = [];
$data['session'] = false;

if ($this->getOption('session')) {
Expand Down
1 change: 1 addition & 0 deletions system/Commands/Generators/SessionMigrationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions system/Commands/Utilities/FilterCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -3274,7 +3275,7 @@ protected function isLiteral(string $str): bool
*
* @return $this
*/
public function resetQueryAsData()
public function resetQuery()
{
$this->resetSelect();
$this->resetWrite();
Expand Down Expand Up @@ -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();
}

/**
Expand Down
1 change: 1 addition & 0 deletions system/Database/SQLSRV/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ public function getPlatform(): string
*/
public function getVersion(): string
{
$info = [];
if (isset($this->dataCache['version'])) {
return $this->dataCache['version'];
}
Expand Down
2 changes: 2 additions & 0 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
Expand Down
1 change: 1 addition & 0 deletions system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions system/Debug/Toolbar/Collectors/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions system/Helpers/html_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 5 additions & 6 deletions system/Helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== '') {
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion system/Images/Handlers/ImageMagickHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 18 additions & 4 deletions system/Validation/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);

Expand All @@ -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);
}

Expand Down
64 changes: 58 additions & 6 deletions system/Validation/StrictRules/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit b1e5c64

Please sign in to comment.