CRM-17691 do not use default return properties from search screen
authoreileen <emcnaughton@wikimedia.org>
Thu, 10 Dec 2015 03:28:18 +0000 (16:28 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 14 Dec 2015 19:32:56 +0000 (08:32 +1300)
Change-Id: Ic6b3d7a2ac2b0ca691ed9fdb84a1ff86f6c73e52

Change-Id: Ib275a710fceceba2e10d0293dc3366c1f37d3397

CRM/Contribute/BAO/Contribution.php
CRM/Contribute/BAO/Query.php
CRM/Contribute/Selector/Search.php

index 79bebb63b614987437e9135c7da10d2d8884e434..fb59766956675f4c1397910a0fe3b113ff44cdee 100644 (file)
@@ -1354,7 +1354,7 @@ LEFT JOIN civicrm_option_value contribution_status ON (civicrm_contribution.cont
 {$additionalClause}
 ";
 
-    $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
+    $dao = CRM_Core_DAO::executeQuery($query);
 
     while ($dao->fetch()) {
       $paymentDetails[$dao->id] = array(
index c9597e8fca9ce600ae05c9b8b232c4f22609c9c6..60547162eebcfb97f4069e06a9943a4b0f84eb29 100644 (file)
@@ -851,7 +851,45 @@ class CRM_Contribute_BAO_Query {
   }
 
   /**
-   * @param $mode
+   * Get the list of fields required to populate the selector.
+   *
+   * The default return properties array returns far too many fields for 'everyday use. Every field you add to this array
+   * kills a small kitten so add carefully.
+   */
+  public static function selectorReturnProperties() {
+    return array(
+      'contact_type' => 1,
+      'contact_sub_type' => 1,
+      'sort_name' => 1,
+      'financial_type' => 1,
+      'contribution_source' => 1,
+      'is_test' => 1,
+      'receive_date' => 1,
+      'is_pay_later' => 1,
+      'thankyou_date' => 1,
+      'total_amount' => 1,
+      'contribution_status_id' => 1,
+      // @todo return this & fix query to do pseudoconstant thing.
+      'contribution_status' => 1,
+      // @todo the product field got added because it suited someone's use case.
+      // ideally we would have some configurability here because I think 90% of sites would
+      // disagree this is the right field to show - but they wouldn't agree with each other
+      // on what field to show instead.
+      'contribution_product_id' => 1,
+      'product_name' => 1,
+    );
+  }
+
+  /**
+   * Function you should avoid.
+   *
+   * This function returns default properties for contribution queries. However, they are
+   * far more than are required in 'most' cases and you should always try to return the return properties
+   * you actually require.
+   *
+   * It would be nice to throw an e-notice when this is called but it would trash the tests :-(.
+   *
+   * @param int $mode
    * @param bool $includeCustomFields
    *
    * @return array|NULL
index bf931d8f42b173af249d77afe474382bbf5f0f1a..15606901470643349601b776984946bfd7971cbf 100644 (file)
@@ -187,10 +187,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     $this->_includeSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_queryParams);
     $this->_query = new CRM_Contact_BAO_Query(
       $this->_queryParams,
-      CRM_Contribute_BAO_Query::defaultReturnProperties(
-        CRM_Contact_BAO_Query::MODE_CONTRIBUTE,
-        FALSE
-      ),
+      CRM_Contribute_BAO_Query::selectorReturnProperties(),
       NULL, FALSE, FALSE,
       CRM_Contact_BAO_Query::MODE_CONTRIBUTE
     );