While trying to fix forum cron I have discovered that has_capability() does not work properly
1/ if you specifiy $userid default roles (guest and default user role) are ignored
2/ if you change $USER on the fly the capcache returns incorrect results (I need this for forum cron)
3/ it does not work on pages with $nomoodlecookie (I need this for cron improvements)
I have prepared a patch and did some extensive testing, going to commit it today. The patch for cron, chat and forum is close to completion too - will file a new report for it.
They changes are not small, I am not working backport for 1.7.x