I have a site definition that activates a set of features some of whom removes all groups from the site and adds some new ones with proper names. I also have a site-scoped feature that enables auditing on the site in the following way:
var site = properties.Feature.Parent as SPSite; site.Audit.AuditFlags = SPAuditMaskType.Copy | SPAuditMaskType.Delete | SPAuditMaskType.Move | SPAuditMaskType.Undelete | SPAuditMaskType.Update; site.TrimAuditLog = true; site.AuditLogTrimmingRetention = 31; site.Audit.Update();
Now without that feature all my groups are created properly, but as soon as I add it into the onet.xml (at the very bottom of the "SiteFeatures" section the existing groups are suddenly not deleted. Neither feature fails in any way and throws nothing to the ULS log.
Why should enabling auditing have an effect on this? It is the last feature in the onet so shouldn't it also be activated last? How then would it have an effect on anything in the other features?
Edit: I've narrowed the problem down to these two lines (which activate trimming and not the actual auditing):
site.TrimAuditLog = true; site.AuditLogTrimmingRetention = 31;
With them the groups are not deleted, without them the groups are deleted. I should also note that the site definition is based on the basic teamsite definition.