Skip to content

Commit be27314

Browse files
committed
Release v4.5.3
1 parent 163f111 commit be27314

24 files changed

+136
-37
lines changed

system/CLI/Commands.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function discoverCommands()
125125
/** @var BaseCommand $class */
126126
$class = new $className($this->logger, $this);
127127

128-
if (isset($class->group)) {
128+
if (isset($class->group) && ! isset($this->commands[$class->name])) {
129129
$this->commands[$class->name] = [
130130
'class' => $className,
131131
'file' => $file,

system/CLI/GeneratorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ protected function setEnabledSuffixing(bool $enabledSuffixing)
516516
* Gets a single command-line option. Returns TRUE if the option exists,
517517
* but doesn't have a value, and is simply acting as a flag.
518518
*/
519-
protected function getOption(string $name): string|bool|null
519+
protected function getOption(string $name): bool|string|null
520520
{
521521
if (! array_key_exists($name, $this->params)) {
522522
return CLI::getOption($name);

system/Cache/Handlers/RedisHandler.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,17 @@ public function delete(string $key)
175175
*/
176176
public function deleteMatching(string $pattern)
177177
{
178+
/** @var list<string> $matchedKeys */
178179
$matchedKeys = [];
180+
$pattern = static::validateKey($pattern, $this->prefix);
179181
$iterator = null;
180182

181183
do {
182-
// Scan for some keys
184+
/** @var false|list<string>|Redis $keys */
183185
$keys = $this->redis->scan($iterator, $pattern);
184186

185-
// Redis may return empty results, so protect against that
186-
if ($keys !== false) {
187-
foreach ($keys as $key) {
188-
$matchedKeys[] = $key;
189-
}
187+
if (is_array($keys)) {
188+
$matchedKeys = [...$matchedKeys, ...$keys];
190189
}
191190
} while ($iterator > 0);
192191

system/CodeIgniter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class CodeIgniter
5656
/**
5757
* The current version of CodeIgniter Framework
5858
*/
59-
public const CI_VERSION = '4.5.2';
59+
public const CI_VERSION = '4.5.3';
6060

6161
/**
6262
* App startup time.
@@ -353,7 +353,7 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
353353
} else {
354354
try {
355355
$this->response = $this->handleRequest($routes, config(Cache::class), $returnResponse);
356-
} catch (ResponsableInterface|DeprecatedRedirectException $e) {
356+
} catch (DeprecatedRedirectException|ResponsableInterface $e) {
357357
$this->outputBufferingEnd();
358358
if ($e instanceof DeprecatedRedirectException) {
359359
$e = new RedirectException($e->getMessage(), $e->getCode(), $e);

system/Commands/Database/MigrateRollback.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use CodeIgniter\CLI\BaseCommand;
1717
use CodeIgniter\CLI\CLI;
18+
use CodeIgniter\Database\MigrationRunner;
1819
use Throwable;
1920

2021
/**
@@ -78,10 +79,23 @@ public function run(array $params)
7879
// @codeCoverageIgnoreEnd
7980
}
8081

82+
/** @var MigrationRunner $runner */
8183
$runner = service('migrations');
8284

8385
try {
8486
$batch = $params['b'] ?? CLI::getOption('b') ?? $runner->getLastBatch() - 1;
87+
88+
if (is_string($batch)) {
89+
if (! ctype_digit($batch)) {
90+
CLI::error('Invalid batch number: ' . $batch, 'light_gray', 'red');
91+
CLI::newLine();
92+
93+
return EXIT_ERROR;
94+
}
95+
96+
$batch = (int) $batch;
97+
}
98+
8599
CLI::write(lang('Migrations.rollingBack') . ' ' . $batch, 'yellow');
86100

87101
if (! $runner->regress($batch)) {

system/Commands/Database/ShowTableInfo.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ private function restoreDBPrefix(): void
188188
$this->db->setPrefix($this->DBPrefix);
189189
}
190190

191+
/**
192+
* Show Data of Table
193+
*
194+
* @return void
195+
*/
191196
private function showDataOfTable(string $tableName, int $limitRows, int $limitFieldValue)
192197
{
193198
CLI::write("Data of Table \"{$tableName}\":", 'black', 'yellow');
@@ -207,6 +212,13 @@ private function showDataOfTable(string $tableName, int $limitRows, int $limitFi
207212
CLI::table($this->tbody, $thead);
208213
}
209214

215+
/**
216+
* Show All Tables
217+
*
218+
* @param list<string> $tables
219+
*
220+
* @return void
221+
*/
210222
private function showAllTables(array $tables)
211223
{
212224
CLI::write('The following is a list of the names of all database tables:', 'black', 'yellow');
@@ -219,6 +231,13 @@ private function showAllTables(array $tables)
219231
CLI::newLine();
220232
}
221233

234+
/**
235+
* Make body for table
236+
*
237+
* @param list<string> $tables
238+
*
239+
* @return list<list<int|string>>
240+
*/
222241
private function makeTbodyForShowAllTables(array $tables): array
223242
{
224243
$this->removeDBPrefix();
@@ -244,6 +263,11 @@ private function makeTbodyForShowAllTables(array $tables): array
244263
return $this->tbody;
245264
}
246265

266+
/**
267+
* Make table rows
268+
*
269+
* @return list<list<int|string>>
270+
*/
247271
private function makeTableRows(
248272
string $tableName,
249273
int $limitRows,

system/Commands/ListCommands.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public function run(array $params)
8585

8686
/**
8787
* Lists the commands with accompanying info.
88+
*
89+
* @return void
8890
*/
8991
protected function listFull(array $commands)
9092
{
@@ -126,6 +128,8 @@ protected function listFull(array $commands)
126128

127129
/**
128130
* Lists the commands only.
131+
*
132+
* @return void
129133
*/
130134
protected function listSimple(array $commands)
131135
{

system/Commands/Server/Serve.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function run(array $params)
103103
$docroot = escapeshellarg(FCPATH);
104104

105105
// Mimic Apache's mod_rewrite functionality with user settings.
106-
$rewrite = escapeshellarg(__DIR__ . '/rewrite.php');
106+
$rewrite = escapeshellarg(SYSTEMPATH . 'rewrite.php');
107107

108108
// Call PHP's built-in webserver, making sure to set our
109109
// base path to the public folder, and to use the rewrite file

system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ final class AutoRouteCollector
2727
* @param string $namespace namespace to search
2828
* @param list<class-string> $protectedControllers List of controllers in Defined
2929
* Routes that should not be accessed via Auto-Routing.
30+
* @param list<string> $httpMethods
3031
* @param string $prefix URI prefix for Module Routing
3132
*/
3233
public function __construct(
@@ -91,6 +92,13 @@ public function get(): array
9192
return $tbody;
9293
}
9394

95+
/**
96+
* Adding Filters
97+
*
98+
* @param list<array<string, array|string>> $routes
99+
*
100+
* @return list<array<string, array|string>>
101+
*/
94102
private function addFilters($routes)
95103
{
96104
$filterCollector = new FilterCollector(true);

system/Commands/Utilities/Routes/FilterFinder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use CodeIgniter\Exceptions\PageNotFoundException;
1717
use CodeIgniter\Filters\Filters;
18+
use CodeIgniter\HTTP\Exceptions\BadRequestException;
1819
use CodeIgniter\HTTP\Exceptions\RedirectException;
1920
use CodeIgniter\Router\Router;
2021
use Config\Feature;
@@ -72,7 +73,7 @@ public function find(string $uri): array
7273
'before' => [],
7374
'after' => [],
7475
];
75-
} catch (PageNotFoundException) {
76+
} catch (BadRequestException|PageNotFoundException) {
7677
return [
7778
'before' => ['<unknown>'],
7879
'after' => ['<unknown>'],

0 commit comments

Comments
 (0)