-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable ini files when restarted by XdebugHandler #726
Conversation
Disable use of (additional) ini files for workers when restarted by XdebugHandler
use better check for existing environment variables
Does composer itself work for you with your setup (composer uses the same xdebug-handler internally)? I am wondering whether there is a issue with your setup, or with the xdebug handler, or the phpstan integration |
Composer works. Have a look at this post: composer/xdebug-handler#137 (comment) |
This is a summary of my post on the linked issue: This error is a result of #559 which adds code to allow the user to pass a custom ini file on the command-line so that it can be used in a worker process. phpstan-src/src/Process/ProcessHelper.php Lines 27 to 28 in 2c11075
Unfortunately it overlooked xdebug-handler, which in this case had already performed a restart using a tmp ini file created from the loaded and additional ini files. Because the worker process is called without preventing additional ini files scanning, php loads the extensions from the main ini file (actually xdebug-handler's tmp ini) , then tries to reload them from the additional inis. And because xdebug is loaded in the worker process, xdebug-handler performs another restart. xdebug-handler has been designed to handle these situations with its persistent settings strategy: https://github.com/composer/xdebug-handler#persistent-settings
This creates a flexible xdebug-free environment for all child processes and in my view is the best solution. |
@johnstevenson So instead of this PR, the only thing we need to add is |
@ondrejmirtes Yes, correct |
Alright, just did that: 222e1c3 Can you please verify it works as expected? Thanks. |
Okay, you can probably get rid of the extra code that was added in ProcessHelper.php. I'll reproduce the various scenarios and check them just to confirm. |
What extra code? |
Also please wait a bit; the new commit hasn't yet built to phpstan/phpstan. The CI pipeline is full today. |
The extra code introduced in #559
I tend to specifically replicate these scenarious in my own testcase classes first. One day I'll put them on Github, when I've worked out a simple way to automate them! |
It's now in phpstan/phpstan dev-master, so you can test it :) |
@ondrejmirtes Great, this works nicely and keeps Xdebug out of all subprocesses.
I was wrong about this. Explicitly setting the loaded ini on the comand-line has no downsides when XdebugHandler has restarted the process, because everything is in a single ini file (which is made available to PHP through through $phpCmd = escapeshellarg(PHP_BINARY);
if (XdebugHandler::getRestartSettings() === null && php_ini_loaded_file() !== false) {
// Explicitly set ini file in case it was passed in on the command line
$phpCmd .= ' -c ' .escapeshellarg(php_ini_loaded_file());
}
$processCommandArray = [
$phpCmd,
]; |
Disable use of (additional) ini files for workers when restarted by XdebugHandler
This relates to: phpstan/phpstan#5809