Skip to content

Commit e674c04

Browse files
authored
Fix bug in v-list-sys-php (hestiacp#2205)
Due to a bug with php packages in the past that have been patched by upstream older servers still might report non installed php versions Rewrote the function so it should not happen again
1 parent 3c7be16 commit e674c04

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

bin/v-list-sys-php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ source_conf "$HESTIA/conf/hestia.conf"
2626
# JSON list function
2727
json_list() {
2828
i=1
29-
objects=$(echo "$versions" |wc -w)
29+
objects=$(echo "${versions[@]}" |wc -w)
3030
echo '['
31-
for version in $versions; do
31+
for version in "${versions[@]}"; do
3232
if [ "$i" -lt "$objects" ]; then
3333
echo -e "\t\"$version\","
3434
else
@@ -43,22 +43,22 @@ json_list() {
4343
shell_list() {
4444
echo "VERSION"
4545
echo "--------"
46-
for version in $versions; do
46+
for version in "${versions[@]}"; do
4747
echo "$version"
4848
done
4949
}
5050

5151
# PLAIN list function
5252
plain_list() {
53-
for version in $versions; do
53+
for version in "${versions[@]}"; do
5454
echo "$version"
5555
done
5656
}
5757

5858
# CSV list function
5959
csv_list() {
6060
echo "VERSION"
61-
for version in $versions; do
61+
for version in "${versions[@]}"; do
6262
echo "$version"
6363
done
6464
}
@@ -68,8 +68,12 @@ csv_list() {
6868
# Action #
6969
#----------------------------------------------------------#
7070

71+
declare -a versions;
7172
# List through /etc/php
72-
versions=$(/usr/sbin/phpquery -V);
73+
for version in /etc/php/*/fpm; do
74+
ver=$(echo "$version" | awk -F"/" '{ print $4 }');
75+
versions+=("$ver")
76+
done
7377

7478
# Listing data
7579
case $format in

bin/v-restart-service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ is_format_valid 'service' 'restart'
3737
if [ "$service" = "php-fpm" ];then
3838
service_list=''
3939
# Get installed php versions
40-
php_versions=$(/usr/sbin/phpquery -V);
40+
php_versions=$($BIN/v-list-sys-php plain);
4141
# Substitute php-fpm service name formats
4242
for version in $php_versions; do
4343
service_list="${service_list} php${version}-fpm"

0 commit comments

Comments
 (0)