From ee4ed198b6096ec946ca056752268adcb676d03d Mon Sep 17 00:00:00 2001 From: Thorsten Rinne Date: Fri, 15 Nov 2024 18:20:22 +0100 Subject: [PATCH] feat: removed Symfony Cookie class for now because of compatability reasons --- composer.json | 12 ++++++------ composer.lock | 4 ++-- phpmyfaq/src/phpMyFAQ/User/CurrentUser.php | 4 ++-- phpmyfaq/src/phpMyFAQ/User/UserSession.php | 18 ++++++++---------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index e0ac6764dd..67f92505e3 100644 --- a/composer.json +++ b/composer.json @@ -37,12 +37,12 @@ "symfony/config": "^7.1", "symfony/dependency-injection": "^7.1", "symfony/event-dispatcher": "^7.1", - "symfony/html-sanitizer": "^7.0", - "symfony/http-client": "^7.0", - "symfony/http-foundation": "^7.0", - "symfony/http-kernel": "^7.0", - "symfony/mailer": "^7.0", - "symfony/routing": "^7.0", + "symfony/html-sanitizer": "^7.1", + "symfony/http-client": "^7.1", + "symfony/http-foundation": "^7.1", + "symfony/http-kernel": "^7.1", + "symfony/mailer": "^7.1", + "symfony/routing": "^7.1", "symfony/uid": "^7.1", "tecnickcom/tcpdf": "~6.0", "tivie/htaccess-parser": "*", diff --git a/composer.lock b/composer.lock index 7611c50180..21ea1446db 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cdbb86190af31eab1cc79616781a6e9d", + "content-hash": "6d9da8071a92749476d385929179b982", "packages": [ { "name": "2tvenom/cborencode", @@ -7927,7 +7927,7 @@ "ext-xmlwriter": "*", "ext-zip": "*" }, - "platform-dev": [], + "platform-dev": {}, "platform-overrides": { "php": "8.2.0" }, diff --git a/phpmyfaq/src/phpMyFAQ/User/CurrentUser.php b/phpmyfaq/src/phpMyFAQ/User/CurrentUser.php index fe8a6a6cee..26e111ba4b 100644 --- a/phpmyfaq/src/phpMyFAQ/User/CurrentUser.php +++ b/phpmyfaq/src/phpMyFAQ/User/CurrentUser.php @@ -8,8 +8,8 @@ * manually. login(), getFromSession() and getFromCookie() may be combined. * * This Source Code Form is subject to the terms of the Mozilla Public License, - * * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * * obtain one at http://mozilla.org/MPL/2.0/. + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at https://mozilla.org/MPL/2.0/. * * @package phpMyFAQ * @author Lars Tiedemann diff --git a/phpmyfaq/src/phpMyFAQ/User/UserSession.php b/phpmyfaq/src/phpMyFAQ/User/UserSession.php index 3dd7aefd0d..7ca925d597 100644 --- a/phpmyfaq/src/phpMyFAQ/User/UserSession.php +++ b/phpmyfaq/src/phpMyFAQ/User/UserSession.php @@ -23,8 +23,6 @@ use phpMyFAQ\Filter; use phpMyFAQ\Network; use phpMyFAQ\Strings; -use Random\RandomException; -use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\IpUtils; use Symfony\Component\HttpFoundation\Request; @@ -235,13 +233,13 @@ public function setCookie(string $name, int|string|null $sessionId, int $timeout { $request = Request::createFromGlobals(); - Cookie::create($name) - ->withValue($sessionId ?? '') - ->withExpires($request->server->get('REQUEST_TIME') + $timeout) - ->withPath(dirname($request->server->get('SCRIPT_NAME'))) - ->withDomain(parse_url($this->configuration->getDefaultUrl(), PHP_URL_HOST)) - ->withSameSite($strict ? 'strict' : '') - ->withSecure($request->isSecure()) - ->withHttpOnly(); + setcookie($name, $sessionId ?? '', [ + 'expires' => $request->server->get('REQUEST_TIME') + $timeout, + 'path' => dirname($request->server->get('SCRIPT_NAME')), + 'domain' => parse_url($this->configuration->getDefaultUrl(), PHP_URL_HOST), + 'secure' => $request->isSecure(), + 'httponly' => true, + 'samesite' => $strict ? 'strict' : '', + ]); } }