@@ -27,6 +27,12 @@ $conf = [
2727 */
2828 'debugmode' => false,
2929
30+ /**
31+ * Don't touch this value. It's used to inform the config structure has a breaking change
32+ *
33+ */
34+ 'version'=> 61
35+
3036];
3137
3238$conf['register_debuggers'] = function () {
@@ -78,6 +84,11 @@ $conf['register_debuggers'] = function () {
7884// indexed from zero upwards.
7985$server_index = 0;
8086
87+ /**
88+ * $conf['servers'] is an array that holds (at least) one server block.
89+ * @see https://github.com/HuasoFoundries/phpPgAdmin6/wiki/Config:-servers
90+ *
91+ */
8192$conf['servers'][$server_index] = [
8293 // Display name for the server on the login screen
8394 'desc' => 'PostgreSQL',
@@ -102,61 +113,9 @@ $conf['servers'][$server_index] = [
102113 // Specify the path to the database dump utilities for this server.
103114 // You can set these to '' if no dumper is available.
104115 'pg_dump_path' => '/usr/bin/pg_dump',
105- 'pg_dumpall_path' => '/usr/bin/pg_dumpall',
116+ 'pg_dumpall_path' => '/usr/bin/pg_dumpall'
106117];
107118
108- // Example for a second server (PostgreSQL for Windows)
109- /*
110- $server_index++;
111- $conf['servers'][$server_index][
112- 'desc'=> 'Test Server',
113- 'host'=> '127.0.0.1',
114- 'port'=> 5432,
115- 'sslmode'=> 'allow',
116- 'defaultdb'=> 'template1',
117- 'pg_dump_path'=> 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dump.exe',
118- 'pg_dumpall_path'=> 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dumpall.exe'
119- ];
120- */
121-
122- /* Groups definition */
123- /* Groups allow administrators to logicaly group servers together under
124- * group nodes in the left browser tree
125- *
126- * The group '0' description
127- */
128- //$conf['srv_groups'][0]['desc'] = 'group one';
129-
130- /* Add here servers indexes belonging to the group '0' seperated by comma */
131- //$conf['srv_groups'][0]['servers'] = '0,1,2';
132-
133- /* A server can belong to multi groups. Here server 1 is referenced in both
134- * 'group one' and 'group two'*/
135- //$conf['srv_groups'][1]['desc'] = 'group two';
136- //$conf['srv_groups'][1]['servers'] = '3,1';
137-
138- /* A group can be nested in one or more existing groups using the 'parents'
139- * parameter. Here the group 'group three' contains only one server and will
140- * appear as a subgroup in both 'group one' and 'group two':
141- */
142- //$conf['srv_groups'][2]['desc'] = 'group three';
143- //$conf['srv_groups'][2]['servers'] = '4';
144- //$conf['srv_groups'][2]['parents'] = '0,1';
145-
146- /* Warning: Only groups with no parents appears at the root of the tree. */
147-
148- /* You can apply specific theme depending on servers, users and databases
149- * The priority order is :
150- * * the theme defined for a server
151- * * the theme defined for a database apply over the server one
152- * * the theme defined for a user apply over the database one
153- */
154- /* Example for servers */
155- //$conf['servers'][0]['theme']['default'] = 'default';
156- /* Example for users */
157- //$conf['servers'][0]['theme']['user']['specific_user'] = 'default';
158- /* Example for databases */
159- //$conf['servers'][0]['theme']['db']['specific_db'] = 'default';
160119
161120// Default language. E.g.: 'english', 'polish', etc. See lang/ directory
162121// for all possibilities. If you specify 'auto' (the default) it will use
@@ -230,12 +189,29 @@ $conf['ajax_refresh'] = 3;
230189// If there's a config.yml in the root folder, parse it and merge its contents with $conf array
231190// see config.example.yml
232191$yamlConfigPath = implode(DIRECTORY_SEPARATOR, [__DIR__, 'config.yml']);
233- if (is_readable($yamlConfigPath) && class_exists('Symfony\Component\Yaml\Yaml')) {
192+ if (\ is_readable($yamlConfigPath) && \ class_exists('Symfony\Component\Yaml\Yaml')) {
234193 try {
235194 $yamlConfig = Symfony\Component\Yaml\Yaml::parseFile($yamlConfigPath);
236- $conf = array_merge($conf, $yamlConfig);
195+ // Servers and srv_groups must be merged beforehand
196+ $servers = $conf['servers'] ?? [];
197+ foreach ($yamlConfig['servers'] ?? [] as $index => $srv) {
198+ $servers[] = $srv;
199+ }
200+ $srv_groups = $conf['srv_groups'] ?? [];
201+ foreach ($yamlConfig['srv_groups'] ?? [] as $index => $srv_group) {
202+ $srv_groups[] = $srv;
203+ }
204+
205+ $yamlConfig['srv_groups'] = array_merge([
206+ $conf['srv_groups'] ?? [],
207+ $yamlConfig['srv_groups'] ?? [],
208+ ]);
209+ $conf = \array_merge($conf, $yamlConfig);
210+
211+ $conf['servers'] = $servers ?? [];
212+ $conf['srv_groups'] = $srv_groups ?? [];
237213 } catch (\Exception $e) {
238214 die($e->getMessage());
239- error_log($e->getTraceAsString());
215+ \ error_log($e->getTraceAsString());
240216 }
241- }
217+ }
0 commit comments