Skip to content

Commit 8c90f43

Browse files
Merge branch '12.5' into 13.1
* 12.5: Closes #5860 Update dependencies
2 parents 45a77b4 + f0ad610 commit 8c90f43

7 files changed

Lines changed: 124 additions & 9 deletions

File tree

ChangeLog-13.1.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes of the PHPUnit 13.1 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
44

5+
## [13.1.5] - 2026-MM-DD
6+
7+
### Fixed
8+
9+
* [#5860](https://github.com/sebastianbergmann/phpunit/issues/5860): PHP CLI `-d` settings are not forwarded to child processes for process isolation
10+
511
## [13.1.4] - 2026-04-15
612

713
### Fixed
@@ -74,6 +80,7 @@ All notable changes of the PHPUnit 13.1 release series are documented in this fi
7480
* [#6433](https://github.com/sebastianbergmann/phpunit/issues/6433): Logic in `TestSuiteLoader` is brittle and causes "Class FooTest not found" even for valid tests in valid filenames
7581
* [#6463](https://github.com/sebastianbergmann/phpunit/issues/6463): Process Isolation fails on non-serializable globals and quietly ignore closures
7682

83+
[13.1.5]: https://github.com/sebastianbergmann/phpunit/compare/13.1.4...13.1
7784
[13.1.4]: https://github.com/sebastianbergmann/phpunit/compare/13.1.3...13.1.4
7885
[13.1.3]: https://github.com/sebastianbergmann/phpunit/compare/13.1.2...13.1.3
7986
[13.1.2]: https://github.com/sebastianbergmann/phpunit/compare/13.1.1...13.1.2

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"sebastian/cli-parser": "^5.0.0",
4747
"sebastian/comparator": "^8.1.2",
4848
"sebastian/diff": "^8.1.0",
49-
"sebastian/environment": "^9.2.0",
49+
"sebastian/environment": "^9.3.0",
5050
"sebastian/exporter": "^8.0.1",
5151
"sebastian/git-state": "^1.0",
5252
"sebastian/global-state": "^9.0.0",

composer.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Util/PHP/DefaultJobRunner.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ private function buildCommand(Job $job, ?string $file): array
252252
}
253253
}
254254

255+
$phpSettings = array_merge($phpSettings, $this->cliIniOverrides($phpSettings));
256+
255257
$command = array_merge($command, $this->settingsToParameters(array_values($phpSettings)));
256258

257259
if (PHP_SAPI === 'phpdbg') {
@@ -280,6 +282,36 @@ private function buildCommand(Job $job, ?string $file): array
280282
return $command;
281283
}
282284

285+
/**
286+
* Detects INI settings that cannot be set via ini_set() (PHP_INI_SYSTEM
287+
* and PHP_INI_PERDIR) and whose current value differs from the value
288+
* configured in INI files.
289+
*
290+
* These settings must be forwarded as -d flags to child processes
291+
* because the @ini_set() calls in GlobalState::getIniSettingsAsString()
292+
* cannot change them at runtime.
293+
*
294+
* @param array<array-key, string> $alreadySet
295+
*
296+
* @return array<string, string>
297+
*/
298+
private function cliIniOverrides(array $alreadySet): array
299+
{
300+
$overrides = (new Runtime)->getSettingsNotChangeableAtRuntime();
301+
302+
foreach ($overrides as $key => $value) {
303+
foreach ($alreadySet as $existing) {
304+
if (str_starts_with($existing, $key . '=')) {
305+
unset($overrides[$key]);
306+
307+
break;
308+
}
309+
}
310+
}
311+
312+
return $overrides;
313+
}
314+
283315
/**
284316
* @param list<string> $settings
285317
*
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture;
11+
12+
use function defined;
13+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
14+
use PHPUnit\Framework\TestCase;
15+
16+
final class AutoPrependFileTest extends TestCase
17+
{
18+
#[RunInSeparateProcess]
19+
public function testAutoPrependFileIsLoadedInChildProcess(): void
20+
{
21+
$this->assertTrue(defined('AUTO_PREPEND_FILE_LOADED'));
22+
}
23+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
\define('AUTO_PREPEND_FILE_LOADED', true);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
PHP CLI -d settings are forwarded to child processes when using process isolation
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
6+
$process = proc_open(
7+
[
8+
PHP_BINARY,
9+
'-d',
10+
'auto_prepend_file=' . __DIR__ . '/_files/auto_prepend_file.php',
11+
__DIR__ . '/../../../phpunit',
12+
'--do-not-cache-result',
13+
'--no-configuration',
14+
__DIR__ . '/_files/AutoPrependFileTest.php',
15+
],
16+
[
17+
1 => ['pipe', 'w'],
18+
2 => ['pipe', 'w'],
19+
],
20+
$pipes,
21+
);
22+
23+
print stream_get_contents($pipes[1]);
24+
fclose($pipes[1]);
25+
26+
$stderr = stream_get_contents($pipes[2]);
27+
fclose($pipes[2]);
28+
29+
proc_close($process);
30+
31+
if ($stderr !== '') {
32+
print $stderr;
33+
}
34+
--EXPECTF--
35+
PHPUnit %s by Sebastian Bergmann and contributors.
36+
37+
Runtime: %s
38+
39+
. 1 / 1 (100%)
40+
41+
Time: %s, Memory: %s
42+
43+
OK (1 test, 1 assertion)

0 commit comments

Comments
 (0)