CRM-18556 api query array of ids not working in contribution

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.4.19
    • Fix Version/s: 4.6.17, 4.7.8
    • Component/s: CiviCRM API
    • Labels:
      None
    • Documentation Required?:
      None
    • Funding Source:
      Core Team Funds

      Description

      api query array of ids not working in contribution support for querying only a single value, works fine in membership for multiple values
      example : contribution get

      /civicrm/ajax/rest?entity=Contribution&action=get&debug=1&sequential=1&json={"id":

      {"IN":["1","2","3"]}

      }

        Attachments

          Activity

          [CRM-18556] api query array of ids not working in contribution
          Monish Deb added a comment -

          Its been fixed in api improvements done from 4.6 onward (to 4.7 latest) as now we support advance filtering for all entities. I confirmed the behaviour on my local also you can check the same on demo http://dmaster.demo.civicrm.org/.

          Please upgrade your site to civicrm latest.

          Thanks,
          Monish

          Monish Deb added a comment -

          Please check the attached screenshot

          Josh Ovett added a comment -

          fix for 4.4.x

          File : /var/www/civicrm/sites/all/modules/civicrm/CRM/Contribute/BAO/Query.php
          Line : 507

          Change case block :
          case 'contribution_id':

          if (is_array($value) && array_key_exists('IN', $value)) {
          $values = reset($value);
          if (count($values) > 1)

          { $op = 'IN'; $val = '(' . implode(',', $values) . ')'; }

          }
          else

          { $op = '='; $val = $value; }

          $query->_qill[$grouping][] = ts('Contribution ID %1', array(1 => $op)) . $val;
          $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution.id", $op, $val);
          $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1;

            People

            • Assignee:
              Monish Deb
              Reporter:
              Josh Ovett

              Dates

              • Created:
                Updated:
                Resolved: