VID-1960 Task to purge cache for pages with gallery tag

See comment below; I'd wouldn't rely on the galleryPageCount to determine when to stop.  It could be that no titles are found but you still have IDs to check.  Do a `select count(*)` before you start to get the total rows you need to check.