From 3b86b0a232d1bfd2bf302d00f62c1cdf9456005b Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 18 Jul 2026 21:33:03 +0200 Subject: [PATCH 1/4] Fix CLIRequest parseCommand TypeError when argv is missing --- system/HTTP/CLIRequest.php | 2 +- tests/system/HTTP/CLIRequestTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/system/HTTP/CLIRequest.php b/system/HTTP/CLIRequest.php index 453272a4f59a..67c6ad4c1c7c 100644 --- a/system/HTTP/CLIRequest.php +++ b/system/HTTP/CLIRequest.php @@ -185,7 +185,7 @@ public function getOptionString(bool $useLongOpts = false): string */ protected function parseCommand() { - $args = $this->getServer('argv'); + $args = $this->getServer('argv') ?? []; array_shift($args); // Scrap index.php $optionValue = false; diff --git a/tests/system/HTTP/CLIRequestTest.php b/tests/system/HTTP/CLIRequestTest.php index 0bf3da0a6848..d12889448a30 100644 --- a/tests/system/HTTP/CLIRequestTest.php +++ b/tests/system/HTTP/CLIRequestTest.php @@ -574,4 +574,15 @@ public function testIs(): void { $this->assertFalse($this->request->is('get')); } + + public function testParseCommandWithMissingArgv(): void + { + Services::injectMock('superglobals', new Superglobals([], [], [], [], [])); + + $request = new CLIRequest(new App()); + + $this->assertSame('', $request->getPath()); + $this->assertSame([], $request->getSegments()); + $this->assertSame('', $request->getOptionString()); + } } From 5ea079829655384ef78c12d675011284e5ed8bda Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 19 Jul 2026 21:48:35 +0200 Subject: [PATCH 2/4] docs: add changelog for CLIRequest parseCommand TypeError fix --- user_guide_src/source/changelogs/v4.7.5.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelogs/v4.7.5.rst b/user_guide_src/source/changelogs/v4.7.5.rst index c4bb7900e07a..b956ac442951 100644 --- a/user_guide_src/source/changelogs/v4.7.5.rst +++ b/user_guide_src/source/changelogs/v4.7.5.rst @@ -30,6 +30,7 @@ Deprecations Bugs Fixed ********** +- **CLIRequest:** Fixed a bug where ``parseCommand()`` could throw a TypeError when ``argv`` is missing. - **Logger:** Fixed a bug where interpolating a log message with array or non-stringable context values could raise PHP warnings or errors. See the repo's From dcc7e7dbae62a282b060079ca6ee1b607ad67a44 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 19 Jul 2026 22:22:00 +0200 Subject: [PATCH 3/4] trigger CI From 4d247bca4ebf20d8c03612cfa9ec09438aa8305e Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 19 Jul 2026 22:22:05 +0200 Subject: [PATCH 4/4] trigger CI