Skip to content

[PHPUnit Bridge]Implement poor man's error handler #21795

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

Closed

Conversation

greg0ire
Copy link
Contributor

@greg0ire greg0ire commented Feb 28, 2017

This line of code is hit when the error handler has failed. In that
case, we want to get errors in the most reliable possible way, with very
simple code. I think var_export and error_get_last are good candidates
for that.

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets none
License MIT
Doc PR none

Here is what it looks like. I will remove the purposefully wrong commit once everyone is ok with the output. Please not that in that case, it's a phpt, so it's a bit special.
Also, to elaborate a bit on the why, if you feel like people developing on the deprecation error handler could easily add these lines and remove them after debugging their problem, bear in mind that some problems, just like the one I introduced to test this, occur on some builds only.

The problem I introduced was a mistake I made in #21539 .
To debug it I had to find the right Travis container from quay.io, set up travis-build on it, which is quite an ordeal, and then run the generated ci.sh script.

@@ -112,7 +112,7 @@ public static function register($mode = 0)
$trace = debug_backtrace(true);
$group = 'other';

$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($file));
$isWeak = DeprecationErrorHandler::MODE_WEAK === $mode || (self::MODE_WEAK_VENDORS === $mode && $isVendor = $inVendors($file));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is a no-go. The PHPUnit Bridge is still compatible with PHP 5.3 even in master (our own testsuite uses the newest bridge even in LTS branches)

Copy link
Contributor Author

@greg0ire greg0ire Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof: this is to demonstrate the error handling, and will be removed from the PR before merging. Please read the commit messages :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way to showcase it in a test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would imply isolating it in a public method. Or maybe… in a private method, and then do a bit of black magic to make it public with reflection. I'll see what I can do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm… that won't be so easy since we're inside a closure, which is itself inside another closure. But the condition to run this piece of code is just to change the error handler. Let's try that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why focus on this specific way to trigger a failure? Aren't there "userland" side to showcase the new behavior in e.g. a phpt test case?

Copy link
Contributor Author

@greg0ire greg0ire Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No there aren't AFAIK. I think this only happens when there is a programming error in the deprecation error handler. Should I think otherwise? I only saw it in action when (failing at) writing my other PR on this error handler, so maybe I'm missing other possible ways to trigger this piece of code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? Then we don't care sorry...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh. Please reconsider… these few lines can save literal hours to anyone try to contribute to this error handler. I know the audience is small, but it exists.

@greg0ire greg0ire changed the title Implement poor man's error handler [PHPUnit Bridge]Implement poor man's error handler Feb 28, 2017
@greg0ire greg0ire mentioned this pull request Feb 28, 2017
7 tasks
@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Feb 28, 2017
This line of code is hit when the error handler has failed. In that
case, we want to get errors in the most reliable possible way, with very
simple code. I think var_export and error_get_last are good candidates
for that.
@greg0ire greg0ire force-pushed the feature/poor_mans_error_handler branch from 7e2c5e8 to 7832b32 Compare February 28, 2017 18:55
@greg0ire
Copy link
Contributor Author

greg0ire commented Mar 1, 2017

Then we don't care sorry...

You probably know better, let's just close this.

@greg0ire greg0ire closed this Mar 1, 2017
@greg0ire greg0ire deleted the feature/poor_mans_error_handler branch March 1, 2017 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants