I have written a custom module (for Drupal 7 and PHP 5.3) that utilizes hook_nodeapi()
and doesn't allow access to a specific node type and simply redirects (with drupal_goto()
) to the main listing page with a warning message.
However I have a suspicion that the Boost module (with "Don't cache pages with messages" enabled) chokes on cron runs when it gets to these content types and keeps getting redirected (I don't know how Boost exactly works but I guess it caches few pages on cron runs?).
The reason for my suspicion, and the real problem is that the cron, after a certain number of runs, starts failing with an error message, "Cron run exceeded the time limit and was aborted.", and immediately after this message on Watchdog there's the following message, "There are Drupal messages on this page, preventing boost from caching."
I put a debugging piece of code on module.inc (hacked core as was suggested here) to see which module was responsible for this failure, and everytime the cron fails, the last module that accessed the Cron seems to be the "Search" (core) module:
boost 22/02/2012 - 9:00am There are Drupal messages on this ... Anonymous
cron 22/02/2012 - 9:00am Cron run exceeded the time limit and was aborted. Anonymous
cron 22/02/2012 - 9:00am hit search cron Anonymous
cron 22/02/2012 - 9:00am hit node cron Anonymous
cron 22/02/2012 - 9:00am hit filter cron Anonymous
cron 22/02/2012 - 9:00am hit dblog cron Anonymous
boost 22/02/2012 - 9:00am Expired stale files from static page cache. Anonymous
cron 22/02/2012 - 9:00am hit boost cron Anonymous
I have since then reduced the number of pages to index but it didn't help. The cron that runs after the Search cron is the "System" cron but I have no idea what exactly this cron does.
The annoying thing is when you access the cron page through typing in the browser http://address/cron.php or through commandline wget http://address/cron.php
it runs Ok. But from the system's cron jobs it eventually runs into this problem after few successful cron runs.
I would appreciate any help in getting to the bottom of this problem or a push in the right direction. Thanks.
/**
* Implements hook_nodeapi().
*/
function rhask_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'view':
if($node->type == 'question' && arg(0) == 'node' && !user_access('administer questions')){
drupal_set_message('Access Denied - You cannot access this content directly. Please use this page.', 'warning');
drupal_goto('ask');
}
break;
}
}
I guess I could do a redirection without setting any message. That might solve it if indeed Boost is causing problems with the cron, I'll edit this post when I get any result by doing so.
Edit: The cron has been running successfully every 30 minutes since yesterday and the change I've made to the XMLSitemap module's settings seems to have done the job. I will continue to monitor this website for few more days.
Edit2: Cron still fails. I've removed the drupal_set_message so now it redirects without setting any messages. However it doesn't prevent the cron from failing. Boost doesn't complain anymore and just logs that "Expired stale files from static page cache". I don't know how to proceed from here to isolate this problem.