CodeIgniter 3.1.11 -> 3.4.5 (pocketarc fork) en PHP 8.3-fixes
- system/ vervangen door CodeIgniter 3.4.5 (pocketarc/codeigniter, PHP 8.2-8.5 compatibel) - config.php, mimes.php, user_agents.php en error-views bijgewerkt naar 3.4.5 - composer.json: php-constraint "^7.4 || ^8.0" zodat composer install op 8.3 werkt - PHP 8-fatals opgelost: count()/array-functies op FALSE/null, rekenen met lege strings, delen door nul, property zetten op FALSE, curly-brace string offsets, ongedefinieerde constanten, foute curl_setopt in Phantom_model::create_img - dynamic properties gedeclareerd in libraries, optionele parameters voor verplichte opgelost - vergelijkingen waar '' == 0 in PHP 8 anders uitvalt gecast naar (int) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* Copyright (c) 2019 - 2022, CodeIgniter Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,6 +30,7 @@
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||
* @copyright Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
@@ -44,9 +45,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/libraries/sessions.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
class CI_Session_redis_driver extends CI_Session_driver implements SessionHandlerInterface {
|
||||
class CI_Session_redis_driver extends CI_Session_driver implements CI_Session_driver_interface {
|
||||
|
||||
/**
|
||||
* phpRedis instance
|
||||
@@ -133,27 +134,40 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
{
|
||||
log_message('error', 'Session: No Redis save path configured.');
|
||||
}
|
||||
elseif (preg_match('#(?:tcp://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->_config['save_path'], $matches))
|
||||
elseif (preg_match('#^unix://([^\?]+)(?<options>\?.+)?$#', $this->_config['save_path'], $matches))
|
||||
{
|
||||
isset($matches[3]) OR $matches[3] = ''; // Just to avoid undefined index notices below
|
||||
$this->_config['save_path'] = array(
|
||||
'host' => $matches[1],
|
||||
'port' => empty($matches[2]) ? NULL : $matches[2],
|
||||
'password' => preg_match('#auth=([^\s&]+)#', $matches[3], $match) ? $match[1] : NULL,
|
||||
'database' => preg_match('#database=(\d+)#', $matches[3], $match) ? (int) $match[1] : NULL,
|
||||
'timeout' => preg_match('#timeout=(\d+\.\d+)#', $matches[3], $match) ? (float) $match[1] : NULL
|
||||
$save_path = array('path' => $matches[1]);
|
||||
}
|
||||
elseif (preg_match('#(?:(?:tcp|tls)://)?([^:?]+)(?:\:(\d+))?(?<options>\?.+)?#', $this->_config['save_path'], $matches))
|
||||
{
|
||||
$save_path = array(
|
||||
'host' => $matches[1],
|
||||
'port' => empty($matches[2]) ? NULL : $matches[2],
|
||||
'timeout' => 0.0 // We always pass this to Redis::connect(), so it needs to exist
|
||||
);
|
||||
|
||||
preg_match('#prefix=([^\s&]+)#', $matches[3], $match) && $this->_key_prefix = $match[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'Session: Invalid Redis save path format: '.$this->_config['save_path']);
|
||||
}
|
||||
|
||||
if ($this->_config['match_ip'] === TRUE)
|
||||
if (isset($save_path))
|
||||
{
|
||||
$this->_key_prefix .= $_SERVER['REMOTE_ADDR'].':';
|
||||
if (isset($matches['options']))
|
||||
{
|
||||
$save_path['password'] = preg_match('#auth=([^\s&]+)#', $matches['options'], $match) ? $match[1] : NULL;
|
||||
$save_path['database'] = preg_match('#database=(\d+)#', $matches['options'], $match) ? (int) $match[1] : NULL;
|
||||
$save_path['timeout'] = preg_match('#timeout=(\d+\.\d+)#', $matches['options'], $match) ? (float) $match[1] : 0.0;
|
||||
|
||||
preg_match('#prefix=([^\s&]+)#', $matches['options'], $match) && $this->_key_prefix = $match[1];
|
||||
}
|
||||
|
||||
$this->_config['save_path'] = $save_path;
|
||||
|
||||
if ($this->_config['match_ip'] === TRUE)
|
||||
{
|
||||
$this->_key_prefix .= $_SERVER['REMOTE_ADDR'].':';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,23 +190,34 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
}
|
||||
|
||||
$redis = new Redis();
|
||||
if ( ! $redis->connect($this->_config['save_path']['host'], $this->_config['save_path']['port'], $this->_config['save_path']['timeout']))
|
||||
$connected = isset($this->_config['save_path']['path'])
|
||||
? $redis->connect($this->_config['save_path']['path'])
|
||||
: $redis->connect(
|
||||
$this->_config['save_path']['host'],
|
||||
$this->_config['save_path']['port'],
|
||||
$this->_config['save_path']['timeout']
|
||||
);
|
||||
|
||||
if ($connected)
|
||||
{
|
||||
log_message('error', 'Session: Unable to connect to Redis with the configured settings.');
|
||||
}
|
||||
elseif (isset($this->_config['save_path']['password']) && ! $redis->auth($this->_config['save_path']['password']))
|
||||
{
|
||||
log_message('error', 'Session: Unable to authenticate to Redis instance.');
|
||||
}
|
||||
elseif (isset($this->_config['save_path']['database']) && ! $redis->select($this->_config['save_path']['database']))
|
||||
{
|
||||
log_message('error', 'Session: Unable to select Redis database with index '.$this->_config['save_path']['database']);
|
||||
if (isset($this->_config['save_path']['password']) && ! $redis->auth($this->_config['save_path']['password']))
|
||||
{
|
||||
log_message('error', 'Session: Unable to authenticate to Redis instance.');
|
||||
}
|
||||
elseif (isset($this->_config['save_path']['database']) && ! $redis->select($this->_config['save_path']['database']))
|
||||
{
|
||||
log_message('error', 'Session: Unable to select Redis database with index '.$this->_config['save_path']['database']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_redis = $redis;
|
||||
$this->php5_validate_id();
|
||||
return $this->_success;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_redis = $redis;
|
||||
$this->php5_validate_id();
|
||||
return $this->_success;
|
||||
log_message('error', 'Session: Unable to connect to Redis with the configured settings.');
|
||||
}
|
||||
|
||||
return $this->_failure;
|
||||
@@ -354,16 +379,32 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update Timestamp
|
||||
*
|
||||
* Update session timestamp without modifying data
|
||||
*
|
||||
* @param string $id Session ID
|
||||
* @param string $data Unknown & unused
|
||||
* @return bool
|
||||
*/
|
||||
public function updateTimestamp($id, $unknown)
|
||||
{
|
||||
return $this->_redis->{$this->_setTimeout_name}($this->_key_prefix.$id, $this->_config['expiration']);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate ID
|
||||
*
|
||||
* Checks whether a session ID record exists server-side,
|
||||
* to enforce session.use_strict_mode.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $id Session ID
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSessionId($id)
|
||||
public function validateId($id)
|
||||
{
|
||||
return (bool) $this->_redis->exists($this->_key_prefix.$id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user