diff --git a/src/Debug/SessionCollector.php b/src/Debug/SessionCollector.php index 5eeb809..43ef7bc 100644 --- a/src/Debug/SessionCollector.php +++ b/src/Debug/SessionCollector.php @@ -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 [ @@ -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'], @@ -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' => [ [ diff --git a/tests/Debug/SessionCollectorTest.php b/tests/Debug/SessionCollectorTest.php index 87c5676..7eeb5fb 100644 --- a/tests/Debug/SessionCollectorTest.php +++ b/tests/Debug/SessionCollectorTest.php @@ -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')), ], ], ]),