An error occurred while enumerating through a collection

Hi,

I'm not here to ask a question but to give a solution to an issue I faced.
If someone else could check it to be sure it's still doing the same thing as before, it would be safer for use.

The solution I found is based on those articles :
http://blog.ithinksharepoint.com/2012/07/04/feature-upgrade-issue-deleted-spwebs-an-error-occurred-while-enumerating-through-a-collection/
http://blog.ithinksharepoint.com/2012/06/20/querying-for-feature-upgrades-error-the-site-with-id-cannot-be-found/

While deploying FBAPack, I had these error : An error occurred while enumerating through a collection
It happens here :
$features = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.QueryFeatures($feature.id)
foreach ($feature in $features)
I found that, when you delete sites or feature, a trace stays and can trow errors. To avoid it, you can replace, in activate.ps1 and deploy.ps1 these line :
$features = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.QueryFeatures($feature.id)
by those :
[Microsoft.SharePoint.Administration.SPWebService]::ContentService.WebApplications | ForEach-Object{$sites+=$_.Sites}
$sites | ForEach-Object{$features+=$_.QueryFeatures($feature.id)}
Hope it will be usefull
Thanks! I've created an issue for this, so it can be fixed in a future release:
http://sharepoint2010fba.codeplex.com/workitem/833