checksum_timeout - Use consistent naming
authorTim Otten <totten@civicrm.org>
Thu, 20 Aug 2015 11:14:04 +0000 (04:14 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 17 Sep 2015 22:45:00 +0000 (15:45 -0700)
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
CRM/Admin/Form/Setting/Miscellaneous.php
CRM/Contact/BAO/Contact/Utils.php
CRM/Core/BAO/ConfigSetting.php
settings/Core.setting.php
templates/CRM/Admin/Form/Setting/Miscellaneous.tpl

index 3b62810ad409e46cb948335e34e7525c02ec2a0c..49c6c6ddff99b258f6a185a0ff8ef6d9b4c5065f 100644 (file)
@@ -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'],
index 1f78d8a22f1f24a43e2913ce166d669040cd844e..215bc86344614e3602c5cfe83a635a098ba79f82 100644 (file)
@@ -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');
   }
 
   /**
index 66de04582cb3ba64ecc2f8378af5646b5aa99444..238e26dfcbe6d024f5738a668a0154143c18cc46 100644 (file)
@@ -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;
     }
 
index ddc5f16bcd7cddd9a1a10f4b7f2657cebcec3de6..4b3a7e4e4df1c0f717fbca90b635d51ceabe64dc 100644 (file)
@@ -736,6 +736,7 @@ WHERE  option_group_id = (
       'autocompleteContactSearch',
       'autocompleteContactReference',
       'checksumTimeout',
+      'checksum_timeout',
     );
   }
 
index d015b5dfe20814e676d4ecd50ced0d4f8877239b..f5c47c266aef18d4018bd917a0e1eafd551b80fb 100644 (file)
@@ -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(
index 3c768d1b090be22a1f5b409e6b46c528ef2284c9..fe742e72d0377d3b2dac4b7e378ace6896259458 100644 (file)
@@ -34,9 +34,9 @@
     </table>
 
     <table class="form-layout">
-        <tr class="crm-miscellaneous-form-block-checksumTimeout">
-            <td class="label">{$form.checksumTimeout.label}</td>
-            <td>{$form.checksumTimeout.html}<br />
+        <tr class="crm-miscellaneous-form-block-checksum_timeout">
+            <td class="label">{$form.checksum_timeout.label}</td>
+            <td>{$form.checksum_timeout.html}<br />
                 <span class="description">{ts}The number of days before a personalized (hashed) link will expire.{/ts}</span></td>
         </tr>
     </table>