From 88ee7b10dc92545fd51feb1ee1b035821de4d4dd Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 15 May 2021 22:32:10 -0700 Subject: [PATCH] Add check for suitable PHP version in depends function as well --- install-script.pl | 2 +- lang/en | 4 +++- scripts-lib.pl | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/install-script.pl b/install-script.pl index 62721f134..6cce233f6 100755 --- a/install-script.pl +++ b/install-script.pl @@ -318,7 +318,7 @@ package virtual_server; &$first_print("Checking PHP version .."); $phpver = &setup_php_version($d, $script, $ver, $opts->{'path'}); if (!$phpver) { - &$second_print(".. no PHP version found!"); + &$second_print(".. no compatible PHP version found!"); exit(1); } else { diff --git a/lang/en b/lang/en index b5badd7af..0e93a1866 100644 --- a/lang/en +++ b/lang/en @@ -3986,7 +3986,7 @@ scripts_edep=This script cannot be installed, as this virtual server does not me scripts_ecommands=This script cannot be installed, as it requires the following commands : $1 scripts_eweb=Scripts can only be installed into virtual servers with a home directory and website scripts_emissing=Script does not exist! -scripts_ephpvers2=This script cannot be installed, as no PHP versions were found +scripts_ephpvers2=This script cannot be installed, as no compatible PHP versions were found scripts_return=list of scripts scripts_edownload=Download of $2 failed : $1 scripts_edownload2=Download of $1 is not an archive file - perhaps an error page @@ -4119,6 +4119,8 @@ scripts_deleted=Manually deleted scripts_inophp=Webserver support for PHP is needed scripts_inocgi=Webserver support for CGI scripts is needed scripts_iphpneed=PHP is disabled for this virtual server +scripts_iphpfullver=PHP version $1 or later is required, but this virtual server is using version $2 +scripts_iphpmaxver=PHP version below $1 is required, but this virtual server is using version $2 scripts_inoapache=Only the Apache webserver is supported scripts_needpackages=Checking for $1 required packages .. scripts_epackages=.. package installation is not supported on this system! diff --git a/scripts-lib.pl b/scripts-lib.pl index aab547328..4057f8a63 100755 --- a/scripts-lib.pl +++ b/scripts-lib.pl @@ -2750,12 +2750,28 @@ sub check_script_depends local ($script, $d, $ver, $sinfo, $phpver) = @_; local @rv; -# If the script uses PHP, make sure it's enabled for the domain if (&indexof("php", @{$script->{'uses'}}) >= 0) { + # If the script uses PHP, make sure it's enabled for the domain local $mode = &get_domain_php_mode($d); if ($mode eq "none") { push(@rv, $text{'scripts_iphpneed'}); } + + # Also check the PHP version + my $minfunc = $script->{'php_fullver_func'}; + my $maxfunc = $script->{'php_maxver_func'}; + if (defined(&$minfunc)) { + my $minver = &$minfunc($d, $ver, $sinfo); + if (&compare_versions($phpver, $minver) < 0) { + return &text('scripts_iphpfullver', $minver, $phpver); + } + } + if (defined(&$maxfunc)) { + my $maxver = &$maxfunc($d, $ver, $sinfo); + if (&compare_versions($phpver, $maxver) < 0) { + return &text('scripts_iphpmaxver', $maxver, $phpver); + } + } } # Call script's depends function