Commit 0c6e226c authored by mikeytown2's avatar mikeytown2

Issue #2548999 by mikeytown2: create httprl_call_user_func_array_async();...

Issue #2548999 by mikeytown2: create httprl_call_user_func_array_async(); simple wrapper for background function calls.
parent 26382f96
......@@ -549,27 +549,13 @@ echo httprl_pr($results);
Run a function in the background. Notice that there is no return or printed key
in the callback options.
Run a function in the background. Notice that there is no return.
<?php
// Bail out here if background callbacks are disabled.
if (!httprl_is_background_callback_capable()) {
return FALSE;
}
// Call watchdog('httprl-test', 'background watchdog call done');
// in the background/async.
httprl_call_user_func_array_async('watchdog', array('httprl-test', 'background watchdog call done 2'));
// Setup callback options array; call watchdog in the background.
$callback_options = array(
array(
'function' => 'watchdog',
),
'httprl-test', 'background watchdog call done', array(), WATCHDOG_DEBUG,
);
// Queue up the request.
httprl_queue_background_callback($callback_options);
// Execute request.
httprl_send_request();
?>
......
......@@ -3510,3 +3510,25 @@ function httprl_run_multiple($callback, $data) {
}
return $results;
}
/**
* Run the callback with the given params in the background.
*
* @param string $callback
* The function to run
* @param array $param_arr
* The arguments to pass along to the function.
*/
function httprl_call_user_func_array_async($callback, array $param_arr) {
if (!httprl_is_background_callback_capable()) {
call_user_func_array($callback, $param_arr);
}
else {
// Setup callback options array; call $callback in the background.
$callback_options = array_merge(array(array('function' => $callback)), $param_arr);
// Queue up the request.
httprl_queue_background_callback($callback_options);
// Execute request.
httprl_send_request();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment