Check for required mbstring extension
[civicrm-core.git] / CRM / Utils / Check / Component / Env.php
index 38548da9b26035cec0365b8970c6e6e2b671f217..f2b9bc9773481bc8013e598d0748c945e789caf0 100644 (file)
@@ -38,13 +38,27 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component {
   public function checkPhpVersion() {
     $messages = array();
 
-    if (version_compare(phpversion(), CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER) < 0) {
+    if (version_compare(phpversion(), CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER) >= 0) {
+      $messages[] = new CRM_Utils_Check_Message(
+        __FUNCTION__,
+        ts('This system uses PHP version %1 which meets or exceeds the minimum recommendation of %2.',
+          array(
+            1 => phpversion(),
+            2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
+          )),
+        ts('PHP Up-to-Date'),
+        \Psr\Log\LogLevel::INFO,
+        'fa-server'
+      );
+    }
+    elseif (version_compare(phpversion(), CRM_Upgrade_Incremental_General::MIN_DEFECT_PHP_VER) >= 0) {
       $messages[] = new CRM_Utils_Check_Message(
         __FUNCTION__,
         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 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
+            3 => CRM_Upgrade_Incremental_General::MIN_DEFECT_PHP_VER,
           )),
         ts('PHP Out-of-Date'),
         \Psr\Log\LogLevel::NOTICE,
@@ -54,13 +68,14 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component {
     else {
       $messages[] = new CRM_Utils_Check_Message(
         __FUNCTION__,
-        ts('This system uses PHP version %1 which meets or exceeds the minimum recommendation of %2.',
+        ts('This system uses PHP version %1. CiviCRM can be installed on this version, but some specific features are known to fail or degrade. Version %3 is the bare minimum to avoid known issues, and version %2 is recommended.',
           array(
             1 => phpversion(),
             2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
+            3 => CRM_Upgrade_Incremental_General::MIN_DEFECT_PHP_VER,
           )),
-        ts('PHP Up-to-Date'),
-        \Psr\Log\LogLevel::INFO,
+        ts('PHP Out-of-Date'),
+        \Psr\Log\LogLevel::WARNING,
         'fa-server'
       );
     }
@@ -97,6 +112,8 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component {
    * @return array<CRM_Utils_Check_Message> an empty array, or a list of warnings
    */
   public function checkMysqlTime() {
+    //CRM-19115 - Always set MySQL time before checking it.
+    CRM_Core_Config::singleton()->userSystem->setMySQLTimeZone();
     $messages = array();
 
     $phpNow = date('Y-m-d H:i');
@@ -681,4 +698,23 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component {
     return $messages;
   }
 
+  /**
+   * Check for required mbstring extension
+   * @return array
+   */
+  public function checkMbstring() {
+    $messages = array();
+
+    if (!function_exists('mb_substr')) {
+      $messages[] = new CRM_Utils_Check_Message(
+        __FUNCTION__,
+        ts('The required PHP Multibyte String extension is not enabled on your server. Ask your system administrator to install it.'),
+        ts('Missing mbstring Extension'),
+        \Psr\Log\LogLevel::ERROR,
+        'fa-server'
+      );
+    }
+    return $messages;
+  }
+
 }