From 43493932b3bf6d0ae2ae556467be4f39c7eb12fa Mon Sep 17 00:00:00 2001 From: hightemp Date: Tue, 27 Oct 2026 15:07:49 +0300 Subject: [PATCH 1/2] test(php): show the output of the script when its exit code is wrong Co-Authored-By: Claude Opus 5.5 --- client-php/tests/ProcessTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client-php/tests/ProcessTest.php b/client-php/tests/ProcessTest.php index 3819b8c..f59357e 100644 --- a/client-php/tests/ProcessTest.php +++ b/client-php/tests/ProcessTest.php @@ -38,7 +38,7 @@ public function testWarningAndUncaughtException(): void { [$exitCode, $output, $events] = $this->runScript('errors.php'); - self::assertSame(255, $exitCode); + self::assertSame(255, $exitCode, $output); self::assertStringContainsString('Order 7 not found', $output, 'PHP still reports the uncaught exception'); self::assertStringContainsString('Undefined index: discount', $output, 'and the warning'); self::assertSame(['request_start', 'message', 'error', 'error', 'request_end'], array_column($events, 'type')); @@ -53,7 +53,7 @@ public function testFatalError(): void { [$exitCode, $output, $events] = $this->runScript('fatal.php'); - self::assertSame(255, $exitCode); + self::assertSame(255, $exitCode, $output); self::assertStringContainsString('Allowed memory size', $output); self::assertSame(['request_start', 'error', 'request_end'], array_column($events, 'type')); self::assertSame('fatal', $events[1]['kind']); From d30135c400aa21349086ebd1cf766ef7f60a3b8b Mon Sep 17 00:00:00 2001 From: hightemp Date: Tue, 27 Oct 2026 15:27:07 +0300 Subject: [PATCH 2/2] test(php): skip the fatal error test where PHP itself exits with 1 on running out of memory setup-php builds of PHP 7.4-8.1 from October 2026 exit with code 1 after 'Allowed memory size exhausted' and skip shutdown functions, with no extensions and no library loaded (php -n). The official PHP 7.4 image and PHP 8.2+ still exit with 255 and run them, so the test checks bare PHP first and is skipped, with the reason, where PHP itself is broken. Co-Authored-By: Claude Opus 5.5 --- client-php/tests/ProcessTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client-php/tests/ProcessTest.php b/client-php/tests/ProcessTest.php index f59357e..b3c1f77 100644 --- a/client-php/tests/ProcessTest.php +++ b/client-php/tests/ProcessTest.php @@ -51,6 +51,10 @@ public function testWarningAndUncaughtException(): void public function testFatalError(): void { + if (!self::phpRunsShutdownAfterOutOfMemory()) { + self::markTestSkipped('This PHP build exits with code 1 on running out of memory and skips shutdown functions, ' + . 'without the library too (seen in setup-php builds of PHP 7.4-8.1 from October 2026)'); + } [$exitCode, $output, $events] = $this->runScript('fatal.php'); self::assertSame(255, $exitCode, $output); @@ -61,6 +65,17 @@ public function testFatalError(): void self::assertSame(255, $events[2]['exit_code']); } + /** Whether bare PHP, with no extensions and no library, still runs shutdown functions after running out of memory. */ + private static function phpRunsShutdownAfterOutOfMemory(): bool + { + $code = 'register_shutdown_function(function () { echo "shutdown"; }); ' + . 'while (true) { $chunks[] = str_repeat("x", 1024 * 1024); }'; + $command = sprintf('%s -n -d memory_limit=16M -d display_errors=0 -r %s 2>&1', escapeshellarg(PHP_BINARY), escapeshellarg($code)); + exec($command, $output, $exitCode); + + return $exitCode === 255 && implode("\n", $output) === 'shutdown'; + } + public function testProjectOfLibraryV1WithoutComposer(): void { [$exitCode, $output, $events] = $this->runScript('compat.php', [