Body: <p>Sometimes I cannot remove a group from recipient list of a Mailing. This can happen for instance when I re-use a mailing, but I want to change the group – I can add a new one, but clicking "x" on the old one just triggers "Estimating" label for a while and does not do anything.</p>
  
  <p>Here I cannot remove "Replay" group:
  <img src="https://i.sstatic.net/Xk4QC.png" alt="enter image description here"></p>
  
  <p>After clicking "Next>", I see the recipient group appearing several times (see attached pictures).</p>
  
  <p><img src="https://i.sstatic.net/m5L3K.png" alt="enter image description here"></p>
  
  <p>How can I debug this? I wasn't able to reproduce this on demo.civicrm.org. </p>
  
  <p>I'm using CiviCRM 4.6.4 with CiviMail 1.0.</p>
  
  <p><strong>edit:</strong>
  I have done some more tests with CiviCRM 4.6.5, where this bug persists.</p>
  
  <p>As I click through all the "new mailing" fields, there are numerous AJAX calls to <code>https://apps.akcjademokracja.pl/crm/civicrm/ajax/rest</code> with <code>entity=Mailing</code>, <code>action=create</code> API call, with <code>json</code> similar to:</p>
  
  <p><code>"{"id":"23","domain_id":"1","header_id":"1","footer_id":"2","reply_id":"8","unsubscribe_id":"5","resubscribe_id":"6","optout_id":"7","mailing_type":"standalone","from_name":"Akcja+Demokracja","from_email":"kontakt@akcjademokracja.pl","url_tracking":"1","forward_replies":"0","auto_responder":"0","open_tracking":"1","override_verp":"1","created_id":"2","created_date":"2015-08-04+13:22:01","scheduled_date":"2015-08-04+13:22:00","approver_id":"2","approval_date":"2015-08-04+13:22:01","is_archived":"0","visibility":"Public+Pages","dedupe_email":"0","email_selection_method":"automatic","is_error":0,"jobs":{},"groups":{"include":[6],"exclude":[],"base":[]},"mailings":{"include":[],"exclude":[]},"name":"placeholder","subject":"placeholder","options":{"force_rollback":1},"api.mailing_job.create":1,"api.MailingRecipients.getcount":{"mailing_id":"$value.id"}}"
  </code></p>
  
  <p>as you see, AJAX properly sets <code>"groups":{"include":[6],"exclude":[],"base":[]}</code> but in the database I see more and more <code>civicrm_mailing_group</code> entries:</p>
  
  <p><code>mysql&gt; select * from civicrm_mailing_group where mailing_id = 23 ;
  +------+------------+------------+---------------+-----------+-----------+-------------+
  | id   | mailing_id | group_type | entity_table  | entity_id | search_id | search_args |
  +------+------------+------------+---------------+-----------+-----------+-------------+
  | 5596 |         23 | include    | civicrm_group |         6 |      NULL | NULL        |
  | 5597 |         23 | include    | civicrm_group |         6 |      NULL | NULL        |
  | 5598 |         23 | include    | civicrm_group |         6 |      NULL | NULL        |
  +------+------------+------------+---------------+-----------+-----------+-------------+
  3 rows in set (0.00 sec)
  </code></p>
  
  <p>Perhaps then, it's a civicrm schema issue – it should force Uniqueness in the table? Or is it rather a backend issue?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-07T17:51:54.767Z
