-
-
Notifications
You must be signed in to change notification settings - Fork 616
Fix setting error_reporting #1675
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 setting error_reporting #1675
Conversation
acoulton
left a comment
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.
@carlos-granados ahhh - that makes sense. Thanks for doing this, sorry I didn't get a chance to get back to it.
One tiny comment on the implementation.
I guess when this ships, people who were using their PHP configuration (rather than their Behat configuration) to e.g. ignore E_DEPRECATED may see failures.
However, I think that's acceptable if we highlight this in the changelog - it's better that we fix the issue that the ->withErrorReporting config doesn't currently work as expected.
| $this->previousErrorReporting = error_reporting(); | ||
| error_reporting($errorReporting); |
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.
Couldn't this just be a single call to error_reporting?
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, yes, of course
|
@acoulton I was already thinking about what you mentioned and I think it would be problematic to release the fix as it is because many people would not have set the error level using the config, so they may suddenly start seeing deprecations and other errors which are silenced by their php.ini config and I think that should be avoided.
|
|
@carlos-granados I guess... The only thing is, can we tell whether the user has set the error_reporting in config? Obviously we could add some state tracking to the I suppose we could change the default value from Behat/src/Behat/Testwork/Call/ServiceContainer/CallExtension.php Lines 69 to 71 in be3911b
And then we can use your patch as-is (even though the call to "change" the error_reporting level will essentially be a no-op). Off the top of my head I think that would match the current behaviour if the user has not explicitly configured Behat specifically, while fixing the issue if they have? |
Sounds like a good solution, let me test it. For now I am marking this PR as draft |
394fc6b to
6a4691a
Compare
6a4691a to
98306a0
Compare
|
@acoulton updated with your suggestion and tests modified to check all needed cases |
acoulton
left a comment
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.
Great, thanks @carlos-granados - just one small comment on BC
| private $errorReportingLevel = E_ALL, | ||
| private $errorReportingLevel, |
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.
It could technically be a BC break to make this parameter non-optional?
I think we could safely leave it with the default E_ALL, if we know that in practice in our usage we're always providing a value?
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.
Yeah, you are right, we don't really need to remove this default value to get this working. Restored
# Conflicts: # features/bootstrap/FeatureContext.php
98306a0 to
fd48063
Compare
acoulton
left a comment
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.
Perfect. Thanks for adding such comprehensive feature coverage :-)
|
@acoulton perhaps the time for a new release? |
|
I was thinking I'd try and update/replace the two existing JUnit-related PRs (#1459 ف) before we release: possibly easier for users if all the changes to junit content happen in the same release? Not sure if I'll get to those today, but hopefully by early next week (if not then we can ship as we are, I - don't think they're blocking, just nice-to-have). |
|
I
If you want, I can work on the second one (#1601) as it is related to paths, where I have done a lot of work recently, and you can work on the first one which is more familiar to you |
|
If you have time that would be great :) |
When the error reporting level was set (either by using
withErrorReporting()or by using the default value of E_ALL), we were callingset_error_handler()with this level but were not callingerror_reporting(). This meant that event though we had set a handler to be called on certain error levels, this handler might not be called if the error_reporting level set in php.ini was more restrictive. I saw this in a system where error_reporting was set toE_ALL & ~E_DEPRECATED & ~E_STRICTand the testWith default error reporting reports all PHP errors and deprecationsfailed because the deprecation was not raisedThis PR fixes this problem by actually setting the error_reporting level, not just using it in the set_error_handler call
Fixes #1663