CRM-18958 add setting to control addion of limit to the dedupe screen.
authoreileen <emcnaughton@wikimedia.org>
Sat, 25 Jun 2016 02:19:53 +0000 (14:19 +1200)
committereileen <emcnaughton@wikimedia.org>
Sat, 25 Jun 2016 02:35:27 +0000 (14:35 +1200)
We have struggled to find a compromise between the needs of larger sites not to crash when deduping & the UI experience of a 'batch' not being a batch - ie. finding duplicates for the first 1000 contacts could result in 67 or 6700. In discussion it was clear that even if we agreed on a UI to make this work the default for a large site (e.g 1000 to prevent crashes) was different to what would work for a small site - so I concluded we would need a setting. Given that it seemed to make sense to focus on adding the setting, which would provide the immediate protection needed for larger sites without compromising UI on small sites, and to put the time into that rather than solving the now less important batchin issue.

Note I did some tidy up on the settings form code too...

CRM/Admin/Form/Setting.php
CRM/Admin/Form/Setting/Miscellaneous.php
CRM/Contact/Form/DedupeFind.php
settings/Core.setting.php
templates/CRM/Admin/Form/Setting/Miscellaneous.tpl

index 3f1e648ec0f8e10ee6cc4b6ce08f69c899ea316a..7a6b91b36f09079505791b4dfe23db518f41c080 100644 (file)
@@ -95,6 +95,7 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
       )
     );
 
+    $descriptions = array();
     foreach ($this->_settings as $setting => $group) {
       $settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting));
       $props = $settingMetaData['values'][$setting];
@@ -135,6 +136,8 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
         else {
           $this->$add($setting, ts($props['title']));
         }
+        // Migrate to using an array as easier in smart...
+        $descriptions[$setting] = ts($props['description']);
         $this->assign("{$setting}_description", ts($props['description']));
         if ($setting == 'max_attachments') {
           //temp hack @todo fix to get from metadata
@@ -147,6 +150,7 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
 
       }
     }