Comments.Text: I wonder if the group was initially in there more than once. Does this only happen when you re-use an old mailing from before your 4.6 upgrade?
Comments.UserDisplayName: Coleman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-08T09:42:17.090Z
Comments.Text: Thank you for questions – I discovered some logic in this: This also happens, when I save the Mailing as a draft. When I re-open it, the group is added 3 times. If I click [x] on the list to remove it three times, it gets removed finally. But when I add it again once, and save the Mailing and reopen it again, the group is added 6 times!  This is a fresh 4.6.4 install.
Comments.UserDisplayName: movonw
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-20T10:02:14.710Z
Comments.Text: could you open your browser debugger (eg. firebug) and check what are the ajax network calls- eg, called once or several time? I don't have the issue, not sure if it's because something on your server or because of the non native english
Comments.UserDisplayName: Xavier
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-04T11:28:23.360Z
Comments.Text: @Xavier yes, I'll edit the first post
Comments.UserDisplayName: movonw
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-05T11:50:43.350Z
Comments.Text: @movonw, not sure why you would get this issue. The only suggestions:1) upgrade to the latest stable version, clear caches, logout/in and see if the problem persists. 2) try to switch the language to en us (just to eliminate that option)
Comments.UserDisplayName: Xavier
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-09T11:44:04.690Z
Comments.Text: stilll an issue across several browsers?
Comments.UserDisplayName: Xavier
Tags: <civimail><groups>
Title: Problems with editing recipient groups of CiviMail
ThreadText: # Problems with editing recipient groups of CiviMail
  
  (Asked by: username_0 on 2015-07-07)
  
  Sometimes I cannot remove a group from recipient list of a Mailing. This can happen for instance when I re-use a mailing, but I want to change the group – I can add a new one, but clicking "x" on the old one just triggers "Estimating" label for a while and does not do anything.
  
  Here I cannot remove "Replay" group:
  ![enter image description here](https://i.sstatic.net/Xk4QC.png)
  
  After clicking "Next>", I see the recipient group appearing several times (see attached pictures).
  
  ![enter image description here](https://i.sstatic.net/m5L3K.png)
  
  How can I debug this? I wasn't able to reproduce this on demo.civicrm.org.
  
  I'm using CiviCRM 4.6.4 with CiviMail 1.0.
  
  **edit:**
  I have done some more tests with CiviCRM 4.6.5, where this bug persists.
  
  As I click through all the "new mailing" fields, there are numerous AJAX calls to `https://apps.akcjademokracja.pl/crm/civicrm/ajax/rest` with `entity=Mailing`, `action=create` API call, with `json` similar to:
  
  `"{"id":"23","domain_id":"1","header_id":"1","footer_id":"2","reply_id":"8","unsubscribe_id":"5","resubscribe_id":"6","optout_id":"7","mailing_type":"standalone","from_name":"Akcja+Demokracja","from_email":"kontakt@akcjademokracja.pl","url_tracking":"1","forward_replies":"0","auto_responder":"0","open_tracking":"1","override_verp":"1","created_id":"2","created_date":"2015-08-04+13:22:01","scheduled_date":"2015-08-04+13:22:00","approver_id":"2","approval_date":"2015-08-04+13:22:01","is_archived":"0","visibility":"Public+Pages","dedupe_email":"0","email_selection_method":"automatic","is_error":0,"jobs":{},"groups":{"include":[6],"exclude":[],"base":[]},"mailings":{"include":[],"exclude":[]},"name":"placeholder","subject":"placeholder","options":{"force_rollback":1},"api.mailing_job.create":1,"api.MailingRecipients.getcount":{"mailing_id":"$value.id"}}"`
  
  as you see, AJAX properly sets `"groups":{"include":[6],"exclude":[],"base":[]}` but in the database I see more and more `civicrm_mailing_group` entries:
  
  `mysql> select * from civicrm_mailing_group where mailing_id = 23 ;
  +------+------------+------------+---------------+-----------+-----------+-------------+
  | id | mailing_id | group_type | entity_table | entity_id | search_id | search_args |
  +------+------------+------------+---------------+-----------+-----------+-------------+
  | 5596 | 23 | include | civicrm_group | 6 | NULL | NULL |
  | 5597 | 23 | include | civicrm_group | 6 | NULL | NULL |
  | 5598 | 23 | include | civicrm_group | 6 | NULL | NULL |
  +------+------------+------------+---------------+-----------+-----------+-------------+
  3 rows in set (0.00 sec)`
  
  Perhaps then, it's a civicrm schema issue – it should force Uniqueness in the table? Or is it rather a backend issue?
  
  **Tags:** civimail, groups
  
  > **Comments:**
  > **username_1**: I wonder if the group was initially in there more than once. Does this only happen when you re-use an old mailing from before your 4.6 upgrade?  
  > **username_0**: Thank you for questions – I discovered some logic in this: This also happens, when I save the Mailing as a draft. When I re-open it, the group is added 3 times. If I click [x] on the list to remove it three times, it gets removed finally. But when I add it again once, and save the Mailing and reopen it again, the group is added 6 times!  This is a fresh 4.6.4 install.  
  > **username_2**: could you open your browser debugger (eg. firebug) and check what are the ajax network calls- eg, called once or several time? I don't have the issue, not sure if it's because something on your server or because of the non native english  
  > **username_0**: @username_2 yes, I'll edit the first post  
  > **username_2**: @username_0, not sure why you would get this issue. The only suggestions:1) upgrade to the latest stable version, clear caches, logout/in and see if the problem persists. 2) try to switch the language to en us (just to eliminate that option)  
  > **username_2**: stilll an issue across several browsers?  
  
  ---
  
  ## 0 answers
  
  