fix display of contacts' recurring contributions
authorAndrew Engelbrecht <sudoman@ninthfloor.org>
Wed, 4 Jan 2017 21:45:12 +0000 (16:45 -0500)
committerAndrew Engelbrecht <sudoman@ninthfloor.org>
Wed, 4 Jan 2017 21:45:12 +0000 (16:45 -0500)
https://rt.gnu.org/Ticket/Display.html?id=1176733

if you look at a contact, click contributions, then click on "view" next
to a recurring payment (not all users have these), then the server would
crash and give a backtrace. this patch fixes that issue.

the issue was due to a sort-by-id failing because multiple tables are
queried, more than one of which has an id column. therefore the "id"
column name was redundant and threw an SQL error. this patch specifies
the desired table with the specified id column.

i worked a bit on this patch and received help from ruben, who corrected
my less than perfect original patch.

CRM/Contribute/BAO/ContributionRecur.php

index 5845950f9afbf4be76b41e10ba249e381488c066..a84557b6eee41524f290c7a30f466df90fca52b3 100644 (file)
@@ -443,7 +443,7 @@ INNER JOIN civicrm_contribution       con ON ( con.id = mp.contribution_id )
   public static function getTemplateContribution($id) {
     $templateContribution = civicrm_api3('Contribution', 'get', array(
       'contribution_recur_id' => $id,
-      'options' => array('limit' => 1, 'sort' => array('id DESC')),
+      'options' => array('limit' => 1, 'sort' => array('civicrm_contribution_recur.id DESC')),
       'sequential' => 1,
       'contribution_test' => '',
     ));