From b1fc1ab0dcbb27d79ced8d077c3cf33effb5f9ed Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 29 Mar 2018 13:36:52 -0700 Subject: [PATCH] systemStatusCheckResult - Migrate from settings to cache This is fundamentally an ephemeral value. Storing this in the settings table prevents one from accessing the system with a read-only database. --- CRM/Core/Invoke.php | 2 +- CRM/Utils/Check.php | 2 +- Civi/Core/Container.php | 1 + api/v3/examples/Setting/GetFields.php | 15 --------------- settings/Core.setting.php | 15 --------------- 5 files changed, 3 insertions(+), 32 deletions(-) diff --git a/CRM/Core/Invoke.php b/CRM/Core/Invoke.php index e5edcd82c9..eb2bef51af 100644 --- a/CRM/Core/Invoke.php +++ b/CRM/Core/Invoke.php @@ -350,7 +350,7 @@ class CRM_Core_Invoke { return; } // always use cached results - they will be refreshed by the session timer - $status = Civi::settings()->get('systemStatusCheckResult'); + $status = Civi::cache('checks')->get('systemStatusCheckResult'); $template->assign('footer_status_severity', $status); $template->assign('footer_status_message', CRM_Utils_Check::toStatusLabel($status)); } diff --git a/CRM/Utils/Check.php b/CRM/Utils/Check.php index 24fd07062a..57d15a741f 100644 --- a/CRM/Utils/Check.php +++ b/CRM/Utils/Check.php @@ -223,7 +223,7 @@ class CRM_Utils_Check { break; } - Civi::settings()->set('systemStatusCheckResult', $maxSeverity); + Civi::cache('checks')->set('systemStatusCheckResult', $maxSeverity); return ($max) ? $maxSeverity : $messages; } diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index c582b01b30..a137d166b5 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -163,6 +163,7 @@ class Container { $basicCaches = array( 'js_strings' => 'js_strings', 'community_messages' => 'community_messages', + 'checks' => 'checks', ); foreach ($basicCaches as $cacheSvc => $cacheGrp) { $container->setDefinition("cache.{$cacheSvc}", new Definition( diff --git a/api/v3/examples/Setting/GetFields.php b/api/v3/examples/Setting/GetFields.php index 8a4ccd83d8..32c450e058 100644 --- a/api/v3/examples/Setting/GetFields.php +++ b/api/v3/examples/Setting/GetFields.php @@ -1170,21 +1170,6 @@ function setting_getfields_expectedresult() { 'description' => '', 'help_text' => '', ), - 'systemStatusCheckResult' => array( - 'group_name' => 'CiviCRM Preferences', - 'group' => 'core', - 'name' => 'systemStatusCheckResult', - 'type' => 'Integer', - 'quick_form_type' => 'Element', - 'html_type' => 'text', - 'default' => 0, - 'add' => '4.7', - 'title' => 'systemStatusCheckResult', - 'is_domain' => 1, - 'is_contact' => 0, - 'description' => '', - 'help_text' => '', - ), 'recentItemsMaxCount' => array( 'group_name' => 'CiviCRM Preferences', 'group' => 'core', diff --git a/settings/Core.setting.php b/settings/Core.setting.php index b95baf8d0e..c95ed3d018 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -883,21 +883,6 @@ return array( 'description' => NULL, 'help_text' => NULL, ), - 'systemStatusCheckResult' => array( - 'group_name' => 'CiviCRM Preferences', - 'group' => 'core', - 'name' => 'systemStatusCheckResult', - 'type' => 'Integer', - 'quick_form_type' => 'Element', - 'html_type' => 'text', - 'default' => 0, - 'add' => '4.7', - 'title' => 'systemStatusCheckResult', - 'is_domain' => 1, - 'is_contact' => 0, - 'description' => NULL, - 'help_text' => NULL, - ), 'recentItemsMaxCount' => array( 'group_name' => 'CiviCRM Preferences', 'group' => 'core', -- 2.25.1