Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7974cd7

Browse files
feature #22804 [Debug] Removed ContextErrorException (mbabker)
This PR was merged into the 4.0-dev branch. Discussion ---------- [Debug] Removed ContextErrorException | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21388 | License | MIT | Doc PR | n/a Commits ------- 76dc317 Removed ContextErrorException
2 parents 1c1a86f + 76dc317 commit 7974cd7

File tree

5 files changed

+4
-82
lines changed

5 files changed

+4
-82
lines changed

src/Symfony/Component/Debug/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
-----
66

77
* removed the symfony_debug extension
8+
* removed `ContextErrorException`
89

910
3.4.0
1011
-----

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Log\LogLevel;
1515
use Psr\Log\LoggerInterface;
16-
use Symfony\Component\Debug\Exception\ContextErrorException;
1716
use Symfony\Component\Debug\Exception\FatalErrorException;
1817
use Symfony\Component\Debug\Exception\FatalThrowableError;
1918
use Symfony\Component\Debug\Exception\OutOfMemoryException;
@@ -415,11 +414,7 @@ public function handleError($type, $message, $file, $line)
415414
return;
416415
}
417416
} else {
418-
if ($scope) {
419-
$errorAsException = new ContextErrorException($logMessage, 0, $type, $file, $line, $context);
420-
} else {
421-
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);
422-
}
417+
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);
423418

424419
// Clean the trace by removing function arguments and the first frames added by the error handler itself.
425420
if ($throw || $this->tracedErrors & $type) {

src/Symfony/Component/Debug/Exception/ContextErrorException.php

Lines changed: 0 additions & 40 deletions
This file was deleted.

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

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Debug\DebugClassLoader;
16-
use Symfony\Component\Debug\ErrorHandler;
1716

1817
class DebugClassLoaderTest extends TestCase
1918
{
@@ -59,38 +58,6 @@ public function testIdempotence()
5958
$this->fail('DebugClassLoader did not register');
6059
}
6160

62-
public function testStacking()
63-
{
64-
// the ContextErrorException must not be loaded to test the workaround
65-
// for https://bugs.php.net/65322.
66-
if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) {
67-
$this->markTestSkipped('The ContextErrorException class is already loaded.');
68-
}
69-
70-
ErrorHandler::register();
71-
72-
try {
73-
// Trigger autoloading + E_STRICT at compile time
74-
// which in turn triggers $errorHandler->handle()
75-
// that again triggers autoloading for ContextErrorException.
76-
// Error stacking works around the bug above and everything is fine.
77-
78-
eval('
79-
namespace '.__NAMESPACE__.';
80-
class ChildTestingStacking extends TestingStacking { function foo($bar) {} }
81-
');
82-
$this->fail('ContextErrorException expected');
83-
} catch (\ErrorException $exception) {
84-
// if an exception is thrown, the test passed
85-
$this->assertStringStartsWith(__FILE__, $exception->getFile());
86-
$this->assertRegExp('/^Warning: Declaration/', $exception->getMessage());
87-
$this->assertEquals(E_WARNING, $exception->getSeverity());
88-
} finally {
89-
restore_error_handler();
90-
restore_exception_handler();
91-
}
92-
}
93-
9461
/**
9562
* @expectedException \RuntimeException
9663
*/

src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\HttpFoundation\Session\Storage;
1313

14-
use Symfony\Component\Debug\Exception\ContextErrorException;
1514
use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
1615
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler;
1716
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy;
@@ -213,13 +212,13 @@ public function save()
213212
{
214213
// Register custom error handler to catch a possible failure warning during session write
215214
set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
216-
throw new ContextErrorException($errstr, $errno, E_WARNING, $errfile, $errline, $errcontext);
215+
throw new \ErrorException($errstr, $errno, E_WARNING, $errfile, $errline, $errcontext);
217216
}, E_WARNING);
218217

219218
try {
220219
session_write_close();
221220
restore_error_handler();
222-
} catch (ContextErrorException $e) {
221+
} catch (\ErrorException $e) {
223222
// The default PHP error message is not very helpful, as it does not give any information on the current save handler.
224223
// Therefore, we catch this error and trigger a warning with a better error message
225224
$handler = $this->getSaveHandler();

0 commit comments

Comments
 (0)