Fix for Custom Query to gracefully remove deleted tickets from query cache.
Fix for Custom Query to gracefully remove deleted tickets from query cache.

Closes #6088.
pkdevbox/trac,pkdevbox/trac,pkdevbox/trac,pkdevbox/trac