Hi there,

is there any way to know when the poorsman cron was launched ?

I mean, once poorman cron is launched I need to know than the execution of differentes hooks, in my case hook_nodeapi and VIEW event, is running because of poormans cron in order to allow o disallow some operation.

Thanks in advance,
Ricardo

Comments

rsantiag’s picture

Finally I found a way to know when poorsmancron is running.

In poormanscron.module you have to replace this code in poormanscron_exit:

// Get the current Drupal messages. Use drupal_set_message() so that
    // the messages aren't deleted in case the cron run fails and
    // we don't get a chance to restore them below.
    $saved_messages = drupal_set_message();

    // Invoke the cron hooks of all enabled modules.
    if (variable_get('poormanscron_log_progress', 0) == 1) {

With this one:

// Get the current Drupal messages. Use drupal_set_message() so that
    // the messages aren't deleted in case the cron run fails and
    // we don't get a chance to restore them below.
    $saved_messages = drupal_set_message();

    // Add poorsman to Request, in order to know that poorsman cron is running    	
    if (strlen($_REQUEST[q])==0){
    	$_REQUEST[q] .= '?poorsman=T';
    } else {
      	$_REQUEST[q] .= '&poorsman=T';
    }	
    
    // Invoke the cron hooks of all enabled modules.
    if (variable_get('poormanscron_log_progress', 0) == 1) {

Now if you want to know if the execution of a hook is because poorsmacron you only need to use:

if (!(strpos($_REQUEST[q], 'poorsman')=== FALSE) ){

	    		$cron_running = TRUE;
}

Hope this can help someone.

dave reid’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.