Commit 4446c150 authored by mikeytown2's avatar mikeytown2

Issue #1905858 by mikeytown2: Fix for printing complex objects.

parent 4bb37b44
......@@ -2013,9 +2013,6 @@ function httprl_queue_background_callback(&$args, &$result = NULL) {
if (isset($callback_options['options']) && is_array($callback_options['options'])) {
$options += $callback_options['options'];
}
if (empty($options['headers']['Host']) && !empty($_SERVER['HTTP_HOST'])) {
$options['headers']['Host'] = $_SERVER['HTTP_HOST'];
}
// Send Request.
return httprl_request($url, $options);
}
......@@ -2390,6 +2387,38 @@ function httprl_lock_release($name) {
}
}
/**
* If $data is bool or strlen = 0 use var_export. Recursively go deeper.
*
* @param $data
* Data In.
* @param $level (optional)
* At what level of the array/object are we at.
*
* @return
* $data
*/
function httprl_print_empty(&$data, $level = 0) {
$level++;
if ($level < 10 ) {
if (is_object($data)) {
foreach ($data as $key => $values) {
$data->{$key} = httprl_print_empty($values, $level);
}
}
elseif (is_array($data)) {
foreach ($data as &$values) {
$values = httprl_print_empty($values, $level);
}
}
elseif (is_bool($data) || strlen($data) == 0) {
$data = strtoupper(var_export($data, TRUE));
}
}
return $data;
}
/**
* Pretty print data.
*
......@@ -2402,40 +2431,8 @@ function httprl_pr($data) {
// Get extra arguments passed in.
$data = func_get_args();
// If bool or null print out the dump of that variable.
foreach ($data as &$v) {
if (is_array($v) || is_object($v)) {
foreach ($v as &$va) {
if (is_array($va) || is_object($va)) {
foreach ($va as &$val) {
if (is_array($val) || is_object($val)) {
foreach ($val as &$valu) {
if (is_array($valu) || is_object($valu)) {
foreach ($valu as &$value) {
if (!is_array($value) && !is_object($value) && (is_bool($value) || is_null($value) || empty($v))) {
$value = strtoupper(var_export($value, TRUE));
}
}
}
elseif (is_bool($valu) || is_null($valu) || empty($valu)) {
$valu = strtoupper(var_export($valu, TRUE));
}
}
}
elseif (is_bool($val) || is_null($val) || empty($val)) {
$val = strtoupper(var_export($val, TRUE));
}
}
}
elseif (is_bool($va) || is_null($va) || empty($va)) {
$va = strtoupper(var_export($va, TRUE));
}
}
}
elseif (is_bool($v) || is_null($v) || empty($v)) {
$v = strtoupper(var_export($v, TRUE));
}
}
// If bool or strlen = 0 use var_export on that variable.
$data = httprl_print_empty($data);
// Merge into base array if only one argument passed in.
if (count($data) == 1) {
......
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