Reduce cache bypasses
authoreileen <emcnaughton@wikmedia.org>
Wed, 22 May 2019 01:12:53 +0000 (13:12 +1200)
committereileen <emcnaughton@wikimedia.org>
Thu, 23 May 2019 22:55:05 +0000 (10:55 +1200)
We have been running this patch in production for some months. When you load up a contribution edit page
(for example) the custom data metadata is loaded without hitting the cache. This means that
unnecessary queries are done. The only reason to bypass the cache would be that it is stale
or parameter dependent. However, the staleness is/ should be dealt with when editing custom
fields & if it is not then there will be other impacts. The entity id is NOT passed into the part of
the code that goes into the cached value

CRM/Custom/Form/CustomData.php

index 3cc0d279c8f4ee8eb10cfe03388058448c3b0f99..664d078cb21716f8ce1c6e398200b77d9deca84b 100644 (file)
@@ -188,15 +188,18 @@ class CRM_Custom_Form_CustomData {
   }
 
   /**
-   * @param $form
-   * @param $subType
-   * @param $gid
-   * @param $onlySubType
-   * @param $getCachedTree
+   * Add the group data as a formatted array to the form.
+   *
+   * @param CRM_Core_Form $form
+   * @param string $subType
+   * @param integer $gid
+   * @param bool $onlySubType
+   * @param bool $getCachedTree
    *
    * @return array
+   * @throws \CRM_Core_Exception
    */
-  public static function setGroupTree(&$form, $subType, $gid, $onlySubType = NULL, $getCachedTree = FALSE) {
+  public static function setGroupTree(&$form, $subType, $gid, $onlySubType = NULL, $getCachedTree = TRUE) {
     $singleRecord = NULL;
     if (!empty($form->_groupCount) && !empty($form->_multiRecordDisplay) && $form->_multiRecordDisplay == 'single') {
       $singleRecord = $form->_groupCount;