-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM-21026 fix issue with ContributionCount not including disabled fin… #10824
Conversation
@eileenmcnaughton @monishdeb @JoeMurray @ineffyble does this look right to all of you? nb i'll fix the CRM number in the new wrapper functions docblocks |
…ancialtypes Fix references and move flushing of cache to all financialTypes for the safe side
CRM/Contribute/BAO/Contribution.php
Outdated
@@ -604,8 +604,8 @@ public static function create(&$params, $ids = array()) { | |||
if ($retrieveRequired == 1) { | |||
$contribution->find(TRUE); | |||
} | |||
$contributionTypes = CRM_Contribute_PseudoConstant::financialType(); | |||
$title = CRM_Contact_BAO_Contact::displayName($contribution->contact_id) . ' - (' . CRM_Utils_Money::format($contribution->total_amount, $contribution->currency) . ' ' . ' - ' . $contributionTypes[$contribution->financial_type_id] . ')'; | |||
$contributionType = CRM_Contribute_PseudoConstant::financialType($contribution->financial_type_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should rename to financialType when touching fields like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger
CRM/Financial/BAO/FinancialType.php
Outdated
* CRM-21026 | ||
* Wrapper aroung getAvaliableFinancialTypes to get all including disabled FinancialTypes | ||
* @param array $financialTypes | ||
* (reference ) an array of financial types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passing as reference is done badly in Civi code so I discourage it. In this case it is also returned & not required & in fact I think the parameter should not be pass in at all but rather initiated as an empty array within the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton hmm i'll see what i can do
CRM/Financial/BAO/FinancialType.php
Outdated
* | ||
* @return array | ||
*/ | ||
public static function getAllEnabledAvailableFinancialTypes(&$financialTypes = NULL, $action = CRM_Core_Action::VIEW, $resetCache = FALSE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comments about financialTypes
@eileenmcnaughton i have i think managed to get rid of the passing by reference for the new functions but the old function that we are wrapping around will be difficult to remove the passing by reference These are all the places its used
|
Does this fix https://issues.civicrm.org/jira/browse/CRM-17773 ? If not, this would be a good opportunity to address it. |
@seamuslee001 yeah the old function needs to stay out of scope ! |
CRM/Financial/BAO/FinancialType.php
Outdated
* | ||
* @return array | ||
*/ | ||
public static function getAllAvailableFinancialTypes($financialTypes = NULL, $action = CRM_Core_Action::VIEW, $resetCache = FALSE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should pass in $financialTypes at all - this function should do what it says & get all
CRM/Financial/BAO/FinancialType.php
Outdated
* | ||
* @return array | ||
*/ | ||
public static function getAllEnabledAvailableFinancialTypes($financialTypes = NULL, $action = CRM_Core_Action::VIEW, $resetCache = FALSE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
CRM/Financial/BAO/FinancialType.php
Outdated
} | ||
|
||
/** | ||
* CRM-21026 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need the CRM here - if we do it should be after the main descriptor
@eileenmcnaughton i think i have tidied it up now |
public static function getAllAvailableFinancialTypes($action = CRM_Core_Action::VIEW, $resetCache = FALSE) { | ||
// Flush pseudoconstant cache | ||
CRM_Contribute_PseudoConstant::flush('financialType'); | ||
$thisIsAUselessVariableButSolvesPHPError = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is needed because PHP7.1 especially will only allow for variables to be passed by reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note spelling error on line 249: "getAvaliableFinancialTypes" s/b "getAvailableFinancialTypes" (also on line 266 below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @laryn fixed that
* @return array | ||
*/ | ||
public static function getAllEnabledAvailableFinancialTypes($action = CRM_Core_Action::VIEW, $resetCache = FALSE) { | ||
$thisIsAUselessVariableButSolvesPHPError = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same Comment as L260
@ineffyble I think this will provide the foundations for fixing CRM-17773 |
Jenkins re test this please |
…h changing to new wrapper functions
@monishdeb @eileenmcnaughton i think this is ready for merging has been tested by Laryn |
I'm happy with the code approach & happy @laryn has tested this, so am merging. |
…ancialtypes
Overview
At present when calling ContributionCount it by default due to the addition of is_active = 1 clause in the pseduoConstant function excludes contributions with Disabled Financial Types
Before
Contribution count on tab is incorrect
After
Contribution count is correct
Technical Details
If the PR introduces noteworthy technical changes, please describe them here. Provide code snippets if necessary
Comments