bug #30034 [Config] ensure moving away from Serializable wont break cache:clear (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
[Config] ensure moving away from Serializable wont break cache:clear
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
When a resource implementation moves away from `Serializable`, the `cache:clear` command currently fails with `Warning: Class Symfony\Component\Config\Resource\ClassExistenceResource has no unserializer`. This change makes it ignore the failure, which is fine.
Commits
-------
9d3180a7e2
[Config] ensure moving away from Serializable wont break cache:clear
This commit is contained in:
commit
c7937c9749
@ -156,10 +156,11 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface
|
|||||||
{
|
{
|
||||||
$e = null;
|
$e = null;
|
||||||
$meta = false;
|
$meta = false;
|
||||||
|
$content = file_get_contents($file);
|
||||||
$signalingException = new \UnexpectedValueException();
|
$signalingException = new \UnexpectedValueException();
|
||||||
$prevUnserializeHandler = ini_set('unserialize_callback_func', '');
|
$prevUnserializeHandler = ini_set('unserialize_callback_func', '');
|
||||||
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {
|
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {
|
||||||
if (E_WARNING === $type && 'Class __PHP_Incomplete_Class has no unserializer' === $msg) {
|
if (__FILE__ === $file) {
|
||||||
throw $signalingException;
|
throw $signalingException;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +168,7 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$meta = unserialize(file_get_contents($file));
|
$meta = unserialize($content);
|
||||||
} catch (\Error $e) {
|
} catch (\Error $e) {
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user