mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 11:19:55 +03:00
issue #2294 compatibility with PHP 8.4+ for session handling
PHP7+ to PHP 9 compatibility
This commit is contained in:
parent
dc2760c36b
commit
047a447585
2 changed files with 38 additions and 15 deletions
|
@ -10,19 +10,47 @@
|
|||
* @package functions\session
|
||||
*/
|
||||
|
||||
// see https://php.watch/versions/8.4/session_set_save_handler-alt-signature-deprecated
|
||||
class PwgSession implements SessionHandlerInterface {
|
||||
public function open(string $path, string $name): bool
|
||||
{
|
||||
return pwg_session_open($path, $name);
|
||||
}
|
||||
|
||||
public function close(): bool
|
||||
{
|
||||
return pwg_session_close();
|
||||
}
|
||||
|
||||
public function read(string $id): string
|
||||
{
|
||||
return pwg_session_read($id);
|
||||
}
|
||||
|
||||
public function write(string $id, string $data): bool
|
||||
{
|
||||
return pwg_session_write($id, $data);
|
||||
}
|
||||
|
||||
public function destroy(string $id): bool
|
||||
{
|
||||
return pwg_session_destroy($id);
|
||||
}
|
||||
|
||||
public function gc(int $max_lifetime): int
|
||||
{
|
||||
return pwg_session_gc();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($conf['session_save_handler'])
|
||||
and ($conf['session_save_handler'] == 'db')
|
||||
and defined('PHPWG_INSTALLED'))
|
||||
{
|
||||
session_set_save_handler(
|
||||
'pwg_session_open',
|
||||
'pwg_session_close',
|
||||
'pwg_session_read',
|
||||
'pwg_session_write',
|
||||
'pwg_session_destroy',
|
||||
'pwg_session_gc'
|
||||
);
|
||||
// In PHP 8.4+ calling session_set_save_handler with
|
||||
// two parameters is deprecated. To correct this,
|
||||
// we pass a SessionHandlerInterface instance.
|
||||
session_set_save_handler(new PwgSession());
|
||||
|
||||
if (function_exists('ini_set'))
|
||||
{
|
||||
|
|
|
@ -466,13 +466,8 @@ else
|
|||
}
|
||||
else
|
||||
{
|
||||
session_set_save_handler('pwg_session_open',
|
||||
'pwg_session_close',
|
||||
'pwg_session_read',
|
||||
'pwg_session_write',
|
||||
'pwg_session_destroy',
|
||||
'pwg_session_gc'
|
||||
);
|
||||
// See include/functions_session.inc.php
|
||||
session_set_save_handler(new PwgSession());
|
||||
if ( function_exists('ini_set') )
|
||||
{
|
||||
ini_set('session.use_cookies', $conf['session_use_cookies']);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue