Commit d4710a3c authored by mikeytown2's avatar mikeytown2

Issue #1653394 by mikeytown2: only capture printed output if requested to do so.

parent 8a11fc24
......@@ -1327,7 +1327,7 @@ function httprl_post_processing($id, &$responses, &$streams, $timer_name) {
}
// If this is a background callback request, extract the data and return.
if (isset($result->options['internal_states']['background_function_return']) && $result->headers['content-type'] == 'application/x-www-form-urlencoded') {
if (isset($result->options['internal_states']['background_function_return']) && isset($result->headers['content-type']) && $result->headers['content-type'] == 'application/x-www-form-urlencoded') {
httprl_extract_background_callback_data($result);
return;
}
......@@ -1441,11 +1441,15 @@ function httprl_run_callback(&$result) {
$result->options['callback'][0] = &$result;
// Capture anything printed out.
ob_start();
if (array_key_exists('printed', $callback_options)) {
ob_start();
}
// Call function.
$callback_options['return'] = call_user_func_array($callback_options['function'], $result->options['callback']);
$callback_options['printed'] = ob_get_contents();
ob_end_clean();
if (array_key_exists('printed', $callback_options)) {
$callback_options['printed'] = ob_get_contents();
ob_end_clean();
}
// Add options back into the callback array.
if (isset($result->options['callback'])) {
......@@ -1495,9 +1499,6 @@ function httprl_queue_background_callback(&$args, &$result = NULL) {
if (!isset($callback_options['return'])) {
$callback_options['return'] = '';
}
if (!isset($callback_options['printed'])) {
$callback_options['printed'] = '';
}
if (!isset($callback_options['function'])) {
$callback_options['function'] = '';
}
......@@ -1549,12 +1550,14 @@ function httprl_queue_background_callback(&$args, &$result = NULL) {
),
'internal_states' => array(
'background_function_return' => &$callback_options['return'],
'background_function_printed' => &$callback_options['printed'],
'background_function_args' => &$args,
),
'blocking' => $mode,
'method' => 'POST',
);
if (isset($callback_options['printed'])) {
$options['internal_states']['background_function_printed'] = &$callback_options['printed'];
}
if (isset($callback_options['options']) && is_array($callback_options['options'])) {
$options += $callback_options['options'];
}
......
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