+    $this->assign('setting_descriptions', $descriptions);
   }
 
   /**
index e481b724a7fc013bc7ad0f5f5884f18d1c4895b4..68f68d15a2f2a4ad24405064f0b5ce981a9b32d4 100644 (file)
@@ -52,6 +52,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
     'wkhtmltopdfPath' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     'recentItemsMaxCount' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     'recentItemsProviders' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
+    'dedupe_default_limit' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
   );
 
   public $_uploadMaxSize;
@@ -60,10 +61,20 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
    * Basic setup.
    */
   public function preProcess() {
-    $config = CRM_Core_Config::singleton();
     $this->_uploadMaxSize = (int) ini_get('upload_max_filesize');
     // check for post max size
     CRM_Utils_Number::formatUnitSize(ini_get('post_max_size'), TRUE);
+    // This is a temp hack for the fact we really don't need to hard-code each setting in the tpl but
+    // we haven't worked through NOT doing that. These settings have been un-hardcoded.
+    $this->assign('pure_config_settings', array(
+      'empoweredBy',
+      'max_attachments',
+      'maxFileSize',
+      'secondDegRelPermissions',
+      'recentItemsMaxCount',
+      'recentItemsProviders',
+      'dedupe_default_limit',
+    ));
   }
 
   /**
index a6717bc3051b76e0e3c2335d8f50130284ed7835..966ce55714b406d08ce3507222b6f65b088eb08c 100644 (file)
@@ -51,7 +51,9 @@ class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form {
     $groupList = array('' => ts('- All Contacts -')) + CRM_Core_PseudoConstant::nestedGroup();
 
     $this->add('select', 'group_id', ts('Select Group'), $groupList, FALSE, array('class' => 'crm-select2 huge'));
-    $this->add('text', 'limit', ts('No of contacts to find matches for '));
+    if (Civi::settings()->get('dedupe_default_limit')) {
+      $this->add('text', 'limit', ts('No of contacts to find matches for '));
+    }
     $this->addButtons(array(
         array(
           'type' => 'next',
@@ -70,7 +72,7 @@ class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form {
   }
 
   public function setDefaultValues() {
-    $this->_defaults['limit'] = 1000;
+    $this->_defaults['limit'] = Civi::settings()->get('dedupe_default_limit');
     return $this->_defaults;
   }
 
@@ -89,7 +91,7 @@ class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form {
       $url .= "&gid={$values['group_id']}";
     }
 
-    if ($values['limit']) {
+    if (!empty($values['limit'])) {
       $url .= '&limit=' . $values['limit'];
     }
 
index 73a444dcdc879dcb0d9af61a16d7e3a9dc3e98d4..f8fa1904bff9a1ca06c23ea02cfff89e3f1c8d61 100644 (file)
@@ -597,6 +597,8 @@ return array(
     'group' => 'core',
     'name' => 'resCacheCode',
     'type' => 'String',
+    'quick_form_type' => 'Element',
+    'html_type' => 'text',
     'default' => NULL,
     'add' => '4.3',
     'title' => 'resCacheCode',
@@ -819,6 +821,8 @@ return array(
     'group' => 'core',
     'name' => 'site_id',
     'type' => 'String',
+    'quick_form_type' => 'Element',
+    'html_type' => 'text',
     'default' => '',
     'add' => '4.6',
     'title' => 'Unique Site ID',
@@ -832,6 +836,8 @@ return array(
     'group' => 'core',
     'name' => 'systemStatusCheckResult',
     'type' => 'Integer',
+    'quick_form_type' => 'Element',
+    'html_type' => 'text',
     'default' => 0,
     'add' => '4.7',
     'title' => 'systemStatusCheckResult',
@@ -881,4 +887,19 @@ return array(
       'callback' => 'CRM_Utils_Recent::getProviders',
     ),
   ),
+  'dedupe_default_limit' => array(
+    'group_name' => 'CiviCRM Preferences',
+    'group' => 'core',
+    'name' => 'dedupe_default_limit',
+    'type' => 'Integer',
+    'default' => 0,
+    'quick_form_type' => 'Element',
+    'html_type' => 'text',
+    'add' => '4.7',
+    'title' => 'Default limit for dedupe screen',
+    'is_domain' => 1,
+    'is_contact' => 0,
+    'description' => ts('Default to only loading matches against this number of contacts'),
+    'help_text' => ts('Deduping larger databases can crash the server. By configuring a limit other than 0 here the dedupe query will only search for matches against a limited number of contacts.'),
+  ),
 );
index 04db77c290d6496de105ea81904008534891e636..5d5c18704989f6b9e91ea6ccefd6572837192b7b 100644 (file)
                 <p class="description">{ts 1="http://wkhtmltopdf.org/"}<a href="%1">wkhtmltopdf is an alternative utility for generating PDF's</a> which may provide better performance especially if you are generating a large number of PDF letters or receipts. Your system administrator will need to download and install this utility, and enter the executable path here.{/ts}</p>
             </td>
         </tr>
-        <tr class="crm-miscellaneous-form-block-empoweredBy">
-            <td class="label">{$form.empoweredBy.label}</td>
-            <td>{$form.empoweredBy.html}<br />
-                <p class="description">{ts}When enabled, "empowered by CiviCRM" is displayed at the bottom of public forms.{/ts}</p></td>
-        </tr>
-        <tr class="crm-miscellaneous-form-block-max_attachments">
-            <td class="label">{$form.max_attachments.label}</td>
-            <td>{$form.max_attachments.html}<br />
-                <span class="description">{ts}Maximum number of files (documents, images, etc.) which can attached to emails or activities.{/ts}</span></td>
-        </tr>
-        <tr class="crm-miscellaneous-form-block-maxFileSize">
-            <td class="label">{$form.maxFileSize.label}</td>
-            <td>{$form.maxFileSize.html}<br />
-                <span class="description">{$maxFileSize_description}</span></td>
-        </tr>
-        <tr class="crm-miscellaneous-form-block-secondDegRelPermissions">
-            <td class="label">{$form.secondDegRelPermissions.label}</td>
-            <td>{$form.secondDegRelPermissions.html}<br />
-                <p class="description">{ts}If enabled, contacts with the permission to edit a related contact will inherit that contact's permission to edit other related contacts.{/ts}</p>
+        {foreach from=$pure_config_settings item=setting_name}
+          <tr class="crm-miscellaneous-form-block-{$setting_name}">
+            <td class="label">{$form.$setting_name.label}</td>
+            <td>{$form.$setting_name.html}<br />
+              <span class="description">{$setting_descriptions.$setting_name}</span>
             </td>
-        </tr>
-        <tr class="crm-miscellaneous-form-block-recentItemsMaxCount">
-            <td class="label">{$form.recentItemsMaxCount.label}</td>
-            <td>{$form.recentItemsMaxCount.html}<br />
-                <span class="description">{$recentItemsMaxCount_description}</span></td>
-        </tr>
-        <tr class="crm-miscellaneous-form-block-recentItemsProviders">
-            <td class="label">{$form.recentItemsProviders.label}</td>
-            <td>{$form.recentItemsProviders.html}<br />
-                <span class="description">{$recentItemsProviders_description}</span></td>
-        </tr>
+          </tr>
+        {/foreach}
 
     </table>
 <h3>{ts}reCAPTCHA Keys{/ts}</h3>