diff --git a/libraries/classes/UserPreferences.php b/libraries/classes/UserPreferences.php index ed9a8b9dd6..e86127be91 100644 --- a/libraries/classes/UserPreferences.php +++ b/libraries/classes/UserPreferences.php @@ -131,7 +131,7 @@ class UserPreferences $existingPrefs = $this->load(); if (isset($existingPrefs['config_data']['2fa'])) { // This is likely a partial save from page settings - merge to preserve 2fa - $config_array = array_merge($existingPrefs['config_data'], $config_array); + $config_array['2fa'] = $existingPrefs['config_data']['2fa']; } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f923436a0b..98d8dee941 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -48750,16 +48750,6 @@ parameters: count: 1 path: test/classes/UserPreferencesTest.php - - - message: "#^Cannot access offset '2fa' on mixed\\.$#" - count: 1 - path: test/classes/UserPreferencesTest.php - - - - message: "#^Cannot access offset 'Console/Mode' on mixed\\.$#" - count: 1 - path: test/classes/UserPreferencesTest.php - - message: "#^Cannot access offset 'DisableIS' on mixed\\.$#" count: 1 @@ -48790,21 +48780,11 @@ parameters: count: 3 path: test/classes/UserPreferencesTest.php - - - message: "#^Cannot access offset 'secret' on mixed\\.$#" - count: 1 - path: test/classes/UserPreferencesTest.php - - message: "#^Cannot access offset 'server_2' on mixed\\.$#" count: 1 path: test/classes/UserPreferencesTest.php - - - message: "#^Cannot access offset 'settings' on mixed\\.$#" - count: 1 - path: test/classes/UserPreferencesTest.php - - message: "#^Cannot access offset 'ts' on mixed\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 617280f3ef..a171c3106b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -14186,9 +14186,10 @@ $allowList[$path] $excludeList[$path] - + $configData $configData + $config_array['2fa'] $prefs['config_data'][$path] $timestamp $value @@ -16451,17 +16452,12 @@ - - $resultConfig['2fa'] - $resultConfig['Console/Mode'] - $_SESSION['userconfig'] - + $_SESSION['userconfig']['db'] $_SESSION['userconfig']['ts'] - $resultConfig['2fa']['settings'] assertTrue diff --git a/test/classes/UserPreferencesTest.php b/test/classes/UserPreferencesTest.php index 7639c0868b..e2159fb14a 100644 --- a/test/classes/UserPreferencesTest.php +++ b/test/classes/UserPreferencesTest.php @@ -233,19 +233,30 @@ class UserPreferencesTest extends AbstractNetworkTestCase // Initial save with 2fa $initialConfig = [ + 'CharEditing' => 'textarea', '2fa' => ['backend' => 'application', 'settings' => ['secret' => 'thisisasecret']], - 'theme' => 'dark', + 'RowActionLinks' => 'both', + 'TableNavigationLinksMode' => 'both', ]; $this->userPreferences->save($initialConfig); // Partial save without 2fa - $partialConfig = ['Console/Mode' => 'collapse']; + $partialConfig = [ + 'CharEditing' => 'textarea', + 'TableNavigationLinksMode' => 'text', + 'Console/Mode' => 'collapse', + ]; $this->userPreferences->save($partialConfig); // Check that 2fa is still present $resultConfig = $_SESSION['userconfig']['db']; - self::assertSame('thisisasecret', $resultConfig['2fa']['settings']['secret']); - self::assertSame('collapse', $resultConfig['Console/Mode']); + $expected = [ + 'CharEditing' => 'textarea', + 'TableNavigationLinksMode' => 'text', + 'Console/Mode' => 'collapse', + '2fa' => ['backend' => 'application', 'settings' => ['secret' => 'thisisasecret']], + ]; + self::assertSame($expected, $resultConfig); } /**