@@ -100,13 +100,98 @@ class Config
100100 /** @var array<string,string|null> $tempDir */
101101 private static array $ tempDir = [];
102102
103+ private bool $ hasSelectedServer = false ;
104+
105+ /**
106+ * @psalm-var array{
107+ * host: string,
108+ * port: string,
109+ * socket: string,
110+ * ssl: bool,
111+ * ssl_key: string|null,
112+ * ssl_cert: string|null,
113+ * ssl_ca: string|null,
114+ * ssl_ca_path: string|null,
115+ * ssl_ciphers: string|null,
116+ * ssl_verify: bool,
117+ * compress: bool,
118+ * controlhost: string,
119+ * controlport: string,
120+ * controluser: string,
121+ * controlpass: string,
122+ * control_socket: string|null,
123+ * control_ssl: bool|null,
124+ * control_ssl_key: string|null,
125+ * control_ssl_cert: string|null,
126+ * control_ssl_ca: string|null,
127+ * control_ssl_ca_path: string|null,
128+ * control_ssl_ciphers: string|null,
129+ * control_ssl_verify: bool|null,
130+ * control_compress: bool|null,
131+ * control_hide_connection_errors: bool|null,
132+ * auth_type: non-empty-string,
133+ * auth_http_realm: string,
134+ * user: string,
135+ * password: string,
136+ * SignonSession: string,
137+ * SignonCookieParams: array{
138+ * lifetime: int<0, max>,
139+ * path: string,
140+ * domain: string,
141+ * secure: bool,
142+ * httponly: bool,
143+ * samesite?: 'Lax'|'Strict',
144+ * },
145+ * SignonScript: string,
146+ * SignonURL: string,
147+ * LogoutURL: string,
148+ * only_db: string|string[],
149+ * hide_db: string,
150+ * verbose: string,
151+ * pmadb: string,
152+ * bookmarktable: string|false,
153+ * relation: string|false,
154+ * table_info: string|false,
155+ * table_coords: string|false,
156+ * pdf_pages: string|false,
157+ * column_info: string|false,
158+ * history: string|false,
159+ * recent: string|false,
160+ * favorite: string|false,
161+ * table_uiprefs: string|false,
162+ * tracking: string|false,
163+ * userconfig: string|false,
164+ * users: string|false,
165+ * usergroups: string|false,
166+ * navigationhiding: string|false,
167+ * savedsearches: string|false,
168+ * central_columns: string|false,
169+ * designer_settings: string|false,
170+ * export_templates: string|false,
171+ * MaxTableUiprefs: int<1, max>,
172+ * SessionTimeZone: string,
173+ * AllowRoot: bool,
174+ * AllowNoPassword: bool,
175+ * AllowDeny: array{order: ''|'deny,allow'|'allow,deny'|'explicit', rules: string[]},
176+ * DisableIS: bool,
177+ * tracking_version_auto_create: bool,
178+ * tracking_default_statements: string,
179+ * tracking_add_drop_view: bool,
180+ * tracking_add_drop_table: bool,
181+ * tracking_add_drop_database: bool,
182+ * hide_connection_errors: bool,
183+ * }
184+ */
185+ public array $ selectedServer ;
186+
103187 public function __construct ()
104188 {
105189 $ this ->config = new Settings ([]);
106190 $ config = $ this ->config ->asArray ();
107191 $ this ->default = $ config ;
108192 $ this ->settings = $ config ;
109193 $ this ->baseSettings = $ config ;
194+ $ this ->selectedServer = (new Server ())->asArray ();
110195 }
111196
112197 public static function getInstance (): self
@@ -428,6 +513,11 @@ public function loadUserPreferences(ThemeManager $themeManager, bool $isMinimumC
428513 $ this ->set ('user_preferences ' , $ _SESSION ['cache ' ][$ cacheKey ]['userprefs_type ' ]);
429514 $ this ->set ('user_preferences_mtime ' , $ _SESSION ['cache ' ][$ cacheKey ]['userprefs_mtime ' ]);
430515
516+ if (isset ($ configData ['Server ' ]) && is_array ($ configData ['Server ' ])) {
517+ $ serverConfig = array_replace_recursive ($ this ->selectedServer , $ configData ['Server ' ]);
518+ $ this ->selectedServer = (new Server ($ serverConfig ))->asArray ();
519+ }
520+
431521 // load config array
432522 $ this ->settings = array_replace_recursive ($ this ->settings , $ configData );
433523 $ GLOBALS ['cfg ' ] = array_replace_recursive ($ GLOBALS ['cfg ' ], $ configData );
@@ -1074,12 +1164,18 @@ public function selectServer(mixed $serverParamFromRequest): int
10741164 * and '$this->settings['ServerDefault'] = 0' is set.
10751165 */
10761166 if (isset ($ this ->config ->Servers [$ serverNumber ])) {
1077- $ this ->settings ['Server ' ] = $ this ->config ->Servers [$ serverNumber ]->asArray ();
1167+ $ this ->hasSelectedServer = true ;
1168+ $ this ->selectedServer = $ this ->config ->Servers [$ serverNumber ]->asArray ();
1169+ $ this ->settings ['Server ' ] = $ this ->selectedServer ;
10781170 } elseif (isset ($ this ->config ->Servers [$ this ->config ->ServerDefault ])) {
1171+ $ this ->hasSelectedServer = true ;
10791172 $ serverNumber = $ this ->config ->ServerDefault ;
1080- $ this ->settings ['Server ' ] = $ this ->config ->Servers [$ this ->config ->ServerDefault ]->asArray ();
1173+ $ this ->selectedServer = $ this ->config ->Servers [$ this ->config ->ServerDefault ]->asArray ();
1174+ $ this ->settings ['Server ' ] = $ this ->selectedServer ;
10811175 } else {
1176+ $ this ->hasSelectedServer = false ;
10821177 $ serverNumber = 0 ;
1178+ $ this ->selectedServer = (new Server ())->asArray ();
10831179 $ this ->settings ['Server ' ] = [];
10841180 }
10851181
@@ -1190,8 +1286,8 @@ public function getSettings(): Settings
11901286 return $ this ->config ;
11911287 }
11921288
1193- public function getCurrentServer (): Server | null
1289+ public function hasSelectedServer (): bool
11941290 {
1195- return $ this ->config -> Servers [ $ this -> server ] ?? null ;
1291+ return $ this ->hasSelectedServer ;
11961292 }
11971293}
0 commit comments