Skip to content

Commit 33bd537

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.6
2 parents cde3c7d + 24a7673 commit 33bd537

File tree

5 files changed

+51
-1
lines changed

5 files changed

+51
-1
lines changed

.github/workflows/deploy-apidocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
- name: Build API in source repo
6262
working-directory: source
6363
run: |
64-
php tools/phpDocumentor run --ansi --verbose
64+
php tools/phpDocumentor --ansi --verbose
6565
cp -R ${GITHUB_WORKSPACE}/source/api/build/* ${GITHUB_WORKSPACE}/api/docs
6666
6767
- name: Deploy to API repo

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/Router/DefinedRouteCollector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public function collect(): Generator
3838
$routes = $this->routeCollection->getRoutes($method);
3939

4040
foreach ($routes as $route => $handler) {
41+
// The route key should be a string, but it is stored as an array key,
42+
// it might be an integer.
43+
$route = (string) $route;
44+
4145
if (is_string($handler) || $handler instanceof Closure) {
4246
if ($handler instanceof Closure) {
4347
$view = $this->routeCollection->getRoutesOptions($route, $method)['view'] ?? false;

tests/system/Commands/DatabaseCommandsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ public function testMigrate(): void
5353
$this->assertStringContainsString('Migrations complete.', $this->getBuffer());
5454
}
5555

56+
public function testMigrateRollbackValidBatchNumber(): void
57+
{
58+
command('migrate --all');
59+
$this->clearBuffer();
60+
61+
command('migrate:rollback -b 1');
62+
$this->assertStringContainsString('Done rolling back migrations.', $this->getBuffer());
63+
}
64+
65+
public function testMigrateRollbackInvalidBatchNumber(): void
66+
{
67+
command('migrate --all');
68+
$this->clearBuffer();
69+
70+
command('migrate:rollback -b x');
71+
$this->assertStringContainsString('Invalid batch number: x', $this->getBuffer());
72+
}
73+
5674
public function testMigrateRollback(): void
5775
{
5876
command('migrate --all -g tests');

tests/system/Router/DefinedRouteCollectorTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ public function testCollect(): void
5050
{
5151
$routes = $this->createRouteCollection();
5252
$routes->get('journals', 'Blogs');
53+
$routes->get('100', 'Home::index');
5354
$routes->get('product/(:num)', 'Catalog::productLookupByID/$1');
5455
$routes->get('feed', static fn () => 'A Closure route.');
56+
$routes->get('200', static fn () => 'A Closure route.');
5557
$routes->view('about', 'pages/about');
5658

5759
$collector = new DefinedRouteCollector($routes);
@@ -69,6 +71,12 @@ public function testCollect(): void
6971
'name' => 'journals',
7072
'handler' => '\App\Controllers\Blogs',
7173
],
74+
[
75+
'method' => 'GET',
76+
'route' => '100',
77+
'name' => '100',
78+
'handler' => '\App\Controllers\Home::index',
79+
],
7280
[
7381
'method' => 'GET',
7482
'route' => 'product/([0-9]+)',
@@ -81,6 +89,12 @@ public function testCollect(): void
8189
'name' => 'feed',
8290
'handler' => '(Closure)',
8391
],
92+
[
93+
'method' => 'GET',
94+
'route' => '200',
95+
'name' => '200',
96+
'handler' => '(Closure)',
97+
],
8498
[
8599
'method' => 'GET',
86100
'route' => 'about',

0 commit comments

Comments
 (0)