Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#16897 closed defect (bug) (invalid)

wp_schedule_event with array of $args does not pass array to action

Reported by: commentluv's profile commentluv Owned by:
Milestone: Priority: normal
Severity: major Version: 3.1
Component: Cron API Keywords:
Focuses: Cc:

Description

when I schedule an event with an array of $args , when the action is called by the cron, it does not pass the callback function the array, it sends a single string value.

action is registered with this

add_action('fhprw_action','fhprw_check_fetch'); 

function fhprw_check_fetch($args){
  $type=$args['type'];
//do stuff according to $type
  update_option('debug_args',$args);
}

when I use

do_action('fhprw_action',array('type'=>'uk'));

the option 'debug_args' is a serialised array as would be expected
a:1:{s:4:"type";s:4:"uk";}

but if an event is scheduled with

wp_schedule_event(time()+60,'twicedaily','fhprw_action',array('type'=>'uk'));

then when the event happens after 1 minute, the callback function receives $args as a string 'uk'

the option 'debug_args' is a single string of
uk

Change History (2)

#1 @commentluv
14 years ago

  • Resolution set to invalid
  • Status changed from new to closed

ok figured this out about a pico second after wpmuguru answered me on twitter

scheduled cron callback functions receive arg1,arg2,arg3 , not as an array

#2 @ocean90
14 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.