Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,29 @@ run-tests.log
/test/*/*/*/*.log
/test/*/*/*/*.out


# Added by horde-components QC --fix-qc-issues
# Build artifacts directory
/build/
# Composer dependencies directory
/vendor/
# Composer lock file (libraries should not commit lock files)
/composer.lock
# PHPStorm IDE settings
/.idea/
# VSCode IDE settings
/.vscode/
# Claude Code CLI cache and state
/.claude/
# Cline extension data
/.cline/
# PHP CS Fixer cache file
/.php-cs-fixer.cache
# PHPUnit result cache
/.phpunit.result.cache
# PHPUnit Cache (other)
/.phpunit.cache
# PHPStan local configuration
/phpstan.neon
# PHPStan cache directory
/.phpstan.cache/
6 changes: 4 additions & 2 deletions .horde.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ license:
uri: http://www.horde.org/licenses/lgpl21
dependencies:
required:
php: ^7.4 || ^8
php: ^8
composer:
horde/exception: ^3
horde/support: ^3
Expand All @@ -54,4 +54,6 @@ dependencies:
horde/hashtable: ^2
horde/log: ^3
horde/mongo: ^2
horde/test: ^3
keywords:
- sessions
vendor: horde
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"horde/db": "^3 || dev-FRAMEWORK_6_0",
"horde/hashtable": "^2 || dev-FRAMEWORK_6_0",
"horde/log": "^3 || dev-FRAMEWORK_6_0",
"horde/mongo": "^2 || dev-FRAMEWORK_6_0",
"horde/test": "^3 || dev-FRAMEWORK_6_0"
"horde/mongo": "^2 || dev-FRAMEWORK_6_0"
},
"suggest": {
"horde/db": "^3 || dev-FRAMEWORK_6_0",
Expand All @@ -52,6 +51,9 @@
}
},
"config": {
"allow-plugins": {}
}
}
"allow-plugins": {
"horde/horde-installer-plugin": true
}
},
"minimum-stability": "dev"
}
29 changes: 15 additions & 14 deletions lib/Horde/SessionHandler.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

/**
* This class provides the interface to the session storage backend.
*
* Copyright 2002-2017 Horde LLC (http://www.horde.org/)
* Copyright 2002-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
Expand Down Expand Up @@ -61,7 +62,7 @@ class Horde_SessionHandler implements SessionHandlerInterface
*
* @var array
*/
protected $_params = array();
protected $_params = [];

