From 8c058ef8c86d23a404bc54cdbfb3709341f7843f Mon Sep 17 00:00:00 2001 From: Brad Erickson Date: Mon, 26 Nov 2012 20:05:21 -0800 Subject: [PATCH] hook_domain_cron_queue_info() to consistently detect cron runs for domain_grant_all() --- domain.module | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/domain.module b/domain.module index 8264289..07f2ed6 100644 --- a/domain.module +++ b/domain.module @@ -2632,6 +2632,17 @@ function domain_form_devel_generate_content_form_alter(&$form, &$form_state) { } } +/** + * Implements hook_domain_cron_queue_info(). + * + * Uses Queue API info hook to detect if cron is running. + */ +function domain_cron_queue_info() { + global $domain_cron_run; + // Set the global to TRUE during a cron run. + $domain_cron_run = TRUE; + return array(); +} /** * Activate the hidden grant for searches. @@ -2643,7 +2654,12 @@ function domain_form_devel_generate_content_form_alter(&$form, &$form_state) { * TRUE or FALSE, depending on whether the grants should be executed for this * page. */ -function domain_grant_all($reset= FALSE) { +function domain_grant_all($reset = FALSE) { + global $domain_cron_run; + if (!isset($domain_cron_run)) { + $domain_cron_run = FALSE; + } + $grant = &drupal_static(__FUNCTION__); $options = array(); if (!isset($grant) || $reset) { @@ -2661,7 +2677,7 @@ function domain_grant_all($reset= FALSE) { if (!$grant) { $ref = explode('/', request_uri()); $script = array_pop($ref); - if (variable_get('domain_cron_rule', 1) && $script == 'cron.php') { + if (variable_get('domain_cron_rule', 1) && $domain_cron_run) { $options['script'] = $script; $grant = TRUE; } -- 1.7.12.3