minor #27795 [Security/Http] report file+line of unserialization errors in Firewall/ContextListener (nicolas-grekas)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Security/Http] report file+line of unserialization errors in Firewall/ContextListener

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

Commits
-------

9adb0c7e42 [Security/Http] report file+line of unserialization errors in Firewall/ContextListener
This commit is contained in:
Fabien Potencier 2018-07-03 09:24:55 +02:00
commit 9da045469e

View File

@ -218,7 +218,7 @@ class ContextListener implements ListenerInterface
$prevUnserializeHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback');
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$prevErrorHandler) {
if (__FILE__ === $file) {
throw new \UnexpectedValueException($msg, 0x37313bc);
throw new \ErrorException($msg, 0x37313bc, $type, $file, $line);
}
return $prevErrorHandler ? $prevErrorHandler($type, $msg, $file, $line, $context) : false;
@ -231,7 +231,7 @@ class ContextListener implements ListenerInterface
restore_error_handler();
ini_set('unserialize_callback_func', $prevUnserializeHandler);
if ($e) {
if (!$e instanceof \UnexpectedValueException || 0x37313bc !== $e->getCode()) {
if (!$e instanceof \ErrorException || 0x37313bc !== $e->getCode()) {
throw $e;
}
if ($this->logger) {
@ -247,6 +247,6 @@ class ContextListener implements ListenerInterface
*/
public static function handleUnserializeCallback($class)
{
throw new \UnexpectedValueException('Class not found: '.$class, 0x37313bc);
throw new \ErrorException('Class not found: '.$class, 0x37313bc);
}
}