Implement deferToPreviousErrorHandler XML configuration option#6708
Closed
sebastianbergmann wants to merge 1 commit into
Closed
Implement deferToPreviousErrorHandler XML configuration option#6708sebastianbergmann wants to merge 1 commit into
deferToPreviousErrorHandler XML configuration option#6708sebastianbergmann wants to merge 1 commit into
Conversation
API Surface ChangesIf any of the additions below are not intended as public API, mark them with New API SurfaceMethods
Modified API SurfaceMethods
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 13.2 #6708 +/- ##
============================================
- Coverage 97.56% 97.56% -0.01%
- Complexity 8694 8715 +21
============================================
Files 868 868
Lines 26540 26592 +52
============================================
+ Hits 25894 25944 +50
- Misses 646 648 +2 ☔ View full report in Codecov by Harness. |
Closed
Owner
Author
|
Superseded by #6710. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since PHPUnit 13.2, PHPUnit takes full ownership of the error handler while your tests run. It installs its own handler, processes every deprecation, notice, warning, and error itself (classifying it, applying the baseline, deduplicating it, and reporting it) and only then forwards the issue to any error handler that was registered before PHPUnit (for example in a bootstrap file).
This was an intentional consequence of #5845, and it is the correct behavior: deciding whether an issue is ignored or reported belongs to PHPUnit, in one place, so that the baseline,
--display-deprecations,failOnDeprecation, and the issue-trigger classification all agree.A side effect is that a custom error handler registered before PHPUnit can no longer suppress issues before PHPUnit sees them. Some setups relied on exactly that, for example Drupal's
BootstrapErrorHandler, which filters deprecations against an ignore list and only forwards the rest (see #6705).This adds a new opt-in boolean attribute on the root
<phpunit>element of PHPUnit's XML configuration file:When enabled, PHPUnit gives the previously registered error handler the first chance to handle each issue. If that handler reports the issue as handled, PHPUnit does nothing further with it: it is not processed, baselined, or reported. Only issues the previous handler declines are processed by PHPUnit as usual. This restores the pre-13.2 precedence and lets bootstrap-based handlers (such as Drupal's) work as they did before.
The option is off by default; existing behavior is unchanged unless you explicitly turn it on. It can only be set in the XML configuration file (there is no CLI flag).
When the option is enabled, any issue your handler suppresses becomes invisible to PHPUnit: to the baseline, deduplication, trigger classification,
--display-deprecations,failOnDeprecation, and to loggers and extensions. PHPUnit can no longer guarantee that its reporting reflects what actually happened during the run.Because of this, PHPUnit emits a notice on every run while the option is active, stating clearly that issue handling has been delegated outside of PHPUnit's control and that reporting integrity cannot be guaranteed. The notice is always shown. By default, PHPUnit does not exit with a shell exit code indicating failure just because the test runner triggered a notice.
Treat this as a compatibility escape hatch, not a recommended configuration. Prefer PHPUnit's built-in mechanisms for handling deprecations which keep PHPUnit as the single authority over what is reported. Use
deferToPreviousErrorHandler="true"only when you specifically need a pre-existing error handler to take precedence.