Tag Archives: recycle bin

Recycle bin won’t empty when using EPiServer Relate

A few days ago i found i strange behaviour on our intranet site. The waste basket didn’t empty! The scheduled job ran just fine, but the log always contained the same message: 0 content items were deleted from recycle bin

Thats a new one! So where to look? The logs are, off course, a great place to start looking for errors. The first line that cought my attention was this one: ERROR EPiServer.Util.EmptyWastebasketJob: 17.3.1 Error when trying to delete content from recycle bin

At first, i thought it was some kind of permission issue. The site runs Windows authentication, and that has some side effects, but than i found another line in the log: EPiServer.Core.TypeMismatchException: Content with id ‘<xxxxx>’ is of type ‘Castle.Proxies.FormContainerBlockProxy’ which does not inherit required type ‘EPiServer.Core.PageData’

and than another similar line: EPiServer.Core.TypeMismatchException: Content with id ‘29990’ is of type ‘EPiServer.Core.ContentFolder’ which does not inherit required type ‘EPiServer.Core.PageData’

I couldn’t believe there’s still code in EPiServer that requires PageData!! And, off couse, there wasn’t. BUT! EPiServer Relate is another story. The CmsIntegrationModule had a few fingers in that cookie jar!

To be specific, the method RemovePageEntity, which deletes corresponding page entities when a page is deleted:

It first, it looks like the code really do try to avoid null references by checking if PageEventArgs are null and than if PageEventArgs.PageLink is null, but: when you have a ContentFolder or FormContiner in the recycle bin, both of them are set. The problem is that PageEventArgs.Page is null.

So, just throw in one more null check for e.Page, like this:

And you also need to handle errors in GetClubId. I took the easy way and put a try around the code.

Now the recycle bin should empty just fine!