8000 feature #22832 [Debug] Deprecate support for stacked errors (mbabker) · symfony/symfony@7ac2570 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ac2570

Browse files
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
2 parents 26641bd + 04b8b80 commit 7ac2570

File tree

6 files changed

+25
-2
lines changed

6 files changed

+25
-2
lines changed

UPGRADE-3.4.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ DependencyInjection
66

77
* Top-level anonymous services in XML are deprecated and will throw an exception in Symfony 4.0.
88

9+
Debug
10+
-----
11+
12+
* Support for stacked errors in the `ErrorHandler` is deprecated and will be removed in Symfony 4.0.
13+
914
Finder
1015
------
1116

UPGRADE-4.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Debug
7070
* `FlattenException::getTrace()` now returns additional type descriptions
7171
`integer` and `float`.
7272

73+
* Support for stacked errors in the `ErrorHandler` has been removed
74+
7375
DependencyInjection
7476
-------------------
7577

src/Symfony/Component/Debug/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
3.4.0
5+
-----
6+
7+
* deprecated `ErrorHandler::stackErrors()` and `ErrorHandler::unstackErrors()`
8+
49
3.3.0
510
-----
611

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static function disable()
136136
*/
137137
public function loadClass($class)
138138
{
139-
ErrorHandler::stackErrors();
139+
$e = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
140140

141141
try {
142142
if ($this->isFinder) {
@@ -148,7 +148,7 @@ public function loadClass($class)
148148
$file = false;
149149
}
150150
} finally {
151-
ErrorHandler::unstackErrors();
151+
error_reporting($e);
152152
}
153153

154154
$exists = class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false);

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,17 +648,25 @@ public static function handleFatalError(array $error = null)
648648
*
649649
* The most important feature of this is to prevent
650650
* autoloading until unstackErrors() is called.
651+
*
652+
* @deprecated since version 3.4, to be removed in 4.0.
651653
*/
652654
public static function stackErrors()
653655
{
656+
@trigger_error('Support for stacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
657+
654658
self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
655659
}
656660

657661
/**
658662
* Unstacks stacked errors and forwards to the logger.
663+
*
664+
* @deprecated since version 3.4, to be removed in 4.0.
659665
*/
660666
public static function unstackErrors()
661667
{
668+
@trigger_error('Support for unstacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
669+
662670
$level = array_pop(self::$stackedErrorLevels);
663671

664672
if (null !== $level) {

src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ public function testHandleException()
342342
}
343343
}
344344

345+
/**
346+
* @group legacy
347+
*/
345348
public function testErrorStacking()
346349
{
347350
try {

0 commit comments

Comments
 (0)
0