mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-28 20:29:58 +03:00
fixes #2296 include the correct class file depending on the version of php
This commit is contained in:
parent
0645372570
commit
627aa045ed
3 changed files with 78 additions and 33 deletions
|
@ -10,39 +10,6 @@
|
||||||
* @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'))
|
||||||
|
@ -50,6 +17,17 @@ if (isset($conf['session_save_handler'])
|
||||||
// In PHP 8.4+ calling session_set_save_handler with
|
// In PHP 8.4+ calling session_set_save_handler with
|
||||||
// two parameters is deprecated. To correct this,
|
// two parameters is deprecated. To correct this,
|
||||||
// we pass a SessionHandlerInterface instance.
|
// we pass a SessionHandlerInterface instance.
|
||||||
|
// https://github.com/Piwigo/Piwigo/issues/2296
|
||||||
|
// Depending on the PHP version, we include the appropriate
|
||||||
|
// session handler class file.
|
||||||
|
if (version_compare(PHP_VERSION, '8.0.0') < 0)
|
||||||
|
{
|
||||||
|
include_once(PHPWG_ROOT_PATH.'/include/pwgsession_php7.class.php');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
include_once(PHPWG_ROOT_PATH.'/include/pwgsession.class.php');
|
||||||
|
}
|
||||||
session_set_save_handler(new PwgSession());
|
session_set_save_handler(new PwgSession());
|
||||||
|
|
||||||
if (function_exists('ini_set'))
|
if (function_exists('ini_set'))
|
||||||
|
|
33
include/pwgsession.class.php
Normal file
33
include/pwgsession.class.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
}
|
34
include/pwgsession_php7.class.php
Normal file
34
include/pwgsession_php7.class.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
// see https://php.watch/versions/8.4/session_set_save_handler-alt-signature-deprecated
|
||||||
|
// https://github.com/Piwigo/Piwigo/issues/2296
|
||||||
|
class PwgSession implements SessionHandlerInterface {
|
||||||
|
public function open($path, $name)
|
||||||
|
{
|
||||||
|
return pwg_session_open($path, $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function close()
|
||||||
|
{
|
||||||
|
return pwg_session_close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function read($id)
|
||||||
|
{
|
||||||
|
return pwg_session_read($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function write($id, $data)
|
||||||
|
{
|
||||||
|
return pwg_session_write($id, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
return pwg_session_destroy($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function gc($max_lifetime)
|
||||||
|
{
|
||||||
|
return pwg_session_gc();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue