From 92a8de72967da0e63f6a8f0f93c78149b8fe9463 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 20 Aug 2015 04:14:04 -0700 Subject: [PATCH] checksum_timeout - Use consistent naming This was a weird one: * The admin form rendered HTML element "checksumTimeout" but saved setting "checksum_timeout", which required workarounds. * The runtime code read the setting as "checksum_timeout". * The metadata defined setting "checksumTimeout". `prefetch` is enabled, but there's no `config_key` or `legacy_key`. I believe this means that the runtime and admin form worked (because they agreed that the name was "checksum_timeout"), but the Setting API would not work (because it used "checksumTimeout"). This revision standardizes on "checksum_timeout" on the theory that "checksum_timeout" was the actual value used at runtime. This means: * If you had configured the form and had it working correctly, it should still work correctly. * If you had a script to set "checksumTimeout" via API, then it wasn't working before, and it's still not working now. --- CRM/Admin/Form/Setting.php | 8 -------- CRM/Admin/Form/Setting/Miscellaneous.php | 4 ++-- CRM/Contact/BAO/Contact/Utils.php | 6 +----- CRM/Core/BAO/ConfigSetting.php | 1 + settings/Core.setting.php | 6 ++---- templates/CRM/Admin/Form/Setting/Miscellaneous.tpl | 6 +++--- 6 files changed, 9 insertions(+), 22 deletions(-) diff --git a/CRM/Admin/Form/Setting.php b/CRM/Admin/Form/Setting.php index 3b62810ad4..49c6c6ddff 100644 --- a/CRM/Admin/Form/Setting.php +++ b/CRM/Admin/Form/Setting.php @@ -230,14 +230,6 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { unset($params['enableComponents']); } - // save checksum timeout - if (!empty($params['checksumTimeout'])) { - CRM_Core_BAO_Setting::setItem($params['checksumTimeout'], - CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, - 'checksum_timeout' - ); - } - // verify ssl peer option if (isset($params['verifySSL'])) { CRM_Core_BAO_Setting::setItem($params['verifySSL'], diff --git a/CRM/Admin/Form/Setting/Miscellaneous.php b/CRM/Admin/Form/Setting/Miscellaneous.php index 1f78d8a22f..215bc86344 100644 --- a/CRM/Admin/Form/Setting/Miscellaneous.php +++ b/CRM/Admin/Form/Setting/Miscellaneous.php @@ -48,7 +48,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { 'maxFileSize' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'doNotAttachPDFReceipt' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'secondDegRelPermissions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, - 'checksumTimeout' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, + 'checksum_timeout' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, ); public $_uploadMaxSize; @@ -99,7 +99,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { $this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this); parent::buildQuickForm(); - $this->addRule('checksumTimeout', ts('Value should be a positive number'), 'positiveInteger'); + $this->addRule('checksum_timeout', ts('Value should be a positive number'), 'positiveInteger'); } /** diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index 66de04582c..238e26dfcb 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -201,11 +201,7 @@ WHERE id IN ( $idString ) } if (!$live) { - $days = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, - 'checksum_timeout', - NULL, - 7 - ); + $days = Civi::settings()->get('checksum_timeout'); $live = 24 * $days; } diff --git a/CRM/Core/BAO/ConfigSetting.php b/CRM/Core/BAO/ConfigSetting.php index ddc5f16bcd..4b3a7e4e4d 100644 --- a/CRM/Core/BAO/ConfigSetting.php +++ b/CRM/Core/BAO/ConfigSetting.php @@ -736,6 +736,7 @@ WHERE option_group_id = ( 'autocompleteContactSearch', 'autocompleteContactReference', 'checksumTimeout', + 'checksum_timeout', ); } diff --git a/settings/Core.setting.php b/settings/Core.setting.php index d015b5dfe2..f5c47c266a 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -520,12 +520,10 @@ return array( 'description' => NULL, 'help_text' => NULL, ), - 'checksumTimeout' => array( + 'checksum_timeout' => array( 'group_name' => 'CiviCRM Preferences', 'group' => 'core', - 'name' => 'checksumTimeout', - 'prefetch' => 1, - // prefetch causes it to be cached in config settings. Usually this is a transitional setting. Some things like urls are permanent. Remove this comment if you have assessed & it should be permanent + 'name' => 'checksum_timeout', 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_attributes' => array( diff --git a/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl b/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl index 3c768d1b09..fe742e72d0 100644 --- a/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl +++ b/templates/CRM/Admin/Form/Setting/Miscellaneous.tpl @@ -34,9 +34,9 @@ - - - + +
{$form.checksumTimeout.label}{$form.checksumTimeout.html}
+
{$form.checksum_timeout.label}{$form.checksum_timeout.html}
{ts}The number of days before a personalized (hashed) link will expire.{/ts}
-- 2.25.1