I ran into an issue recently where my hook_cron function was failing when triggered by cron. The problem was that I was calling EntityFieldQuery, which does access checks and since cron runs as an anonymous user, the query would to process correctly. Specifically, I was having this issue: EntityFieldQuery doesn't work correctly in hook_cron
I am trying to understand why cron runs as an anonymous user. Cron clears the cache and so has at least some database access. When writing hook_cron functions now, I have to bypass access checks so that they return results as expected. Does anyone understand why this is the intended behaviour?
Drupal 7