Skip to content

Pass xdebug, pcov and uopz startup switches on to workers and restarts - #6931

Merged
ondrejmirtes merged 2 commits into
2.3.xfrom
pass-startup-switches-to-restarted-processes
Nov 3, 2026
Merged

ondrejmirtes merged 2 commits into
2.3.xfrom
pass-startup-switches-to-restarted-processes

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

Running php -d xdebug.mode=off vendor/bin/phpstan analyse with xdebug.mode=debug,coverage in php.ini left xdebug armed in places RestartManager is supposed to keep clean.

Spawned workers (Windows, or anywhere fork is not used). The main process sees xdebug.mode=off and has nothing to restart for. Workers are spawned with -c php.ini and phpstan.restarted=1, so they get php.ini's armed xdebug and never restart themselves. Before RestartManager this was masked: every worker ran XdebugHandler in CommandHelper::begin() and restarted itself without xdebug. ProcessHelper now passes the parent's xdebug.mode, pcov.enabled and uopz.disable on as -d, for each loaded extension (RestartExtensionRegistry::getStartupSwitches()). Worker -d entries are now shell-escaped because xdebug.mode can contain spaces.

Restart that composes no ini (turbo is the only reason, e.g. the phar with OPcache not loaded). getPassedThroughArguments() re-executed PHP with only -c php.ini -d memory_limit=…, so the main process and its forked workers got the armed xdebug back, and the restart marker blocked the restart that would disarm it. Before, XdebugHandler's later check restarted a second time. The same switches are now passed through there too.

Reproduced both locally (pcntl disabled to spawn the way Windows does; a fake phar directory with a stand-in turbo binary for the second one) and checked both after the fix. Added a Windows row to the process restart E2E tests covering the spawned-worker case.

php -d xdebug.mode=off leaves the main process nothing to restart for,
but spawned workers load only the php.ini and do not restart themselves,
so they ran with the php.ini's armed xdebug. Before RestartManager, each
worker ran XdebugHandler on its own and restarted without xdebug.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1a349-2844-71e4-8763-34b8c84967e1
…mposes no ini

A restart only loading the turbo extension re-executes PHP with the
php.ini and memory_limit alone, so php -d xdebug.mode=off got the
php.ini's armed xdebug back, and the restart marker then prevented the
restart that would disarm it.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1a349-2844-71e4-8763-34b8c84967e1
@ondrejmirtes
ondrejmirtes merged commit 5e92535 into 2.3.x Nov 3, 2026
349 checks passed
@ondrejmirtes
ondrejmirtes deleted the pass-startup-switches-to-restarted-processes branch November 3, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant