Conditionally add options to unserialize in PHP 7.0+.

This commit is contained in:
Denis Brumann 2016-12-29 19:41:55 +01:00
parent 51bc35cc84
commit b4201810b9
No known key found for this signature in database
GPG Key ID: 834DDE05D627E853
8 changed files with 41 additions and 8 deletions

View File

@ -93,7 +93,11 @@ class TwigDataCollector extends DataCollector implements LateDataCollectorInterf
public function getProfile()
{
if (null === $this->profile) {
$this->profile = unserialize($this->data['profile']);
if (PHP_VERSION_ID >= 70000) {
$this->profile = unserialize($this->data['profile'], array('allowed_classes' => array('Twig_Profiler_Profile')));
} else {
$this->profile = unserialize($this->data['profile']);
}
}
return $this->profile;

View File

@ -60,7 +60,11 @@ class AutowireServiceResource implements SelfCheckingResourceInterface, \Seriali
public function unserialize($serialized)
{
list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized);
if (PHP_VERSION_ID >= 70000) {
list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized, array('allowed_classes' => false));
} else {
list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized);
}
}
/**

View File

@ -185,6 +185,10 @@ class FormError implements \Serializable
*/
public function unserialize($serialized)
{
list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized);
if (PHP_VERSION_ID >= 70000) {
list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized, array('allowed_classes' => false));
} else {
list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized);
}
}
}

View File

@ -72,7 +72,11 @@ class EnvParametersResource implements SelfCheckingResourceInterface, \Serializa
public function unserialize($serialized)
{
$unserialized = unserialize($serialized);
if (PHP_VERSION_ID >= 70000) {
$unserialized = unserialize($serialized, array('allowed_classes' => false));
} else {
$unserialized = unserialize($serialized);
}
$this->prefix = $unserialized['prefix'];
$this->variables = $unserialized['variables'];

View File

@ -63,7 +63,11 @@ class FileLinkFormatter implements \Serializable
public function unserialize($serialized)
{
$this->fileLinkFormat = unserialize($serialized);
if (PHP_VERSION_ID >= 70000) {
$this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false));
} else {
$this->fileLinkFormat = unserialize($serialized);
}
}
private function getFileLinkFormat()

View File

@ -734,7 +734,11 @@ abstract class Kernel implements KernelInterface, TerminableInterface
public function unserialize($data)
{
list($environment, $debug) = unserialize($data);
if (PHP_VERSION_ID >= 70000) {
list($environment, $debug) = unserialize($data, array('allowed_classes' => false));
} else {
list($environment, $debug) = unserialize($data);
}
$this->__construct($environment, $debug);
}

View File

@ -73,7 +73,12 @@ class CompiledRoute implements \Serializable
*/
public function unserialize($serialized)
{
$data = unserialize($serialized);
if (PHP_VERSION_ID >= 70000) {
$data = unserialize($serialized, array('allowed_classes' => false));
} else {
$data = unserialize($serialized);
}
$this->variables = $data['vars'];
$this->staticPrefix = $data['path_prefix'];
$this->regex = $data['path_regex'];

View File

@ -116,7 +116,11 @@ class Route implements \Serializable
*/
public function unserialize($serialized)
{
$data = unserialize($serialized);
if (PHP_VERSION_ID >= 70000) {
$data = unserialize($serialized, array('allowed_classes' => array(CompiledRoute::class)));
} else {
$data = unserialize($serialized);
}
$this->path = $data['path'];
$this->host = $data['host'];
$this->defaults = $data['defaults'];