From 31e80d5a0a7bc48c1432fb7a4638e0da92de657e Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 6 Oct 2015 14:42:01 -0400 Subject: [PATCH] CRM-13823 - Add php version check --- CRM/Utils/Check/Env.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/CRM/Utils/Check/Env.php b/CRM/Utils/Check/Env.php index f462702f26..57557199db 100644 --- a/CRM/Utils/Check/Env.php +++ b/CRM/Utils/Check/Env.php @@ -34,6 +34,8 @@ */ class CRM_Utils_Check_Env { + const MINIMUM_RECOMMENDED_PHP_VERSION = '5.5'; + /** * Run some sanity checks. * @@ -41,6 +43,7 @@ class CRM_Utils_Check_Env { */ public function checkAll() { $messages = array_merge( + $this->checkPhpVersion(), $this->checkMysqlTime(), $this->checkDebug(), $this->checkOutboundMail(), @@ -56,6 +59,40 @@ class CRM_Utils_Check_Env { return $messages; } + /** + * @return array + */ + public function checkPhpVersion() { + $messages = array(); + + if (version_compare(phpversion(), self::MINIMUM_RECOMMENDED_PHP_VERSION) < 0) { + $messages[] = new CRM_Utils_Check_Message( + 'checkPhpVersion', + ts('This system uses PHP version %1. While this meets the minimum requirements for CiviCRM to function, upgrading to PHP version %2 or newer is recommended for maximum compatibility.', + array( + 1 => phpversion(), + 2 => self::MINIMUM_RECOMMENDED_PHP_VERSION, + )), + ts('PHP Out-of-Date'), + \Psr\Log\LogLevel::NOTICE + ); + } + else { + $messages[] = new CRM_Utils_Check_Message( + 'checkPhpVersion', + ts('This system uses PHP version %1 which meets or exceeds the minimum recommendation of %2.', + array( + 1 => phpversion(), + 2 => self::MINIMUM_RECOMMENDED_PHP_VERSION, + )), + ts('PHP Up-to-Date'), + \Psr\Log\LogLevel::INFO + ); + } + + return $messages; + } + /** * Check that the MySQL time settings match the PHP time settings. * -- 2.25.1