Upgrade CodeIgniter 3.1.9 => 3.1.11
This commit is contained in:
@@ -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 2.0.0
|
||||
* @filesource
|
||||
|
||||
@@ -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,7 +29,7 @@
|
||||
* @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/)
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
|
||||
@@ -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
|
||||
@@ -115,13 +115,13 @@ abstract class CI_Session_driver implements SessionHandlerInterface {
|
||||
/**
|
||||
* PHP 5.x validate ID
|
||||
*
|
||||
* Enforces session.use_strict_mode on PHP 5.x (7+ does it by itself)
|
||||
* Enforces session.use_strict_mode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function php5_validate_id()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70000 && isset($_COOKIE[$this->_config['cookie_name']]) && ! $this->validateId($_COOKIE[$this->_config['cookie_name']]))
|
||||
if (isset($_COOKIE[$this->_config['cookie_name']]) && ! $this->validateSessionId($_COOKIE[$this->_config['cookie_name']]))
|
||||
{
|
||||
unset($_COOKIE[$this->_config['cookie_name']]);
|
||||
}
|
||||
@@ -184,25 +184,4 @@ abstract class CI_Session_driver implements SessionHandlerInterface {
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fail
|
||||
*
|
||||
* Drivers other than the 'files' one don't (need to) use the
|
||||
* session.save_path INI setting, but that leads to confusing
|
||||
* error messages emitted by PHP when open() or write() fail,
|
||||
* as the message contains session.save_path ...
|
||||
* To work around the problem, the drivers will call this method
|
||||
* so that the INI is set just in time for the error message to
|
||||
* be properly generated.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _fail()
|
||||
{
|
||||
ini_set('session.save_path', config_item('sess_save_path'));
|
||||
return $this->_failure;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -130,7 +130,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
{
|
||||
if (empty($this->_db->conn_id) && ! $this->_db->db_connect())
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->php5_validate_id();
|
||||
@@ -150,48 +150,47 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
*/
|
||||
public function read($session_id)
|
||||
{
|
||||
if ($this->_get_lock($session_id) !== FALSE)
|
||||
if ($this->_get_lock($session_id) === FALSE)
|
||||
{
|
||||
// Prevent previous QB calls from messing with our queries
|
||||
$this->_db->reset_query();
|
||||
|
||||
// Needed by write() to detect session_regenerate_id() calls
|
||||
$this->_session_id = $session_id;
|
||||
|
||||
$this->_db
|
||||
->select('data')
|
||||
->from($this->_config['save_path'])
|
||||
->where('id', $session_id);
|
||||
|
||||
if ($this->_config['match_ip'])
|
||||
{
|
||||
$this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
|
||||
if ( ! ($result = $this->_db->get()) OR ($result = $result->row()) === NULL)
|
||||
{
|
||||
// PHP7 will reuse the same SessionHandler object after
|
||||
// ID regeneration, so we need to explicitly set this to
|
||||
// FALSE instead of relying on the default ...
|
||||
$this->_row_exists = FALSE;
|
||||
$this->_fingerprint = md5('');
|
||||
return '';
|
||||
}
|
||||
|
||||
// PostgreSQL's variant of a BLOB datatype is Bytea, which is a
|
||||
// PITA to work with, so we use base64-encoded data in a TEXT
|
||||
// field instead.
|
||||
$result = ($this->_platform === 'postgre')
|
||||
? base64_decode(rtrim($result->data))
|
||||
: $result->data;
|
||||
|
||||
$this->_fingerprint = md5($result);
|
||||
$this->_row_exists = TRUE;
|
||||
return $result;
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_fingerprint = md5('');
|
||||
return '';
|
||||
// Prevent previous QB calls from messing with our queries
|
||||
$this->_db->reset_query();
|
||||
|
||||
// Needed by write() to detect session_regenerate_id() calls
|
||||
$this->_session_id = $session_id;
|
||||
|
||||
$this->_db
|
||||
->select('data')
|
||||
->from($this->_config['save_path'])
|
||||
->where('id', $session_id);
|
||||
|
||||
if ($this->_config['match_ip'])
|
||||
{
|
||||
$this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
|
||||
if ( ! ($result = $this->_db->get()) OR ($result = $result->row()) === NULL)
|
||||
{
|
||||
// PHP7 will reuse the same SessionHandler object after
|
||||
// ID regeneration, so we need to explicitly set this to
|
||||
// FALSE instead of relying on the default ...
|
||||
$this->_row_exists = FALSE;
|
||||
$this->_fingerprint = md5('');
|
||||
return '';
|
||||
}
|
||||
|
||||
// PostgreSQL's variant of a BLOB datatype is Bytea, which is a
|
||||
// PITA to work with, so we use base64-encoded data in a TEXT
|
||||
// field instead.
|
||||
$result = ($this->_platform === 'postgre')
|
||||
? base64_decode(rtrim($result->data))
|
||||
: $result->data;
|
||||
|
||||
$this->_fingerprint = md5($result);
|
||||
$this->_row_exists = TRUE;
|
||||
return $result;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -215,7 +214,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
{
|
||||
if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_row_exists = FALSE;
|
||||
@@ -223,7 +222,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
}
|
||||
elseif ($this->_lock === FALSE)
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
if ($this->_row_exists === FALSE)
|
||||
@@ -242,7 +241,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_db->where('id', $session_id);
|
||||
@@ -265,7 +264,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -280,7 +279,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
public function close()
|
||||
{
|
||||
return ($this->_lock && ! $this->_release_lock())
|
||||
? $this->_fail()
|
||||
? $this->_failure
|
||||
: $this->_success;
|
||||
}
|
||||
|
||||
@@ -309,7 +308,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
|
||||
if ( ! $this->_db->delete($this->_config['save_path']))
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +318,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -339,7 +338,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
|
||||
return ($this->_db->delete($this->_config['save_path'], 'timestamp < '.(time() - $maxlifetime)))
|
||||
? $this->_success
|
||||
: $this->_fail();
|
||||
: $this->_failure;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -353,7 +352,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
public function validateId($id)
|
||||
public function validateSessionId($id)
|
||||
{
|
||||
// Prevent previous QB calls from messing with our queries
|
||||
$this->_db->reset_query();
|
||||
|
||||
@@ -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
|
||||
@@ -135,12 +135,14 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
{
|
||||
if ( ! mkdir($save_path, 0700, TRUE))
|
||||
{
|
||||
throw new Exception("Session: Configured save path '".$this->_config['save_path']."' is not a directory, doesn't exist or cannot be created.");
|
||||
log_message('error', "Session: Configured save path '".$this->_config['save_path']."' is not a directory, doesn't exist or cannot be created.");
|
||||
return $this->_failure;
|
||||
}
|
||||
}
|
||||
elseif ( ! is_writable($save_path))
|
||||
{
|
||||
throw new Exception("Session: Configured save path '".$this->_config['save_path']."' is not writable by the PHP process.");
|
||||
log_message('error', "Session: Configured save path '".$this->_config['save_path']."' is not writable by the PHP process.");
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_config['save_path'] = $save_path;
|
||||
@@ -402,9 +404,11 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
public function validateId($id)
|
||||
public function validateSessionId($id)
|
||||
{
|
||||
return is_file($this->_file_path.$id);
|
||||
$result = is_file($this->_file_path.$id);
|
||||
clearstatcache(TRUE, $this->_file_path.$id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -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
|
||||
@@ -117,7 +117,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
{
|
||||
$this->_memcached = NULL;
|
||||
log_message('error', 'Session: Invalid Memcached save path format: '.$this->_config['save_path']);
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
foreach ($matches as $match)
|
||||
@@ -142,7 +142,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
if (empty($server_list))
|
||||
{
|
||||
log_message('error', 'Session: Memcached server pool is empty.');
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->php5_validate_id();
|
||||
@@ -172,7 +172,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $session_data;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -190,14 +190,14 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
{
|
||||
if ( ! isset($this->_memcached, $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->_fingerprint = md5('');
|
||||
@@ -215,7 +215,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
elseif (
|
||||
$this->_memcached->touch($key, $this->_config['expiration'])
|
||||
@@ -225,7 +225,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -244,14 +244,14 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
$this->_release_lock();
|
||||
if ( ! $this->_memcached->quit())
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_memcached = NULL;
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -273,7 +273,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -303,9 +303,9 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
public function validateId($id)
|
||||
public function validateSessionId($id)
|
||||
{
|
||||
$this->_memcached-get($this->_key_prefix.$id);
|
||||
$this->_memcached->get($this->_key_prefix.$id);
|
||||
return ($this->_memcached->getResultCode() === Memcached::RES_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user