From 83f064f249edd4bae721da97704f28cef528edb2 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 5 Dec 2015 10:25:54 -0500 Subject: [PATCH] CRM-17637 - Suppress version status if not available --- CRM/Utils/Check/Env.php | 88 +++++++++++++++++++------------------- CRM/Utils/VersionCheck.php | 5 ++- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/CRM/Utils/Check/Env.php b/CRM/Utils/Check/Env.php index 574795a081..c4861e4711 100644 --- a/CRM/Utils/Check/Env.php +++ b/CRM/Utils/Check/Env.php @@ -295,55 +295,57 @@ class CRM_Utils_Check_Env { $vc = new CRM_Utils_VersionCheck(); $newerVersion = $vc->isNewerVersionAvailable(); - if ($newerVersion['version']) { - $vInfo = array( - 1 => $newerVersion['version'], - 2 => $vc->localVersion, - ); - // LTS = long-term support version - if ($newerVersion['status'] == 'lts') { - $vInfo[1] .= ' ' . ts('(long-term support)'); - } - - if ($newerVersion['upgrade'] == 'security') { - // Security - $severity = \Psr\Log\LogLevel::CRITICAL; - $title = ts('CiviCRM Security Update Required'); - $message = ts('New security release %1 is available. The site is currently running %2.', $vInfo); - } - elseif ($newerVersion['status'] == 'eol') { - // Warn about EOL - $severity = \Psr\Log\LogLevel::WARNING; - $title = ts('CiviCRM Update Needed'); - $message = ts('New version %1 is available. The site is currently running %2, which has reached its end of life.', $vInfo); + if ($vc->isInfoAvailable) { + if ($newerVersion['version']) { + $vInfo = array( + 1 => $newerVersion['version'], + 2 => $vc->localVersion, + ); + // LTS = long-term support version + if ($newerVersion['status'] == 'lts') { + $vInfo[1] .= ' ' . ts('(long-term support)'); + } + + if ($newerVersion['upgrade'] == 'security') { + // Security + $severity = \Psr\Log\LogLevel::CRITICAL; + $title = ts('CiviCRM Security Update Required'); + $message = ts('New security release %1 is available. The site is currently running %2.', $vInfo); + } + elseif ($newerVersion['status'] == 'eol') { + // Warn about EOL + $severity = \Psr\Log\LogLevel::WARNING; + $title = ts('CiviCRM Update Needed'); + $message = ts('New version %1 is available. The site is currently running %2, which has reached its end of life.', $vInfo); + } + else { + // For most new versions, just make them notice + $severity = \Psr\Log\LogLevel::NOTICE; + $title = ts('CiviCRM Update Available'); + $message = ts('New version %1 is available. The site is currently running %2.', $vInfo); + } } else { - // For most new versions, just make them notice - $severity = \Psr\Log\LogLevel::NOTICE; - $title = ts('CiviCRM Update Available'); - $message = ts('New version %1 is available. The site is currently running %2.', $vInfo); - } - } - else { - $vNum = $vc->localVersion; - // LTS = long-term support version - if ($newerVersion['status'] == 'lts') { - $vNum .= ' ' . ts('(long-term support)'); + $vNum = $vc->localVersion; + // LTS = long-term support version + if ($newerVersion['status'] == 'lts') { + $vNum .= ' ' . ts('(long-term support)'); + } + + $severity = \Psr\Log\LogLevel::INFO; + $title = ts('CiviCRM Up-to-Date'); + $message = ts('CiviCRM version %1 is up-to-date.', array(1 => $vNum)); } - $severity = \Psr\Log\LogLevel::INFO; - $title = ts('CiviCRM Up-to-Date'); - $message = ts('CiviCRM version %1 is up-to-date.', array(1 => $vNum)); + $messages[] = new CRM_Utils_Check_Message( + __FUNCTION__, + $message, + $title, + $severity, + 'fa-cloud-upload' + ); } - $messages[] = new CRM_Utils_Check_Message( - __FUNCTION__, - $message, - $title, - $severity, - 'fa-cloud-upload' - ); - // Make sure the version_check job is enabled $jobs = civicrm_api3('Job', 'get', array( 'sequential' => 1, diff --git a/CRM/Utils/VersionCheck.php b/CRM/Utils/VersionCheck.php index d7a0bcd9da..e366a5c333 100644 --- a/CRM/Utils/VersionCheck.php +++ b/CRM/Utils/VersionCheck.php @@ -59,6 +59,9 @@ class CRM_Utils_VersionCheck { */ public $versionInfo = array(); + /** @var bool */ + public $isInfoAvailable; + /** * Pingback params * @@ -90,7 +93,7 @@ class CRM_Utils_VersionCheck { // Populate remote $versionInfo from cache file $this->cacheFile = Civi::paths()->getPath(self::CACHEFILE_NAME); - $this->readCacheFile(); + $this->isInfoAvailable = $this->readCacheFile(); } /** -- 2.25.1