Skip to content

Commit

Permalink
🐛 fix session issues
Browse files Browse the repository at this point in the history
Signed-off-by: otengkwame <developerkwame@gmail.com>
  • Loading branch information
otengkwame committed Feb 10, 2022
1 parent 653be77 commit 04c4434
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@
"framework/"
]
},
"exclude-from-classmap": [
"framework/libraries/OldSessionWrapper.php"
],
"minimum-stability": "stable"
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@
* @subpackage Libraries
* @category Sessions
* @author Andrey Andreev
* @author Developer Kwame
* @link https://codeigniter.com/userguide3/libraries/sessions.html
*/
class CI_OldSessionWrapper implements SessionHandlerInterface
class CI_SessionWrapper implements SessionHandlerInterface
{

protected $driver;
Expand All @@ -58,32 +59,34 @@ public function __construct(CI_Session_driver_interface $driver)
$this->driver = $driver;
}

public function open($save_path, $name)
public function open($save_path, $name): bool
{
return $this->driver->open($save_path, $name);
}

public function close()
public function close(): bool
{
return $this->driver->close();
}

#[\ReturnTypeWillChange]
public function read($id)
{
return $this->driver->read($id);
}

public function write($id, $data)
public function write($id, $data): bool
{
return $this->driver->write($id, $data);
}

public function destroy($id)
public function destroy($id): bool
{
return $this->driver->destroy($id);
}

public function gc($maxlifetime)
#[\ReturnTypeWillChange]
public function gc($maxlifetime): mixed
{
return $this->driver->gc($maxlifetime);
}
Expand Down
2 changes: 1 addition & 1 deletion framework/libraries/Session/PHP8SessionWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* @author Andrey Andreev
* @link https://codeigniter.com/userguide3/libraries/sessions.html
*/
class CI_SessionWrapper implements SessionHandlerInterface
class CI_PHP8SessionWrapper implements SessionHandlerInterface
{

protected CI_Session_driver_interface $driver;
Expand Down
6 changes: 6 additions & 0 deletions framework/libraries/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ public function __construct(array $params = [])
$this->_config['_sid_regexp'] = $this->_sid_regexp;

$class = new $class($this->_config);

$wrapper = new CI_SessionWrapper($class);

if (is_php('8.0')) {
$wrapper = new CI_PHP8SessionWrapper($class);
}

if (is_php('5.4')) {
session_set_save_handler($wrapper, true);
} else {
Expand Down

0 comments on commit 04c4434

Please sign in to comment.