From d42c3dc18652ad8044015903282b90fc198ff39a Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 20 Jan 2024 15:18:37 +1300 Subject: [PATCH] Add PHP version check to setup.php --- htdocs/setup.php | 14 ++++++++++++++ inc/always.php.in | 3 +++ 2 files changed, 17 insertions(+) diff --git a/htdocs/setup.php b/htdocs/setup.php index 3c465596..ff4f9ffe 100644 --- a/htdocs/setup.php +++ b/htdocs/setup.php @@ -286,6 +286,19 @@ function check_davical_version() { return $result; } +function check_php_version() { + global $c; + + $result = new CheckResult(version_compare(phpversion(), $c->minimum_php_version, '>=')); + if ( ! $result->getOK() ) { + $result->setDescription( sprintf(i18n('Minimum: %s, Currently: %s'), $c->minimum_php_version, phpversion()) ); + $result->setClass('dep_fail'); + } else { + $result->setDescription( sprintf(i18n('Passed: %s'), phpversion() . ' >= ' . $c->minimum_php_version) ); + } + return $result; + +} function check_awl_version() { global $c; @@ -337,6 +350,7 @@ function build_dependencies_table( ) { $dependencies = array( translate('Current DAViCal version ') => 'check_davical_version', + translate('PHP version ') => 'check_php_version', translate('AWL Library version ') => 'check_awl_version', translate('PHP not using Apache Filter mode') => 'check_real_php', translate('PHP PDO module available') => 'check_pdo', diff --git a/inc/always.php.in b/inc/always.php.in index 0d8ffed0..015cca8c 100644 --- a/inc/always.php.in +++ b/inc/always.php.in @@ -308,6 +308,9 @@ if ( isset($c->version_string) && preg_match( '/(\d+)\.(\d+)\.(\d+)(.*)/', $c->v @header( sprintf('Server: %d.%d', $c->code_major, $c->code_minor) ); } +// What is our minimum supported version of PHP? +$c->minimum_php_version = '5.4.0'; + /** * Force the domain name to what was in the configuration file */