Skip to content

Commit 17ea1c6

Browse files
authored
Fix Redis session driver returning success on failed connection.
The open() method in Session_redis_driver returns $this->_success even when Redis::connect() fails (the else branch on a failed connection). This causes PHP's session_start() to believe the handler is ready, but subsequent read() calls fail, producing: session_start(): Failed to read session data: user (path: /var/lib/php/sessions) This was originally reported and fixed in the upstream bcit-ci/CodeIgniter repo: Issue: bcit-ci#5779 PR: bcit-ci#5781 The fix was merged into CI3 for the 3.1.11 milestone but appears to have been lost when the 3.2.0-dev branch was created, which this fork is based on. The fix changes the failed-connection else branch to log an error and fall through to return $this->_failure instead of incorrectly returning $this->_success.
1 parent 6ff5717 commit 17ea1c6

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

system/libraries/Session/drivers/Session_redis_driver.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,7 @@ public function open($save_path, $name)
217217
}
218218
else
219219
{
220-
$this->_redis = $redis;
221-
$this->php5_validate_id();
222-
return $this->_success;
220+
log_message('error', 'Session: Unable to connect to Redis with the configured settings.');
223221
}
224222

225223
return $this->_failure;

0 commit comments

Comments
 (0)