Skip to content

Commit

Permalink
Remove outdated PHP conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlavtox committed May 7, 2024
1 parent 909ea5e commit 7392d3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 38 deletions.
16 changes: 0 additions & 16 deletions classes/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,22 +380,6 @@ protected function encryptAndSetCookie($cookie = null)
throw new PrestaShopException('Error during setting a cookie. Combined size of name and value cannot exceed 4096 characters. Larger cookie is not compliant with RFC 2965 and will not be accepted by the browser.');
}

/*
* The alternative signature supporting an options array is only available since
* PHP 7.3.0, before there is no support for SameSite attribute.
*/
if (PHP_VERSION_ID < 70300) {
return setcookie(
$this->_name,
$content,
$time,
$this->_path,
$this->_domain . '; SameSite=' . $this->_sameSite,
$this->_secure,
true
);
}

return setcookie(
$this->_name,
$content,
Expand Down
2 changes: 1 addition & 1 deletion classes/db/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public static function getClass()
{
$class = '';
/* @phpstan-ignore-next-line */
if (PHP_VERSION_ID >= 50200 && extension_loaded('pdo_mysql')) {
if (extension_loaded('pdo_mysql')) {
$class = 'DbPDO';
} elseif (extension_loaded('mysqli')) {
$class = 'DbMySQLi';
Expand Down
28 changes: 7 additions & 21 deletions src/Core/Session/SessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,13 @@ public function init(): void
return;
}

/*
* The alternative signature supporting an options array is only available since
* PHP 7.3.0, before there is no support for SameSite attribute.
*/
if (PHP_VERSION_ID < 70300) {
session_set_cookie_params(
$this->lifetime,
$this->path . ';SameSite=' . $this->sameSite,
'',
$this->isSecure,
true
);
} else {
session_set_cookie_params([
'lifetime' => $this->lifetime,
'path' => $this->path,
'secure' => $this->isSecure,
'httponly' => true,
'samesite' => $this->sameSite,
]);
}
session_set_cookie_params([
'lifetime' => $this->lifetime,
'path' => $this->path,
'secure' => $this->isSecure,
'httponly' => true,
'samesite' => $this->sameSite,
]);

$this->session = new Session(new PhpBridgeSessionStorage());
$this->session->start();
Expand Down

0 comments on commit 7392d3b

Please sign in to comment.