Item with ID cannot be deleted because it is not found in Sitecore 9.2+
See original GitHub issueWe are getting our logs spammed with messages like
WARN Item with ID={C100A1CF-6205-4F05-A636-0831DBADE1D0} cannot be deleted because it is not found
I traced it back to here https://github.com/mikeedwards83/Glass.Mapper/blob/2bc3e9418bb9d3dd4fedd854e2e0e688dc5a86d1/Source/Glass.Mapper.Sc/RenderingParametersModelFactory.cs#L50
I added a log statement
Sitecore.Diagnostics.Log.Info("GLASS DELETE?", this); item.Delete(); //added for clean up
And confirmed logs:
17368 12:51:06 INFO GLASS DELETE? 17368 12:51:06 WARN Item with ID={C100A1CF-6205-4F05-A636-0831DBADE1D0} cannot be deleted because it is not found 17368 12:51:06 INFO GLASS DELETE? 17368 12:51:06 WARN Item with ID={88CC0F4C-EB54-4013-8228-83E558CF35AC} cannot be deleted because it is not found 17368 12:51:06 INFO GLASS DELETE? 17368 12:51:06 WARN Item with ID={B82C7AC0-46BD-4CD5-9D58-E4D9627646E6} cannot be deleted because it is not found 17368 12:51:07 INFO GLASS DELETE?
It looks like Sitecore in 9.2+ has changed that Delete() to log if the item is not found. Looks like in this case it is an in memory item only. Is it safe to just remove that item.Delete() line and let the GC do its thing? Happy to open a PR if so.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top GitHub Comments
I have pushed a beta release with this fix, it also contains a flag in the config for backward compatibility. By default it will no longer delete the item, but setting the flag will restore the original logic.
https://github.com/mikeedwards83/Glass.Mapper/commit/74ff5e89e98724e5e258d2201bd9c033c842617d#diff-112f7122b703ee4f85649982cc0c249eR74
@mikeedwards83 it looks fine to me, I quickly cracked the Sitecore dll open and I couldn’t find anything being allocated that is not cleaned up by the GC.