Upgrade CodeIgniter 3.1.9 => 3.1.11

This commit is contained in:
2020-08-14 04:19:45 -04:00
parent dde9afa5c6
commit f473e949cb
357 changed files with 1718 additions and 1601 deletions
@@ -6,7 +6,7 @@
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2018, British Columbia Institute of Technology
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -29,8 +29,8 @@
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
* @copyright Copyright (c) 2014 - 2018, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
* @since Version 3.0.0
* @filesource
@@ -76,6 +76,33 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
*/
protected $_key_exists = FALSE;
/**
* Name of setTimeout() method in phpRedis
*
* Due to some deprecated methods in phpRedis, we need to call the
* specific methods depending on the version of phpRedis.
*
* @var string
*/
protected $_setTimeout_name;
/**
* Name of delete() method in phpRedis
*
* Due to some deprecated methods in phpRedis, we need to call the
* specific methods depending on the version of phpRedis.
*
* @var string
*/
protected $_delete_name;
/**
* Success return value of ping() method in phpRedis
*
* @var mixed
*/
protected $_ping_success;
// ------------------------------------------------------------------------
/**
@@ -88,6 +115,20 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
{
parent::__construct($params);
// Detect the names of some methods in phpRedis instance
if (version_compare(phpversion('redis'), '5', '>='))
{
$this->_setTimeout_name = 'expire';
$this->_delete_name = 'del';
$this->_ping_success = TRUE;
}
else
{
$this->_setTimeout_name = 'setTimeout';
$this->_delete_name = 'delete';
$this->_ping_success = '+PONG';
}
if (empty($this->_config['save_path']))
{
log_message('error', 'Session: No Redis save path configured.');
@@ -131,7 +172,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
{
if (empty($this->_config['save_path']))
{
return $this->_fail();
return $this->_failure;
}
$redis = new Redis();
@@ -150,12 +191,11 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
else
{
$this->_redis = $redis;
$this->php5_validate_id();
return $this->_success;
}
$this->php5_validate_id();
return $this->_fail();
return $this->_failure;
}
// ------------------------------------------------------------------------
@@ -185,7 +225,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
return $session_data;
}
return $this->_fail();
return $this->_failure;
}
// ------------------------------------------------------------------------
@@ -203,21 +243,21 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
{
if ( ! isset($this->_redis, $this->_lock_key))
{
return $this->_fail();
return $this->_failure;
}
// Was the ID regenerated?
elseif ($session_id !== $this->_session_id)
{
if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
{
return $this->_fail();
return $this->_failure;
}
$this->_key_exists = FALSE;
$this->_session_id = $session_id;
}
$this->_redis->setTimeout($this->_lock_key, 300);
$this->_redis->{$this->_setTimeout_name}($this->_lock_key, 300);
if ($this->_fingerprint !== ($fingerprint = md5($session_data)) OR $this->_key_exists === FALSE)
{
if ($this->_redis->set($this->_key_prefix.$session_id, $session_data, $this->_config['expiration']))
@@ -227,12 +267,12 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
return $this->_success;
}
return $this->_fail();
return $this->_failure;
}
return ($this->_redis->setTimeout($this->_key_prefix.$session_id, $this->_config['expiration']))
return ($this->_redis->{$this->_setTimeout_name}($this->_key_prefix.$session_id, $this->_config['expiration']))
? $this->_success
: $this->_fail();
: $this->_failure;
}
// ------------------------------------------------------------------------
@@ -249,12 +289,12 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
if (isset($this->_redis))
{
try {
if ($this->_redis->ping() === '+PONG')
if ($this->_redis->ping() === $this->_ping_success)
{
$this->_release_lock();
if ($this->_redis->close() === FALSE)
{
return $this->_fail();
return $this->_failure;
}
}
}
@@ -284,16 +324,16 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
{
if (isset($this->_redis, $this->_lock_key))
{
if (($result = $this->_redis->delete($this->_key_prefix.$session_id)) !== 1)
if (($result = $this->_redis->{$this->_delete_name}($this->_key_prefix.$session_id)) !== 1)
{
log_message('debug', 'Session: Redis::delete() expected to return 1, got '.var_export($result, TRUE).' instead.');
log_message('debug', 'Session: Redis::'.$this->_delete_name.'() expected to return 1, got '.var_export($result, TRUE).' instead.');
}
$this->_cookie_destroy();
return $this->_success;
}
return $this->_fail();
return $this->_failure;
}
// ------------------------------------------------------------------------
@@ -323,7 +363,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
* @param string $id
* @return bool
*/
public function validateId($id)
public function validateSessionId($id)
{
return (bool) $this->_redis->exists($this->_key_prefix.$id);
}
@@ -345,7 +385,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
// correct session ID.
if ($this->_lock_key === $this->_key_prefix.$session_id.':lock')
{
return $this->_redis->setTimeout($this->_lock_key, 300);
return $this->_redis->{$this->_setTimeout_name}($this->_lock_key, 300);
}
// 30 attempts to obtain a lock, in case another request already has it
@@ -359,11 +399,13 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
continue;
}
$result = ($ttl === -2)
? $this->_redis->set($lock_key, time(), array('nx', 'ex' => 300))
: $this->_redis->setex($lock_key, 300, time());
if ( ! $result)
if ($ttl === -2 && ! $this->_redis->set($lock_key, time(), array('nx', 'ex' => 300)))
{
// Sleep for 1s to wait for lock releases.
sleep(1);
continue;
}
elseif ( ! $this->_redis->setex($lock_key, 300, time()))
{
log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id);
return FALSE;
@@ -401,7 +443,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
{
if (isset($this->_redis, $this->_lock_key) && $this->_lock)
{
if ( ! $this->_redis->delete($this->_lock_key))
if ( ! $this->_redis->{$this->_delete_name}($this->_lock_key))
{
log_message('error', 'Session: Error while trying to free lock for '.$this->_lock_key);
return FALSE;