Skip to content

Commit 6faead0

Browse files
committed
Fix /edit/server/ always says database unsupported
1 parent 656d34e commit 6faead0

File tree

3 files changed

+65
-71
lines changed

3 files changed

+65
-71
lines changed

bin/v-list-database-hosts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ json_list() {
2828
fi
2929
done
3030

31-
echo "{"
31+
echo "["
3232
for type in $(echo $DB_SYSTEM |sed -e 's/,/\n/'); do
3333
if [ -e "$VESTA/conf/$type.conf" ]; then
3434
for str in $(cat $VESTA/conf/$type.conf); do
3535
eval $str
36-
echo -n ' "'$HOST'": {
36+
echo -n ' {
3737
"HOST": "'$HOST'",
3838
"TYPE": "'$type'",
3939
"CHARSETS": "'$CHARSETS'",
@@ -54,7 +54,7 @@ json_list() {
5454
done
5555
fi
5656
done
57-
echo '}'
57+
echo ']'
5858
}
5959

6060
# SHELL list function

web/edit/server/index.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,15 @@
4646
$v_dns_cluster = 'yes';
4747
}
4848

49-
// List MySQL hosts
50-
exec (VESTA_CMD."v-list-database-hosts mysql json", $output, $return_var);
51-
$v_mysql_hosts = json_decode(implode('', $output), true);
49+
// List Database hosts
50+
exec (VESTA_CMD."v-list-database-hosts json", $output, $return_var);
51+
$db_hosts = json_decode(implode('', $output), true);
5252
unset($output);
53-
foreach ($v_mysql_hosts as $key => $value) {
54-
$v_mysql = 'yes';
55-
}
56-
57-
// List PostgreSQL hosts
58-
exec (VESTA_CMD."v-list-database-hosts pgsql json", $output, $return_var);
59-
$v_pgsql_hosts = json_decode(implode('', $output), true);
60-
unset($output);
61-
foreach ($v_pgsql_hosts as $key => $value) {
62-
$v_pgsql = 'yes';
63-
}
53+
$v_mysql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'mysql';}));
54+
$v_mysql = count($v_mysql_hosts) ? 'yes' : 'no';
55+
$v_pgsql_hosts = array_values(array_filter($db_hosts, function($host){return $host['TYPE'] === 'pgsql';}));
56+
$v_pgsql = count($v_pgsql_hosts) ? 'yes' : 'no';
57+
unset($db_hosts);
6458

6559
// List backup settings
6660
$v_backup_dir = "/backup";

0 commit comments

Comments
 (0)