/**
* Initial session data signature.
Expand Down Expand Up @@ -99,14 +100,14 @@ class Horde_SessionHandler implements SessionHandlerInterface
* DEFAULT: No
* </pre>
*/
public function __construct(Horde_SessionHandler_Storage $storage,
array $params = array())
{
public function __construct(
Horde_SessionHandler_Storage $storage,
array $params = []
) {
$params = array_merge($this->_params, $params);

$this->_logger = isset($params['logger'])
? $params['logger']
: new Horde_Support_Stub();
$this->_logger = $params['logger']
?? new Horde_Support_Stub();
unset($params['logger']);

$this->_params = $params;
Expand Down Expand Up @@ -205,9 +206,9 @@ public function read($id): string|false
*/
public function write($id, $session_data): bool
{
if ($this->changed ||
(empty($this->_params['no_md5']) &&
($this->_sig != md5($session_data)))) {
if ($this->changed
|| (empty($this->_params['no_md5'])
&& ($this->_sig != md5($session_data)))) {
if (!$this->_storage->write($id, $session_data)) {
$this->_logger->log('Failed to write session data (' . $id . ')', 'DEBUG');
return false;
Expand Down Expand Up @@ -273,10 +274,10 @@ public function getSessionIDs()
*/
public function getSessionsInfo()
{
$info = array();
$info = [];

if (empty($this->_params['parse']) ||
!is_callable($this->_params['parse'])) {
if (empty($this->_params['parse'])
|| !is_callable($this->_params['parse'])) {
return $info;
}

Expand Down
7 changes: 3 additions & 4 deletions lib/Horde/SessionHandler/Exception.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

/**
* Exception handler for the SessionHandler package.
*
* Copyright 2010-2017 Horde LLC (http://www.horde.org/)
* Copyright 2010-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
Expand All @@ -11,6 +12,4 @@
* @category Horde
* @package SessionHandler
*/
class Horde_SessionHandler_Exception extends Horde_Exception_Wrapped
{
}
class Horde_SessionHandler_Exception extends Horde_Exception_Wrapped {}
11 changes: 5 additions & 6 deletions lib/Horde/SessionHandler/Storage.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2002-2017 Horde LLC (http://www.horde.org/)
* Copyright 2002-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
Expand Down Expand Up @@ -36,14 +37,14 @@ abstract class Horde_SessionHandler_Storage
*
* @var array
*/
protected $_params = array();
protected $_params = [];

/**
* Constructor.
*
* @param array $params Configuration parameters.
*/
public function __construct(array $params = array())
public function __construct(array $params = [])
{
$this->_params = array_merge($this->_params, $params);
}
Expand All @@ -61,9 +62,7 @@ public function __sleep()
*
* @deprecated
*/
public function setLogger(Horde_Log_Logger $log)
{
}
public function setLogger(Horde_Log_Logger $log) {}

/**
* Open the backend.
Expand Down
27 changes: 12 additions & 15 deletions lib/Horde/SessionHandler/Storage/Builtin.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

/**
* SessionHandler storage implementation for PHP's built-in session handler.
* This doesn't do any session handling itself - instead, it exists to allow
* utility features to be used with the built-in PHP handler.
*
* Copyright 2005-2017 Horde LLC (http://www.horde.org/)
* Copyright 2005-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
Expand All @@ -25,7 +26,7 @@ class Horde_SessionHandler_Storage_Builtin extends Horde_SessionHandler_Storage

/**
*/
public function __construct(array $params = array())
public function __construct(array $params = [])
{
parent::__construct($params);

Expand All @@ -37,15 +38,11 @@ public function __construct(array $params = array())

/**
*/
public function open($save_path = null, $session_name = null)
{
}
public function open($save_path = null, $session_name = null) {}

/**
*/
public function close()
{
}
/**
*/
public function close() {}

/**
*/
Expand Down Expand Up @@ -73,8 +70,8 @@ public function destroy($id)

foreach ($di as $val) {
/* Make sure we're dealing with files that start with sess_. */
if ($val->isFile() &&
($val->getFilename() == 'sess_' . $id)) {
if ($val->isFile()
&& ($val->getFilename() == 'sess_' . $id)) {
return unlink($val->getPathname());
}
}
Expand All @@ -93,7 +90,7 @@ public function gc($maxlifetime = 300)
*/
public function getSessionIDs()
{
$sessions = array();
$sessions = [];

try {
$di = new DirectoryIterator($this->_path);
Expand All @@ -103,8 +100,8 @@ public function getSessionIDs()

foreach ($di as $val) {
/* Make sure we're dealing with files that start with sess_. */
if ($val->isFile() &&
(strpos($val->getFilename(), 'sess_') === 0)) {
if ($val->isFile()
&& (strpos($val->getFilename(), 'sess_') === 0)) {
$sessions[] = substr($val->getFilename(), strlen('sess_'));
}
}
Expand Down
7 changes: 4 additions & 3 deletions lib/Horde/SessionHandler/Storage/External.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

/**
* SessionHandler storage implementation for an external save handler defined
* via configuration parameters.
*
* Copyright 2010-2017 Horde LLC (http://www.horde.org/)
* Copyright 2010-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
Expand All @@ -30,9 +31,9 @@ class Horde_SessionHandler_Storage_External extends Horde_SessionHandler_Storage
*
* @throws InvalidArgumentException
*/
public function __construct(array $params = array())
public function __construct(array $params = [])
{
foreach (array('open', 'close', 'read', 'write', 'destroy', 'gc') as $val) {
foreach (['open', 'close', 'read', 'write', 'destroy', 'gc'] as $val) {
if (!isset($params[$val])) {
throw new InvalidArgumentException('Missing parameter: ' . $val);
}
Expand Down
22 changes: 12 additions & 10 deletions lib/Horde/SessionHandler/Storage/File.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* Copyright 2010-2017 Horde LLC (http://www.horde.org/)
* Copyright 2010-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
Expand All @@ -23,7 +24,7 @@
class Horde_SessionHandler_Storage_File extends Horde_SessionHandler_Storage
{
/* File prefix. */
const PREFIX = 'horde_sh_';
public const PREFIX = 'horde_sh_';

/**
* File stream.
Expand All @@ -42,7 +43,7 @@ class Horde_SessionHandler_Storage_File extends Horde_SessionHandler_Storage
*
* @throws InvalidArgumentException
*/
public function __construct(array $params = array())
public function __construct(array $params = [])
{
if (!isset($params['path'])) {
throw new InvalidArgumentException('Missing path parameter.');
Expand Down Expand Up @@ -152,9 +153,9 @@ public function gc($maxlifetime = 300)
$expire_time = time() - $maxlifetime;

foreach ($di as $val) {
if ($val->isFile() &&
(strpos($val->getFilename(), self::PREFIX) === 0) &&
($val->getMTime() < $expire_time)) {
if ($val->isFile()
&& (strpos($val->getFilename(), self::PREFIX) === 0)
&& ($val->getMTime() < $expire_time)) {
@unlink($val->getPathname());
}
}
Expand All @@ -166,17 +167,18 @@ public function gc($maxlifetime = 300)
*/
public function getSessionIDs()
{
$ids = array();
$ids = [];

try {
$di = new DirectoryIterator($this->_params['path']);
foreach ($di as $val) {
if ($val->isFile() &&
(strpos($val->getFilename(), self::PREFIX) === 0)) {
if ($val->isFile()
&& (strpos($val->getFilename(), self::PREFIX) === 0)) {
$ids[] = substr($val->getFilename(), strlen(self::PREFIX));
}
}
} catch (UnexpectedValueException $e) {}
} catch (UnexpectedValueException $e) {
}

return $ids;
}
Expand Down
Loading
Loading