Skip to content

Commit

Permalink
Merge pull request #6998 from kenjis/fix-services-session
Browse files Browse the repository at this point in the history
fix: Config\Session
  • Loading branch information
kenjis authored Dec 22, 2022
2 parents feb1772 + 503ab4f commit 13d8246
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/Config/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Config;

use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Session\Handlers\BaseHandler;
use CodeIgniter\Session\Handlers\FileHandler;
use SessionHandlerInterface;

class Session extends BaseConfig
{
Expand All @@ -19,7 +19,7 @@ class Session extends BaseConfig
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
* - `CodeIgniter\Session\Handlers\RedisHandler`
*
* @phpstan-var class-string<SessionHandlerInterface>
* @phpstan-var class-string<BaseHandler>
*/
public string $driver = FileHandler::class;

Expand Down
8 changes: 6 additions & 2 deletions system/Config/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
use Config\Migrations;
use Config\Pager as PagerConfig;
use Config\Services as AppServices;
use Config\Session as SessionConfig;
use Config\Toolbar as ToolbarConfig;
use Config\Validation as ValidationConfig;
use Config\View as ViewConfig;
Expand Down Expand Up @@ -645,10 +646,13 @@ public static function session(?App $config = null, bool $getShared = true)

$logger = AppServices::logger();

$driverName = $config->sessionDriver;
/** @var SessionConfig|null $sessionConfig */
$sessionConfig = config('Session');

$driverName = $sessionConfig->driver ?? $config->sessionDriver;

if ($driverName === DatabaseHandler::class) {
$DBGroup = $config->sessionDBGroup ?? config(Database::class)->defaultGroup;
$DBGroup = $sessionConfig->DBGroup ?? $config->sessionDBGroup ?? config(Database::class)->defaultGroup;
$db = Database::connect($DBGroup);

$driver = $db->getPlatform();
Expand Down

0 comments on commit 13d8246

Please sign in to comment.