Contribution Details Statistics are multiplied under many circumstances
This bug was previously identified and fixed as #655 (closed), but the fix only addresses the rows and not the statistics.
In addition to contribution detail rows getting multiplied by soft credits, they can be multipled by any one-to-many JOIN
to the contribution table. Soft credits are one example, but it can also be to a contact's multi-record contact field group, or if you pick a field (like "Credit Card Type") that lives in the financial transaction tables (first reported on SE by @KarinG).
Given that the statistics don't concern itself with any data that's not in civicrm_contribution
, we can replace the flawed (and potentially CPU-intensive) original query with a list of contribution IDs and only use FROM civicrm_contribution
.