diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 241ab67c06..a4019da3bb 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -16885,7 +16885,7 @@ parameters:
path: tests/unit/UtilTest.php
-
- message: '#^Cannot access offset ''server_2'' on mixed\.$#'
+ message: '#^Cannot access offset ''server_2_'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 4
path: tests/unit/UtilTest.php
@@ -16896,12 +16896,6 @@ parameters:
count: 2
path: tests/unit/UtilTest.php
- -
- message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\.$#'
- identifier: assign.propertyType
- count: 1
- path: tests/unit/UtilTest.php
-
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16963,7 +16957,7 @@ parameters:
path: tests/unit/Utils/SessionCacheTest.php
-
- message: '#^Cannot access offset ''server_2'' on mixed\.$#'
+ message: '#^Cannot access offset ''server_2_'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 4
path: tests/unit/Utils/SessionCacheTest.php
@@ -16992,12 +16986,6 @@ parameters:
count: 2
path: tests/unit/Utils/SessionCacheTest.php
- -
- message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\.$#'
- identifier: assign.propertyType
- count: 5
- path: tests/unit/Utils/SessionCacheTest.php
-
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index f85d278bac..e3a8bac908 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -10826,20 +10826,17 @@
-
- selectedServer]]>
-
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -10912,24 +10909,17 @@
-
- selectedServer]]>
- selectedServer]]>
- selectedServer]]>
- selectedServer]]>
- selectedServer]]>
-
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/src/Utils/SessionCache.php b/src/Utils/SessionCache.php
index facbba81c1..712d7d6f7f 100644
--- a/src/Utils/SessionCache.php
+++ b/src/Utils/SessionCache.php
@@ -14,11 +14,8 @@ final class SessionCache
$key = 'server_' . Current::$server;
$config = Config::getInstance();
- if (isset($config->selectedServer['user'])) {
- return $key . '_' . $config->selectedServer['user'];
- }
- return $key;
+ return $key . '_' . $config->selectedServer['user'];
}
public static function has(string $name): bool
diff --git a/tests/unit/UtilTest.php b/tests/unit/UtilTest.php
index f24fccf29b..d307a63e12 100644
--- a/tests/unit/UtilTest.php
+++ b/tests/unit/UtilTest.php
@@ -104,17 +104,17 @@ class UtilTest extends AbstractTestCase
public function testClearUserCache(): void
{
- Config::getInstance()->selectedServer['user'] = null;
+ Config::getInstance()->selectedServer['user'] = '';
Current::$server = 2;
SessionCache::set('is_superuser', 'yes');
- self::assertSame('yes', $_SESSION['cache']['server_2']['is_superuser']);
+ self::assertSame('yes', $_SESSION['cache']['server_2_']['is_superuser']);
SessionCache::set('mysql_cur_user', 'mysql');
- self::assertSame('mysql', $_SESSION['cache']['server_2']['mysql_cur_user']);
+ self::assertSame('mysql', $_SESSION['cache']['server_2_']['mysql_cur_user']);
Util::clearUserCache();
- self::assertArrayNotHasKey('is_superuser', $_SESSION['cache']['server_2']);
- self::assertArrayNotHasKey('mysql_cur_user', $_SESSION['cache']['server_2']);
+ self::assertArrayNotHasKey('is_superuser', $_SESSION['cache']['server_2_']);
+ self::assertArrayNotHasKey('mysql_cur_user', $_SESSION['cache']['server_2_']);
}
/**
diff --git a/tests/unit/Utils/SessionCacheTest.php b/tests/unit/Utils/SessionCacheTest.php
index 07b762df5e..ce8ba61109 100644
--- a/tests/unit/Utils/SessionCacheTest.php
+++ b/tests/unit/Utils/SessionCacheTest.php
@@ -16,7 +16,7 @@ class SessionCacheTest extends TestCase
public function testGet(): void
{
$_SESSION = [];
- Config::getInstance()->selectedServer['user'] = null;
+ Config::getInstance()->selectedServer['user'] = '';
SessionCache::set('test_data', 5);
SessionCache::set('test_data_2', 5);
@@ -29,35 +29,35 @@ class SessionCacheTest extends TestCase
public function testRemove(): void
{
$_SESSION = [];
- Config::getInstance()->selectedServer['user'] = null;
+ Config::getInstance()->selectedServer['user'] = '';
Current::$server = 2;
SessionCache::set('test_data', 25);
SessionCache::set('test_data_2', 25);
SessionCache::remove('test_data');
- self::assertArrayNotHasKey('test_data', $_SESSION['cache']['server_2']);
+ self::assertArrayNotHasKey('test_data', $_SESSION['cache']['server_2_']);
SessionCache::remove('test_data_2');
- self::assertArrayNotHasKey('test_data_2', $_SESSION['cache']['server_2']);
+ self::assertArrayNotHasKey('test_data_2', $_SESSION['cache']['server_2_']);
}
public function testSet(): void
{
$_SESSION = [];
- Config::getInstance()->selectedServer['user'] = null;
+ Config::getInstance()->selectedServer['user'] = '';
Current::$server = 2;
SessionCache::set('test_data', 25);
SessionCache::set('test_data', 5);
- self::assertSame(5, $_SESSION['cache']['server_2']['test_data']);
+ self::assertSame(5, $_SESSION['cache']['server_2_']['test_data']);
SessionCache::set('test_data_3', 3);
- self::assertSame(3, $_SESSION['cache']['server_2']['test_data_3']);
+ self::assertSame(3, $_SESSION['cache']['server_2_']['test_data_3']);
}
public function testHas(): void
{
$_SESSION = [];
- Config::getInstance()->selectedServer['user'] = null;
+ Config::getInstance()->selectedServer['user'] = '';
SessionCache::set('test_data', 5);
SessionCache::set('test_data_2', 5);
@@ -74,16 +74,16 @@ class SessionCacheTest extends TestCase
public function testKeyWithoutUser(): void
{
$_SESSION = [];
- Config::getInstance()->selectedServer['user'] = null;
+ Config::getInstance()->selectedServer['user'] = '';
Current::$server = 123;
SessionCache::set('test_data', 5);
self::assertArrayHasKey('cache', $_SESSION);
self::assertIsArray($_SESSION['cache']);
- self::assertArrayHasKey('server_123', $_SESSION['cache']);
- self::assertIsArray($_SESSION['cache']['server_123']);
- self::assertArrayHasKey('test_data', $_SESSION['cache']['server_123']);
- self::assertSame(5, $_SESSION['cache']['server_123']['test_data']);
+ self::assertArrayHasKey('server_123_', $_SESSION['cache']);
+ self::assertIsArray($_SESSION['cache']['server_123_']);
+ self::assertArrayHasKey('test_data', $_SESSION['cache']['server_123_']);
+ self::assertSame(5, $_SESSION['cache']['server_123_']['test_data']);
}
public function testKeyWithUser(): void