feature #22832 [Debug] Deprecate support for stacked errors (mbabker)

This PR was merged into the 3.4 branch.

Discussion
----------

[Debug] Deprecate support for stacked errors

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | #22804
| License       | MIT
| Doc PR        | n/a

Per discussion in #22804 this deprecates support for error stacking.  // @nicolas-grekas

Commits
-------

04b8b80 Deprecate support for stacked errors
This commit is contained in:
Nicolas Grekas 2017-07-06 13:21:47 +03:00
commit 7ac2570d5c
6 changed files with 25 additions and 2 deletions

View File

@ -6,6 +6,11 @@ DependencyInjection
* Top-level anonymous services in XML are deprecated and will throw an exception in Symfony 4.0. * Top-level anonymous services in XML are deprecated and will throw an exception in Symfony 4.0.
Debug
-----
* Support for stacked errors in the `ErrorHandler` is deprecated and will be removed in Symfony 4.0.
Finder Finder
------ ------

View File

@ -70,6 +70,8 @@ Debug
* `FlattenException::getTrace()` now returns additional type descriptions * `FlattenException::getTrace()` now returns additional type descriptions
`integer` and `float`. `integer` and `float`.
* Support for stacked errors in the `ErrorHandler` has been removed
DependencyInjection DependencyInjection
------------------- -------------------

View File

@ -1,6 +1,11 @@
CHANGELOG CHANGELOG
========= =========
3.4.0
-----
* deprecated `ErrorHandler::stackErrors()` and `ErrorHandler::unstackErrors()`
3.3.0 3.3.0
----- -----

View File

@ -136,7 +136,7 @@ class DebugClassLoader
*/ */
public function loadClass($class) public function loadClass($class)
{ {
ErrorHandler::stackErrors(); $e = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
try { try {
if ($this->isFinder) { if ($this->isFinder) {
@ -148,7 +148,7 @@ class DebugClassLoader
$file = false; $file = false;
} }
} finally { } finally {
ErrorHandler::unstackErrors(); error_reporting($e);
} }
$exists = class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); $exists = class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false);

View File

@ -648,17 +648,25 @@ class ErrorHandler
* *
* The most important feature of this is to prevent * The most important feature of this is to prevent
* autoloading until unstackErrors() is called. * autoloading until unstackErrors() is called.
*
* @deprecated since version 3.4, to be removed in 4.0.
*/ */
public static function stackErrors() public static function stackErrors()
{ {
@trigger_error('Support for stacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
} }
/** /**
* Unstacks stacked errors and forwards to the logger. * Unstacks stacked errors and forwards to the logger.
*
* @deprecated since version 3.4, to be removed in 4.0.
*/ */
public static function unstackErrors() public static function unstackErrors()
{ {
@trigger_error('Support for unstacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
$level = array_pop(self::$stackedErrorLevels); $level = array_pop(self::$stackedErrorLevels);
if (null !== $level) { if (null !== $level) {

View File

@ -342,6 +342,9 @@ class ErrorHandlerTest extends TestCase
} }
} }
/**
* @group legacy
*/
public function testErrorStacking() public function testErrorStacking()
{ {
try { try {