Skip to content

Commit

Permalink
Get save handler configs from main instances
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Aug 8, 2023
1 parent 9d6615e commit 2312d83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/Debug/SessionCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,13 @@ protected function getSaveHandlerConfigs() : array
];
}
if ($this->saveHandler instanceof MemcachedHandler) {
$serverList = $this->saveHandler->getMemcached()?->getServerList();
$config['servers'] = $serverList ?: [];
$servers = [];
foreach ($config['servers'] as $server) {
$servers[] = [
'Host' => $server['host'],
'Port' => $server['port'] ?? 11211,
'Weight' => $server['weight'] ?? 0,
];
}
return [
Expand All @@ -385,10 +386,11 @@ protected function getSaveHandlerConfigs() : array
];
}
if ($this->saveHandler instanceof RedisHandler) {
$redis = $this->saveHandler->getRedis();
return [
'Host' => $config['host'],
'Port' => $config['port'],
'Timeout' => $config['timeout'],
'Host' => $redis?->getHost() ?: $config['host'],
'Port' => $redis?->getPort() ?: $config['port'],
'Timeout' => $redis?->getTimeout() ?: $config['timeout'],
'Database' => $config['database'],
'Prefix' => $config['prefix'],
'Lock Attempts' => $config['lock_attempts'],
Expand All @@ -400,9 +402,10 @@ protected function getSaveHandlerConfigs() : array
];
}
if ($this->saveHandler instanceof DatabaseHandler) {
$databaseConfig = $this->saveHandler->getDatabase()?->getConfig();
return [
'Host' => $config['host'],
'Schema' => $config['schema'],
'Host' => $databaseConfig['host'] ?? '',
'Schema' => $databaseConfig['schema'] ?? '',
'Table' => $config['table'],
'Columns' => [
[
Expand Down
3 changes: 2 additions & 1 deletion tests/Debug/SessionCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ public function saveHandlerProvider() : Generator
'host' => \getenv('MEMCACHED_HOST'),
],
[
'host' => \getenv('MEMCACHED_HOST'),
// @phpstan-ignore-next-line
'host' => \gethostbyname(\getenv('MEMCACHED_HOST')),
],
],
]),
Expand Down

0 comments on commit 2312d83

Please sign in to comment.