Download & Extend

Cron detection works in mysterious ways

Project:Boost
Version:7.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Hi

In hook_flush_caches() there is a piece of logic that checks if it was called by cron. It does this by checking lock_may_be_available('cron').

The problem with that approach, is that it spans across requests. So whenever cron is running, hook_flush_caches() will not flush, regardless of being called from cron or not.

Perhaps a better approach could be to check $_SERVER['PHP_SELF'] for 'cron.php'?

Comments

#1

Status:active» needs review

Here's a patch...

AttachmentSize
boost-cron-detection-1829832-1.patch 2.76 KB

#2

Can you give more information on how lock_may_be_available('cron') may span across requests?

Does checking for cron.php explicitely also work when the cron is called from drush?

Thanks for the patch.

#3

Hi bgm

One of the main purposes of a lock/semaphore is that it's available across requests, so one may take concurrency into consideration. The lock is stored in the DB (or memcache or other backend). It's available to whoever asks for it. So if cron is running, and you then invoke the flush_caches, then Boost will not flush its caches, because it thinks cron is running ... because cron __is__ running, just in another request.

The patch didn't support Drush, well spotted. I've added a new patch that supports Drush as well.

AttachmentSize
boost-cron-detection-1829832-3.patch 3.72 KB

#4

Any news on this?