-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Use the current config #47
Conversation
Not sure, but don't we then need both |
I'm not sure either so I just aligned myself with what Composer XdebugHandler was doing |
I'm pretty sure |
I've just tried it and indeed that solves the warning issue |
Any idea on why this is failing on Windows? I don't have a windows machine so I won't be able to do much debugging locally :/ |
Don't worry, everything is currently failing on Windows, it's not related to this PR. |
@theofidry this happens because PHP loads not only the default php.ini, but all other files, which naturally include directive to load other module. Try: setenv("PHP_INI_SCAN_DIR="); This should make all processes ignore those extra .ini files. And yeah, |
If you want all child processes to exclude xdebug, this is also doable.
This is easy to verify: $ mkdir /tmp/phprc
$ touch /tmp/phprc/php.ini
$ PHP_INI_SCAN_DIR="" PHPRC="/tmp/phprc" php -r 'echo `php --ini`;'
Configuration File (php.ini) Path: /usr/local/etc/php/7.2
Loaded Configuration File: /tmp/phprc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none) So PHP sees and loads only |
Why not just adding |
With With (I have not looked if this is particularly important in this case.) |
I think that's fine. I mean that part is actually out of the scope of Amp it's more on the consumer like me how they want to integrate it with the xdebug handler. However I'm more concerned about if this patch is safe or if it could break something. If it does break then I'll have to find an alternative way to handle it |
Any reason for not using |
@kelunik I've tested with Is there anything else concerning you? I'd like to include this patch in the next version of Box if possible |
xDebugHandler can be disabled. Best would be to check that this isn't the case. |
@sanmai is XDebugHandler really the issue here? What I see is that the worker is started with a different configuration than the main process, so if I pass a custom config it's just not gonna pick it up. Note however that it is indeed only a patch not a real fix. For example if I call the main process with I also tried to just not care and put XDebugHandler in the work process directly, but it's a +17% slowdown (box now takes 33s instead of 23s) |
|
Can you give an example? I've been testing with Box but it just works fine (I had to do Also an issue is that I don't have more control on the command used for the base process at all: it's deeper in Amp and there is not much of an extension point AFAICS |
lib/Context/Process.php
Outdated
$command = \implode(" ", [ | ||
\escapeshellarg($binary), | ||
$phpConfig ? "-n -c $phpConfig" : "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There needs to be an escapeshellarg
around the $phpConfig
.
lib/Context/Process.php
Outdated
@@ -120,7 +120,7 @@ public function __construct($script, string $cwd = null, array $env = [], string | |||
|
|||
$command = \implode(" ", [ | |||
\escapeshellarg($binary), | |||
$phpConfig ? "-n -c $phpConfig" : "", | |||
$phpConfig ? \escapeshellarg("-n -c $phpConfig") : "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'll make -n -c $phpConfig
one argument. The escapeshellarg
needs to be only around the $phpConfig
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must be
"-n -c ".\escapeshellarg($phpConfig)
Let's say a user chose to keep xdebug enabled, and you started a process with For example, under Debian-based even very basic things like SimpleXML are not compiled in:
|
True but on another hand scanning for them would require to do something a la XdebugHandler which is an order or magnitude more complex and you cannot also leave it to the user since there is no extension point for it. Which is why I say it's a patch not a real fix |
You don't have to do anything other than checking that XDebugHandler did its job by looking at output from |
I'll need to test the patch with my system library. Usually I use a custom compiled one that has almost everything built-in. |
Any progress @kelunik or something I can help with? |
It appears to me Parallel should not be doing anything like this. Like, at all. If a user needs to use a custom php.ini from XdebugHandler, it is as simple as:
Nothing else needs to be done to run all sub-processes without xdebug, other than adding the two above lines. Work is underway in composer/xdebug-handler#67 to abstract away even these details. |
@sanmai ah I see what you mean. Yeah indeed that looks better thanks! I think I'll have to adjust some things in Box to restart the process with XdebugHandler in any case to ensure the workers are started with the same configuration as the main process (xdebug or not). Maybe this should be done in parallel instead, but in any case this patch is not gonna cut it anyway |
@theofidry Sorry for not getting back to you on this topic. I'm glad to hear that the proposed solution probably works for you without changes on our side. #47 (comment) is an important issue with |
No problem @kelunik |
In the case of Box for example, the PHP process may be restarted (via composer/xdebug-handler) with a different configuration file to disable xdebug among other things. Right now, it looks like the processes used are not using that configuration and as a result, even though the main process may not have xdebug enabled, the works will run with xdebug enabled.
It seems however that my patch is incomplete as it looks like some elements of the config are loaded twice, the following message is printed at the start of each worker: