mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-27 19:59:56 +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
|
* @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'])
|
if (isset($conf['session_save_handler'])
|
||||||
and ($conf['session_save_handler'] == 'db')
|
and ($conf['session_save_handler'] == 'db')
|
||||||
and defined('PHPWG_INSTALLED'))
|
and defined('PHPWG_INSTALLED'))
|
||||||
{
|
{
|
||||||
session_set_save_handler(
|
// In PHP 8.4+ calling session_set_save_handler with
|
||||||
'pwg_session_open',
|
// two parameters is deprecated. To correct this,
|
||||||
'pwg_session_close',
|
// we pass a SessionHandlerInterface instance.
|
||||||
'pwg_session_read',
|
session_set_save_handler(new PwgSession());
|
||||||
'pwg_session_write',
|
|
||||||
'pwg_session_destroy',
|
|
||||||
'pwg_session_gc'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (function_exists('ini_set'))
|
if (function_exists('ini_set'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -466,13 +466,8 @@ else
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
session_set_save_handler('pwg_session_open',
|
// See include/functions_session.inc.php
|
||||||
'pwg_session_close',
|
session_set_save_handler(new PwgSession());
|
||||||
'pwg_session_read',
|
|
||||||
'pwg_session_write',
|
|
||||||
'pwg_session_destroy',
|
|
||||||
'pwg_session_gc'
|
|
||||||
);
|
|
||||||
if ( function_exists('ini_set') )
|
if ( function_exists('ini_set') )
|
||||||
{
|
{
|
||||||
ini_set('session.use_cookies', $conf['session_use_cookies']);
|
ini_set('session.use_cookies', $conf['session_use_cookies']);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue