Skip to content

Commit 4ca9fee

Browse files
author
Denis Brumann
committed
Conditionally add options to unserialize in PHP 7.0+.
1 parent 01e72a5 commit 4ca9fee

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Config/EnvParametersResource.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ public function serialize()
7272

7373
public function unserialize($serialized)
7474
{
75-
$unserialized = unserialize($serialized);
75+
if (PHP_VERSION_ID >= 70000) {
76+
$unserialized = unserialize($serialized, array('allowed_classes' => false));
77+
} else {
78+
$unserialized = unserialize($serialized);
79+
}
7680

7781
$this->prefix = $unserialized['prefix'];
7882
$this->variables = $unserialized['variables'];

Debug/FileLinkFormatter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public function serialize()
6363

6464
public function unserialize($serialized)
6565
{
66-
$this->fileLinkFormat = unserialize($serialized);
66+
if (PHP_VERSION_ID >= 70000) {
67+
$this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false));
68+
} else {
69+
$this->fileLinkFormat = unserialize($serialized);
70+
}
6771
}
6872

6973
private function getFileLinkFormat()

Kernel.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,11 @@ public function serialize()
734734

735735
public function unserialize($data)
736736
{
737-
list($environment, $debug) = unserialize($data);
737+
if (PHP_VERSION_ID >= 70000) {
738+
list($environment, $debug) = unserialize($data, array('allowed_classes' => false));
739+
} else {
740+
list($environment, $debug) = unserialize($data);
741+
}
738742

739743
$this->__construct($environment, $debug);
740744
}

0 commit comments

Comments
 (0)