Unsubscribe broken if mailing sent to previous mailing recipients with an excluded group
I think 96fce13b broke the unsubscribe in various situations.
The logic is pretty hard to follow because the options create zillions of use cases, however, having been hit by this I can report that the following situation created it:
send a mailing (A) to a mailing group
send a second mailing (B) to the recipients of mailing (A), excluding those in a group (C).
Recipients of (B) will not be able to unsubscribe.
This is because (as I have understood so far):
The unsubscribe code is supposed to find all the lists of contacts (I'm deliberately using lists to avoid ambiuities with groups -if I say group it means a CiviCRM group as you would see on a contact's record.) that were used to select recipients of the mailing. These "lists" might be groups or previous mailings.
After the initial fetch - for the mailing that triggered the unsubscribe - there is a recursive fetch loop that goes back up the tree of mailings that were used to include contacts in the lists, finding all their included groups.
The code introduced by the commit above makes (1) return no records, and therefore the second step is never triggered, resulting in no groups whatsoever being identified as the ones to unsubscribe (remove) contacts from.
This is getting orgs using CiviMail in this way in hot water as you can imagine.