-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Fix generated php.ini config file #215
Conversation
Hm, actually this doesn't seem to fix the issue I have. It fixed something like that on Box but that's not enough here |
The issue is that I'm using phpbrew which configure the compiled PHP version:
What is happening is you take all the ini files and dump the content (removing xdebug on the way) to restart the process using that temporary ini file instead. However, because of my PHP configuration it scans fort the additional ini files again causing the modules saved above to be loaded twice causing an error. Now according to the doc, it is possible to override that behaviour. So what needs to be done is also configuring This is however where this gets tricky: I didn't find a way to do that in a manner working with
so that works. Even more confusing, I don't have this issue with neither Composer or Box Any idea @borNfreee? |
Unfortunately, by just reading the code I don't understand why it scans again, because we reset We need some input from @sidz here, I will touch base with him tomorrow ;) |
@theofidry please double check that PHP_INI_SCAN_DIR is equal empty string. Also we use the same idea as composer could you please clone composer and try to run it with the same config? |
It is. The INI files are scanned because their location has been passed with the
It works fine with Composer. Actually it works fine with Infection on both PHP-Scoper and Box so maybe this is a project issue. I'm trying to get Infection working on Symfony (the project, not a Symfony app) |
if it will be possible for you to create a vagrant box for example I can take a look. |
I'll give it a try |
The documentation about
Sure and the process will restart fine. But when it restarts it sets the variable to its original value. However, you seem to have missed out providing this rather crucial bit of information for some reason, so instead the environment variable is always unset. Now, this problem has come up before and it occurs when you call another php process from the restarted process and have the need to give it an ini file (ie If you could explain your use case for using the tmp ini again, then I can perhaps come up with a way of incorporating https://packagist.org/packages/composer/xdebug-handler to make things a bit more robust. |
@johnstevenson Sure, nothing special
The main Infection process runs 2 types of the sub processes:
How it works: |
@johnstevenson I've investigated a bit (https://packagist.org/packages/composer/xdebug-handler) and seems like we need to have some kind of getter for the |
@sidz Thanks for the info
You can get that now by calling if (XdebugHandler::getSkippedVersion()) {
// We are in a restarted process
$tmpIni = php_ini_loaded_file();
} But I could possibly provide a method (say |
thank you @johnstevenson for the feedback.
👍 That is what we really need to
Your example will return the original path to the php.ini file but we need to get modified with disabled xdebug. From the Infection side we will need to do smth like this:
So there here^ we've removed the condition with |
No it won't, it will return the modified tmp ini with xdebug entries disabled. But I guess I need to understand the flow, so could you explain where the restart(s) occur based on your description:
Thanks. |
Okay, as I see it (please correct me if I am wrong):
So, if xdebug is loaded and This ini file can be used to start a sub-process without xdebug, which is what you currently do, but However, https://packagist.org/packages/composer/xdebug-handler can be used to emulate the current behaviour as it is, with a modification to public function findArguments()
{
$arguments = [];
$tempConfigPath = '';
if (XdebugHandler::getSkippedVersion()) {
$tempConfigPath = php_ini_loaded_file();
putenv('PHP_INI_SCAN_DIR=');
}
if (!empty($tempConfigPath) && file_exists($tempConfigPath)) {
$arguments[] = '-c';
$arguments[] = $tempConfigPath;
} elseif ('phpdbg' === PHP_SAPI) {
$arguments[] = '-qrr';
}
return $arguments;
} Alternatively, you could save the tmp ini path to an environment variable in case the sub-process invokes another sub-process of itself (because |
@johnstevenson thank you for your time.
yes
tbh I took this logic from https://github.com/composer/composer/blob/master/src/Composer/XdebugHandler.php#L63
Yeah, this is what I really want to do. But I think that we need to do this somewhere in the XdebugHandler instead of doing a trick in the |
I was actually questioning the renaming, from _ALLOW_XDEBUG to DISABLE_XDEBUG. It is not important, though it did confuse me a bit (not hard to do!)
Why do you need to override the restart method? |
Ah, not a big deal to rename.
|
When I suggested a possible So I've knocked that idea on the head because it is obviously confusing and could be misused. I have every intention of making xdebug-handler more extendable in the future, but it is very new as a standalone package and I don't want to rush into anything at this stage, until we have more of an idea about what folks want to to with it. Of course you can put the A couple of points I noticed whilst debugging, which may or may not be useful:
|
thanks for reporting, fixed d88d934 |
@borNfreee Cool - apologies for the shortcut and not creating an issue. Nice library, by the way. |
Is this still an issue? |
Nope, if it is I'll open the issue again with the appropriate info |
My PHP setup may be bit unorthodox (I'm using phpbrew) in the sense that I have different files for the configuration. Because of how they are included, there is no redundancy. However in the case of the
ConfigBuilder
, it simply collects the different configurations and put everything in a single file. The issue is that it may result in duplicated lines:So I would just make sure there is no duplicated lines in the dumped content :)