Skip to content
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

dev/core#812 - Fix null display of contribution row on contact summar… #13868

Closed
wants to merge 1 commit into from

Conversation

jitendrapurohit
Copy link
Contributor

…y page

Overview

Null row is displayed on contact summary page if contact has 0 contribution.

Before

Screenshot from dmaster -

image

If any of the link is clicked on the row, it results into an error -

image

After

Fixed.

image

Technical Details

We removed the unnecessary financial type join from the contribution table in #13720

Before the above fix, the query included the financial type which unintentionally avoided the null row to be returned as output -

SELECT  civicrm_contribution.id, .......... 
FROM civicrm_contact contact_a 
    LEFT JOIN civicrm_contribution ON civicrm_contribution.contact_id = contact_a.id  
    INNER JOIN civicrm_financial_type ON civicrm_contribution.financial_type_id = civicrm_financial_type.id  
    LEFT  JOIN civicrm_contribution_product ON civicrm_contribution_product.contribution_id = civicrm_contribution.id 
    LEFT  JOIN civicrm_product ON civicrm_contribution_product.product_id =civicrm_product.id 
WHERE  ( contact_a.id = '202' )  AND (contact_a.is_deleted = 0)   
  GROUP BY civicrm_contribution.id  ORDER BY `receive_date` desc, `contact_a`.`id`  LIMIT 0, 50 

After the removal of financial type join, the query is -

SELECT  civicrm_contribution.id, ......
FROM civicrm_contact contact_a 
    LEFT JOIN civicrm_contribution   ON civicrm_contribution.contact_id = contact_a.id
WHERE  ( contact_a.id = '202' )  AND (contact_a.is_deleted = 0)   
GROUP BY civicrm_contribution.id  ORDER BY `receive_date` desc, `contact_a`.`id`  
LIMIT 0, 50 

As it is a left join and no other field, the contact null row gets returned and is displayed on the contribution tab. @eileenmcnaughton

Comments

Gitlab - https://lab.civicrm.org/dev/core/issues/812

@civibot
Copy link

civibot bot commented Mar 20, 2019

(Standard links)

@civibot civibot bot added the master label Mar 20, 2019
@eileenmcnaughton
Copy link
Contributor

@jitendrapurohit that spun up fails- perhaps we can add a where instead?

@eileenmcnaughton
Copy link
Contributor

this should go a the rc when we get it figured out maybe

@eileenmcnaughton
Copy link
Contributor

@jitendrapurohit what about this instead - I'm not sure if that selector is the best place to add the extra criteria but it seems to work & potentially avoids changing a scary join lower down

diff --git a/CRM/Contribute/Selector/Search.php b/CRM/Contribute/Selector/Search.php
index 0606f9a207..e17f043cb7 100644
--- a/CRM/Contribute/Selector/Search.php
+++ b/CRM/Contribute/Selector/Search.php
@@ -181,6 +181,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     $this->_action = $action;
     $returnProperties = CRM_Contribute_BAO_Query::selectorReturnProperties($this->_queryParams);
     $this->_includeSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_queryParams);
+    $this->_queryParams[] = ['contribution_id', '!=', 0, 0, 0];
     $this->_query = new CRM_Contact_BAO_Query(
       $this->_queryParams,
       $returnProperties,

@jitendrapurohit
Copy link
Contributor Author

Updated the changes which now uses where clause to avoid the NULL contact row to be returned as result. Also avoided this unnecessary filter to be displayed as qill value on search results.

image

@eileenmcnaughton
Copy link
Contributor

Hmm the new test is failing now - also - perhaps the qill should also check for 0 since I can imagine if someone later wants to have a qill for 'contribution id = 89' it might be confusing why it's blocked

@jitendrapurohit
Copy link
Contributor Author

jitendrapurohit commented Mar 22, 2019

The test which is failing is the same which is added in this PR. The problem was it directly used the BAO_Query object to generate the query. It is now modified as per the selector which should work fine in passing all the tests.

Also, modified the qill condition to be more restrictive and ignore the display for only this case.

@eileenmcnaughton
Copy link
Contributor

@jitendrapurohit looks good - last thing - I think this should be on the rc?

@jitendrapurohit
Copy link
Contributor Author

Yes, I've confirmed that this also affects 5.12-rc. Have raised the PR here - #13881 @eileenmcnaughton

@eileenmcnaughton
Copy link
Contributor

ok - we can close this one in favour of that then I guess

@jitendrapurohit jitendrapurohit deleted the core-812 branch March 22, 2019 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants