8000 [Config] ensure moving away from Serializable wont break cache:clear by nicolas-grekas · Pull Request #30034 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Config] ensure moving away from Serializable wont break cache:clear #30034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Config] ensure moving away from Serializable wont break cache:clear
  • Loading branch information
nicolas-grekas committed Jan 30, 2019
commit 9d3180a7e23cedc63fbf269c1227ce9bbe3e3005
5 changes: 3 additions & 2 deletions src/Symfony/Component/Config/ResourceCheckerConfigCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,19 @@ private function safelyUnserialize($file)
{
$e = null;
$meta = false;
$content = file_get_contents($file);
$signalingException = new \UnexpectedValueException();
$prevUnserializeHandler = ini_set('unserialize_callback_func', '');
$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;
}

return $prevErrorHandler ? $prevErrorHandler($type, $msg, $file, $line, $context) : false;
});

try {
$meta = unserialize(file_get_contents($file));
$meta = unserialize($content);
} catch (\Error $e) {
} catch (\Exception $e) {
}
Expand Down
0