MDL-40584 backup: Query db once per category in precheck

The cache is function local and testing against a large database
indicates 10k questions is a large category.  Restore already
uses MEMORY_EXTRA and that will have enough space for the couple
of megabtyes a local sql hash will introduce.
Merge branch 'MDL-40584' of https://github.com/mr-russ/moodle
MDL-34397
MDL-34397 unittest fix