From 540c3e63b5dca109952b401dbbc5c73fab84eba0 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 7 Dec 2015 15:12:59 -0500 Subject: [PATCH] CRM-17637 - Don't show up-to-date status if scheduled job is disabled --- CRM/Utils/Check/Env.php | 55 +++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/CRM/Utils/Check/Env.php b/CRM/Utils/Check/Env.php index c4861e4711..51089006bd 100644 --- a/CRM/Utils/Check/Env.php +++ b/CRM/Utils/Check/Env.php @@ -292,6 +292,24 @@ class CRM_Utils_Check_Env { public function checkVersion() { $messages = array(); + // See if the version_check job is enabled + $jobs = civicrm_api3('Job', 'get', array( + 'sequential' => 1, + 'api_action' => "version_check", + 'api_entity' => "job", + )); + $jobEnabled = !empty($jobs['values'][0]['is_active']); + if (!$jobEnabled) { + $args = empty($josb['id']) ? array('reset' => 1) : array('reset' => 1, 'action' => 'update', 'id' => $jobs['id']); + $messages[] = new CRM_Utils_Check_Message( + 'checkVersionDisabled', + ts('The check for new versions of CiviCRM has been disabled. Re-enable the scheduled job to receive important security update notifications.', array(1 => 'href="' . CRM_Utils_System::url('civicrm/admin/job', $args) . '"')), + ts('Update Check Disabled'), + \Psr\Log\LogLevel::NOTICE, + 'fa-times-circle-o' + ); + } + $vc = new CRM_Utils_VersionCheck(); $newerVersion = $vc->isNewerVersionAvailable(); @@ -325,7 +343,7 @@ class CRM_Utils_Check_Env { $message = ts('New version %1 is available. The site is currently running %2.', $vInfo); } } - else { + elseif ($jobEnabled) { $vNum = $vc->localVersion; // LTS = long-term support version if ($newerVersion['status'] == 'lts') { @@ -337,36 +355,15 @@ class CRM_Utils_Check_Env { $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' - ); - } - - // Make sure the version_check job is enabled - $jobs = civicrm_api3('Job', 'get', array( - 'sequential' => 1, - 'api_action' => "version_check", - 'api_entity' => "job", - )); - if (!$jobs['count'] || empty($jobs['values'][0]['is_active'])) { - $args = array('reset' => 1); - if (!empty($jobs['id'])) { - $args += array( - 'action' => 'update', - 'id' => $jobs['id'], + if (!empty($message)) { + $messages[] = new CRM_Utils_Check_Message( + __FUNCTION__, + $message, + $title, + $severity, + 'fa-cloud-upload' ); } - $messages[] = new CRM_Utils_Check_Message( - 'checkVersionDisabled', - ts('The check for new versions of CiviCRM has been disabled. Re-enable the scheduled job to receive important security update notifications.', array(1 => 'href="' . CRM_Utils_System::url('civicrm/admin/job', $args) . '"')), - ts('Update Check Disabled'), - \Psr\Log\LogLevel::NOTICE, - 'fa-times-circle-o' - ); } return $messages; -- 2.25.1