Towards CRM-19815 refactor cached clause to use Civi:Statics
authoreileen <emcnaughton@wikimedia.org>
Tue, 24 Jan 2017 01:08:27 +0000 (14:08 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 24 Jan 2017 09:10:00 +0000 (22:10 +1300)
CRM/Contribute/BAO/Query.php
CRM/Utils/System.php

index c323b4f7a8471d485c767ed7d70d0e618f9b081d..e09ddd64d1dfcf03f30f6b10a4092c279214b8f0 100644 (file)
  */
 class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
 
-  /**
-   * Static field for all the export/import contribution fields.
-   *
-   * @var array
-   */
-  static $_contributionFields = NULL;
-
   static $_contribOrSoftCredit = "only_contribs";
 
   static $_contribRecurPayment = NULL;
@@ -54,16 +47,12 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
    *   Associative array of contribution fields
    */
   public static function getFields($checkPermission = TRUE) {
-    if (!self::$_contributionFields) {
-      self::$_contributionFields = array();
-
-      $fields = CRM_Contribute_BAO_Contribution::exportableFields($checkPermission);
-
+    if (!isset(\Civi::$statics[__CLASS__]) || !isset(\Civi::$statics[__CLASS__]['fields']) || !isset(\Civi::$statics[__CLASS__]['contribution'])) {
+      $fields  = CRM_Contribute_BAO_Contribution::exportableFields($checkPermission);
       unset($fields['contribution_contact_id']);
-
-      self::$_contributionFields = $fields;
+      \Civi::$statics[__CLASS__]['fields']['contribution'] = $fields;
     }
-    return self::$_contributionFields;
+    return \Civi::$statics[__CLASS__]['fields']['contribution'];
   }
 
   /**
index 94c28b4dfc8b173ba99f4b9c0e6b911fc7b37bba..8079cec6f2d61e3c40eeb88c438a2dbbeb6c3210 100644 (file)
@@ -1428,7 +1428,7 @@ class CRM_Utils_System {
     CRM_Contact_BAO_Contact::$_importableFields = CRM_Contact_BAO_Contact::$_exportableFields
       = CRM_Contribute_BAO_Contribution::$_importableFields
         = CRM_Contribute_BAO_Contribution::$_exportableFields
-          = CRM_Pledge_BAO_Pledge::$_exportableFields = CRM_Contribute_BAO_Query::$_contributionFields
+          = CRM_Pledge_BAO_Pledge::$_exportableFields
             = CRM_Core_BAO_CustomField::$_importFields
               = CRM_Core_BAO_Cache::$_cache = CRM_Core_DAO::$_dbColumnValueCache = NULL;