8000 Merge branch '4.1' · symfony/symfony@1b2bd8f · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b2bd8f

Browse files
Merge branch '4.1'
* 4.1: [Cache][Security] Use Throwable where possible revert #27545 Update Finder.php [FrameworkBundle] remove dead code in CachePoolClearerPass Fix security-core cross-dependencies, fixes #27507 Pass previous exception to FatalErrorException
2 parents 1df0a69 + 302b0d4 commit 1b2bd8f

File tree

10 files changed

+33
-56
lines changed

10 files changed

+33
-56
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolClearerPass.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1514
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1615
use Symfony\Component\DependencyInjection\ContainerBuilder;
1716
use Symfony\Component\DependencyInjection\Reference;
@@ -38,22 +37,5 @@ public function process(ContainerBuilder $container)
3837
}
3938
$clearer->replaceArgument(0, $pools);
4039
}
41-
42-
if (!$container->has('cache.annotations')) {
43-
return;
44-
}
45-
$factory = array(AbstractAdapter::class, 'createSystemCache');
46-
$annotationsPool = $container->findDefinition('cache.annotations');
47-
if ($factory !== $annotationsPool->getFactory() || 4 !== count($annotationsPool->getArguments())) {
48-
return;
49-
}
50-
if ($container->has('monolog.logger.cache')) {
51-
$annotationsPool->addArgument(new Reference('monolog.logger.cache'));
52-
} elseif ($container->has('cache.system')) {
53-
$systemPool = $container->findDefinition('cache.system');
54-
if ($factory === $systemPool->getFactory() && 5 <= count($systemArgs = $systemPool->getArguments())) {
55-
$annotationsPool->addArgument($systemArgs[4]);
56-
}
57-
}
5840
}
5941
}

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,8 @@ public function getItem($key)
127127
$value = null;
128128
} elseif (\is_string($value) && isset($value[2]) && ':' === $value[1]) {
129129
try {
130-
$e = null;
131130
$value = unserialize($value);
132-
} catch (\Error $e) {
133-
} catch (\Exception $e) {
134-
}
135-
if (null !== $e) {
131+
} catch (\Throwable $e) {
136132
$value = null;
137133
$isHit = false;
138134
}
@@ -266,9 +262,7 @@ private function generateItems(array $keys): \Generator
266262
} elseif (\is_string($value) && isset($value[2]) && ':' === $value[1]) {
267263
try {
268264
yield $key => $f($key, unserialize($value), true);
269-
} catch (\Error $e) {
270-
yield $key => $f($key, null, false);
271-
} catch (\Exception $e) {
265+
} catch (\Throwable $e) {
272266
yield $key => $f($key, null, false);
273267
}
274268
} else {

src/Symfony/Component/Cache/Simple/PhpArrayCache.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,12 @@ public function get($key, $default = null)
7474
$value = $this->values[$key];
7575

7676
if ('N;' === $value) {
77-
$value = null;
78-
} elseif (\is_string($value) && isset($value[2]) && ':' === $value[1]) {
77+
return null;
78+
}
79+
if (\is_string($value) && isset($value[2]) && ':' === $value[1]) {
7980
try {
80-
$e = null;
81-
$value = unserialize($value);
82-
} catch (\Error $e) {
83-
} catch (\Exception $e) {
84-
}
85-
if (null !== $e) {
81+
return unserialize($value);
82+
} catch (\Throwable $e) {
8683
return $default;
8784
}
8885
}
@@ -235,9 +232,7 @@ private function generateItems(array $keys, $default)
235232
} elseif (\is_string($value) && isset($value[2]) && ':' === $value[1]) {
236233
try {
237234
yield $key => unserialize($value);
238-
} catch (\Error $e) {
239-
yield $key => $default;
240-
} catch (\Exception $e) {
235+
} catch (\Throwable $e) {
241236
yield $key => $default;
242237
}
243238
} else {

src/Symfony/Component/Cache/Traits/ApcuTrait.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,13 @@ protected function doSave(array $values, $lifetime)
103103
}
104104

105105
return array_keys($failures);
106-
} catch (\Error $e) {
107-
} catch (\Exception $e) {
108-
}
106+
} catch (\Throwable $e) {
107+
if (1 === count($values)) {
108+
// Workaround https://github.com/krakjoe/apcu/issues/170
109+
apcu_delete(key($values));
110+
}
109111

110-
if (1 === count($values)) {
111-
// Workaround https://github.com/krakjoe/apcu/issues/170
112-
apcu_delete(key($values));
112+
throw $e;
113113
}
114-
115-
throw $e;
116114
}
117115
}

src/Symfony/Component/Config/ResourceCheckerConfigCache.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ private function safelyUnserialize($file)
168168

169169
try {
170170
$meta = unserialize(file_get_contents($file));
171-
} catch (\Error $e) {
172-
} catch (\Exception $e) {
173-
}
174-
restore_error_handler();
175-
ini_set('unserialize_callback_func', $prevUnserializeHandler);
176-
if (null !== $e && $e !== $signalingException) {
177-
throw $e;
171+
} catch (\Throwable $e) {
172+
if ($e !== $signalingException) {
173+
throw $e;
174+
}
175+
} finally {
176+
restore_error_handler();
177+
ini_set('unserialize_callback_func', $prevUnserializeHandler);
178178
}
179179

180180
return $meta;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public function __construct(string $message, \ErrorException $previous)
2626
$previous->getSeverity(),
2727
$previous->getFile(),
2828
$previous->getLine(),
29+
null,
30+
true,
31+
null,
2932
$previous->getPrevious()
3033
);
3134
$this->setTrace($previous->getTrace());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
*/
1919
class FatalErrorException extends \ErrorException
2020
{
21-
public function __construct(string $message, int $code, int $severity, string $filename, int $lineno, int $traceOffset = null, bool $traceArgs = true, array $trace = null)
21+
public function __construct(string $message, int $code, int $severity, string $filename, int $lineno, int $traceOffset = null, bool $traceArgs = true, array $trace = null, \Throwable $previous = null)
2222
{
23-
parent::__construct($message, $code, $severity, $filename, $lineno);
23+
parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
2424

2525
if (null !== $trace) {
2626
if (!$traceArgs) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public function __construct(string $message, \ErrorException $previous)
2626
$previous->getSeverity(),
2727
$previous->getFile(),
2828
$previous->getLine(),
29+
null,
30+
true,
31+
null,
2932
$previous->getPrevious()
3033
);
3134
$this->setTrace($previous->getTrace());

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public function __construct(string $message, \ErrorException $previous)
2626
$previous->getSeverity(),
2727
$previous->getFile(),
2828
$previous->getLine(),
29+
null,
30+
true,
31+
null,
2932
$previous->getPrevious()
3033
);
3134
$this->setTrace($previous->getTrace());

src/Symfony/Component/Security/Http/Firewall/ContextListener.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ private function safelyUnserialize($serializedToken)
226226

227227
try {
228228
$token = unserialize($serializedToken);
229-
} catch (\Error $e) {
230-
} catch (\Exception $e) {
229+
} catch (\Throwable $e) {
231230
}
232231
restore_error_handler();
233232
ini_set('unserialize_callback_func', $prevUnserializeHandler);

0 commit comments

Comments
 (0)
0