APIv3 "replace" action is broken when there is > 25 records to replace.
In what might be the oldest bug in API3...
Steps to replicate
- Have a site with > 25 groups.
- Create a mailing.
- Start adding groups to the mailing.
- Run
select count(*) from civicrm_mailing_group WHERE mailing_id = <your mailing ID here>
. - Note that the number of records is equal to the number of groups you added to the mailing.
- Add the 26th group and run that SQL again.
- Oops.
The number goes up very quickly - replace
will only delete the first 25 records, so this quickly spirals out of control. Also, MailingGroup.replace
is called every time the mailing is saved, so the problem increases exponentially until it can't calculate recipients and you can't send the mailing.