Skip to content

Commit d6468e1

Browse files
committed
Call get_magic_quotes_gpc() only for PHP < 5.4 as it always returns false on newer versions and is deprecated since PHP 7.4
1 parent 89421ab commit d6468e1

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

lib/request/sfWebRequest.class.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ public function initialize(sfEventDispatcher $dispatcher, $parameters = array(),
7575
parent::initialize($dispatcher, $parameters, $attributes, $options);
7676

7777
// GET parameters
78-
$this->getParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_GET) : $_GET;
78+
if (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc())
79+
{
80+
$this->getParameters = sfToolkit::stripslashesDeep($_GET);
81+
}
82+
else
83+
{
84+
$this->getParameters = $_GET;
85+
}
7986
$this->parameterHolder->add($this->getParameters);
8087

8188
$postParameters = $_POST;
@@ -148,7 +155,15 @@ public function initialize(sfEventDispatcher $dispatcher, $parameters = array(),
148155
$this->setMethod(self::GET);
149156
}
150157

151-
$this->postParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($postParameters) : $postParameters;
158+
if (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc())
159+
{
160+
$this->postParameters = sfToolkit::stripslashesDeep($postParameters);
161+
}
162+
else
163+
{
164+
$this->postParameters = $postParameters;
165+
}
166+
152167
$this->parameterHolder->add($this->postParameters);
153168

154169
if ($formats = $this->getOption('formats'))
@@ -600,7 +615,14 @@ public function getCookie($name, $defaultValue = null)
600615

601616
if (isset($_COOKIE[$name]))
602617
{
603-
$retval = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_COOKIE[$name]) : $_COOKIE[$name];
618+
if (version_compare(PHP_VERSION, '5.4', '<') && get_magic_quotes_gpc())
619+
{
620+
$retval = sfToolkit::stripslashesDeep($_COOKIE[$name]);
621+
}
622+
else
623+
{
624+
$retval = $_COOKIE[$name];
625+
}
604626
}
605627

606628
return $retval;

0 commit comments

Comments
 (0)