-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Respect PHP version used by Composer and provide better feedback on failure #80
Conversation
src/Plugin.php
Outdated
|
||
$command = ProcessExecutor::escape($phpPath); | ||
$command .= $phpArgs; | ||
$command .= ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen')); |
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.
Just curious why are these needed ?
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.
ah never mind, its the comment above
Confirm this fixes it. Nice job :) |
@exussum12 Thanks for testing & confirming! |
Composer 1.9.0 has just been released and I noticed an entry in the changelog which may be useful to solve this issue, though that would mean that only Composer 1.9.0+ would be supported and I haven't run any tests yet to see if it is available to plugins as well as Composer scripts. Anyway, just thought I'd leave a note about it here.
Ref: https://github.com/composer/composer/releases/tag/1.9.0 |
Your fix basically uses that. https://github.com/symfony/process/blob/master/PhpExecutableFinder.php#L36 The issue fixed in composer is for when the scripts called by composer are shell scripts (This is a direct php call) at least thats as i understand it - so this fix is still needed |
@exussum12 Thanks for looking into it. I hadn't had time yet. I was hoping it would remove the need for the function copy which is part of this PR. |
For me, all that is needed is that I find a moment where I have both time, energy and a development machine available. As you may have noticed, it can take a while before the stars are thusly aligned... I'm thinking that it might be beneficial at this point to add another developer to the list of maintainers as neither me nor @frenck can easily allocate time for this from our other responsibilities. |
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.
Made some minor changes, other than that, looks good.
To get Travis passing MR #86 needs to be merged. |
Awaiting MR #86, these changes can be seen to pass the build, except for PHP5.3:
|
Should this exit code be |
Yup. I think that might be another bug. |
Could you please rebase this on master, because the build issues have been resolved |
Rebased. |
I've rebased yet again and added an additional commit fixing the failure against PHPCS 2.x. The build will currently fail on some code style issues which are addressed in PR #88. I'll rebase this PR again once that PR has been merged so you can see the build passing. I'd really, really love to see this merged & released before the 1-year anniversary of the bug report..... As per my comment in the ticket #79 (comment), I've added another branch to the POC repo to make testing this fix even easier, but as can be seen in the comments from other people in this PR thread and based on my own tests, the fix works. |
This fixes the issue identified in #80 (comment) where even when the setting of `installed_paths` failed, the plugin would exit with exit code `0`.
This fixes the issue identified in #80 (comment) where even when the setting of `installed_paths` failed, the plugin would exit with exit code `0`.
This fixes the issue identified in #80 (comment) where even when the setting of `installed_paths` failed, the plugin would exit with exit code `0`. Technical choices: As PHPCS returns exit code `0`, even when the setting of the `installed_paths` failed, we need to verify that the paths we tried to set, have actually been set. To that end, a new function `verifySaveSuccess()` has been added. This function takes the paths which were to be saved and compares then to the paths which are actually set in PHPCS after the save to determine whether or not the plugin was successful. A `0` exit code will be returned if successful, `1` if not.
Related to 79. When the setting of `installed_paths` fails, show an error instead of giving the impression that the setting of the `installed_paths` succeeded.
Possible not the best way to do this, but it does work, so consider this a proof of concept, if not the solution. The `getPhpExecCommand()` method in the `Composer\EventDispatcher\EventDispatcher` class basically does what is needed: find the PHP executable used by Composer and turn it into an executable command. Unfortunately, that method is `protected`, making it difficult to call that method from within the plugin. This now copies that method into the plugin and uses it to create the command to pass on to the `ProcessExecutor`. The copied method has some minor modifications to comply with the coding standards used within this project. Based on the proof of conflict referenced in 79, I can confirm that this would solve the issue.
- Moves command outside of exec call, for readability - Moves error message composition to begin of method, to keep it together with other preparations and keep `if/else` statement cleaner - Adds whitespace to separate actions that do not belong together or for readability - Removes redundant variable concat
Rebased & force pushed now #88 has been merged. We should now be able to see a 100% passing build. |
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.
Any/All concerns I had have been addressed. As far as I am concerned, this can merged.
This fixes the issue identified in #80 (comment) where even when the setting of `installed_paths` failed, the plugin would exit with exit code `0`. A `0` exit code will be returned if successful, `1` - or the exit code returned by PHPCS itself - if not.
Proposed Changes
Improve feedback to user on failure to set paths
Related to #79.
When the setting of
installed_paths
fails, show an error instead of giving the impression that the setting of theinstalled_paths
succeeded.Use the PHP version used by Composer
Possibly not the best way to do this, but it does work, so consider this a proof of concept, if not the solution.
The
getPhpExecCommand()
method in theComposer\EventDispatcher\EventDispatcher
class basically does what is needed: find the PHP executable used by Composer and turn it into an executable command.Unfortunately, that method is
protected
, making it difficult to call that method from within the plugin.This now copies that method into the plugin and uses it to create the command to pass on to the
ProcessExecutor
.The copied method has some minor modifications to comply with the coding standards used within this project.
Based on the proof of conflict referenced in #79, I can confirm that this would solve the issue.
Related Issues
Fixes #79