Skip to content

Commit b420181

Browse files
author
Denis Brumann
committed
Conditionally add options to unserialize in PHP 7.0+.
1 parent 51bc35c commit b420181

File tree

8 files changed

+41
-8
lines changed

8 files changed

+41
-8
lines changed

src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ public function getHtmlCallGraph()
9393
public function getProfile()
9494
{
9595
if (null === $this->profile) {
96-
$this->profile = unserialize($this->data['profile']);
96+
if (PHP_VERSION_ID >= 70000) {
97+
$this->profile = unserialize($this->data['profile'], array('allowed_classes' => array('Twig_Profiler_Profile')));
98+
} else {
99+
$this->profile = unserialize($this->data['profile']);
100+
}
97101
}
98102

99103
return $this->profile;

src/Symfony/Component/DependencyInjection/Config/AutowireServiceResource.php

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

6161
public function unserialize($serialized)
6262
{
63-
list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized);
63+
if (PHP_VERSION_ID >= 70000) {
64+
list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized, array('allowed_classes' => false));
65+
} else {
66+
list($this->class, $this->filePath, $this->autowiringMetadata) = unserialize($serialized);
67+
}
6468
}
6569

6670
/**

src/Symfony/Component/Form/FormError.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ public function serialize()
185185
*/
186186
public function unserialize($serialized)
187187
{
188-
list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized);
188+
if (PHP_VERSION_ID >= 70000) {
189+
list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized, array('allowed_classes' => false));
190+
} else {
191+
list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized);
192+
}
189193
}
190194
}

src/Symfony/Component/HttpKernel/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'];

src/Symfony/Component/HttpKernel/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()

src/Symfony/Component/HttpKernel/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
}

src/Symfony/Component/Routing/CompiledRoute.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ public function serialize()
7373
*/
7474
public function unserialize($serialized)
7575
{
76-
$data = unserialize($serialized);
76+
if (PHP_VERSION_ID >= 70000) {
77+
$data = unserialize($serialized, array('allowed_classes' => false));
78+
} else {
79+
$data = unserialize($serialized);
80+
}
81+
7782
$this->variables = $data['vars'];
7883
$this->staticPrefix = $data['path_prefix'];
7984
$this->regex = $data['path_regex'];

src/Symfony/Component/Routing/Route.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ public function serialize()
116116
*/
117117
public function unserialize($serialized)
118118
{
119-
$data = unserialize($serialized);
119+
if (PHP_VERSION_ID >= 70000) {
120+
$data = unserialize($serialized, array('allowed_classes' => array(CompiledRoute::class)));
121+
} else {
122+
$data = unserialize($serialized);
123+
}
120124
$this->path = $data['path'];
121125
$this->host = $data['host'];
122126
$this->defaults = $data['defaults'];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy