Index: branches/unlabeled/unlabeled-1.59.2/core/kernel/utility/debugger.php =================================================================== diff -u -r5778 -r5782 --- branches/unlabeled/unlabeled-1.59.2/core/kernel/utility/debugger.php (.../debugger.php) (revision 5778) +++ branches/unlabeled/unlabeled-1.59.2/core/kernel/utility/debugger.php (.../debugger.php) (revision 5782) @@ -216,10 +216,9 @@ $ret .= 'no file information available'; } - // ensure parameter value is not longer then 200 symbols if ($has_args) { - $this->processTraceArguments($traceRec['args']); - $args = $this->highlightString($this->print_r($traceRec['args'], true)); + // if parameter value is longer then 200 symbols, then leave only first 50 + $args = $this->highlightString($this->print_r($traceRec['args'], true, 50, 200)); $ret .= ''; } $i++; @@ -278,6 +277,7 @@ $skip_classes = Array( defined('APPLICATION_CLASS') ? APPLICATION_CLASS : 'kApplication', 'kFactory', + 'kUnitConfigReader', 'TemplateParser', ); @@ -290,67 +290,25 @@ return false; } - function processTraceObject(&$object) + /** + * Advanced version of print_r (for debugger only). Don't print objects recursively + * + * @param Array $array + * @param bool $return_output return output or print it out + * @param int $cut_first cut first N symbols, don't cut anything if -1 specified + * @package int $cut_min_length cut only of this length of string or greather + * @return string + */ + function print_r(&$array, $return_output = false, $cut_first = -1, $cut_min_length = -1) { - $attribute_names = get_class_vars( get_class($object) ); - if (!$attribute_names) return 'NO_ATTRIBUTES'; - - // $attribute_value - default value for this attribute, not used here - foreach ($attribute_names as $attribute_name => $attribute_value) { - if (is_object($object->$attribute_name)) { - // it is object - $object_class = get_class($object->$attribute_name); - if (!in_array($object_class, $this->RecursionStack)) { - // object [not in recursion stack] - if ($this->IsBigObject($object->$attribute_name)) { - continue; - } - - array_push($this->RecursionStack, $object_class); - $this->processTraceObject($object->$attribute_name); - array_pop($this->RecursionStack); - } - else { - // object [in recursion stack] - $object->$attribute_name = '**** RECURSION ***'; - } - } - elseif (is_array($object->$attribute_name)) { - // it is array - $this->processTraceArguments($object->$attribute_name); - } - else { - $object->$attribute_name = $this->cutStringForHTML($object->$attribute_name); - } - } - } - - function processTraceArguments(&$traceArgs) - { - if (!$traceArgs) return 'EMPTY_ARRAY'; - $array_keys = array_keys($traceArgs); - foreach ($array_keys as $arg_id) { - $arg_value =& $traceArgs[$arg_id]; - - if (is_object($arg_value)) { - $this->processTraceObject($arg_value); - } - elseif (is_array($arg_value)) { - $this->processTraceArguments($arg_value); - } - else { - $traceArgs[$arg_id] = $this->cutStringForHTML($arg_value); - } - } - } - - function print_r(&$array, $return_output = false) - { static $first_line = true, $tab_count = -1; if (is_null($array)) { return 'NULL'; }elseif (!is_array($array)) { + if ($cut_min_length != -1 && strlen($array) > $cut_min_length) { + $array = substr($array, 0, $cut_first).' ...'; + } return $array; } @@ -367,7 +325,7 @@ foreach ($array_keys as $key) { switch (gettype($array[$key])) { case 'array': - $output .= $tabsign.'['.$key.'] = '.$this->print_r($array[$key]); + $output .= $tabsign.'['.$key.'] = '.$this->print_r($array[$key], true, 50, 200); break; case 'boolean': @@ -377,6 +335,9 @@ case 'integer': case 'double': case 'string': + if ($cut_min_length != -1 && strlen($array[$key]) > $cut_min_length) { + $array[$key] = substr($array[$key], 0, $cut_first).' ...'; + } $output .= $tabsign.'['.$key.'] = '.$array[$key]."\n"; break; @@ -390,6 +351,11 @@ $output .= $tabsign.'['.$key."] = NO_ATTRIBUTES\n"; } else { + if ($this->IsBigObject($array[$key])) { + $output .= $tabsign.'['.$key.'] = SKIPPED (class: '.get_class($array[$key]).")\n"; + break; + } + // $attribute_value - default value for this attribute, not used here foreach ($attribute_names as $attribute_name => $attribute_value) { if (is_object($array[$key]->$attribute_name)) { @@ -398,21 +364,21 @@ if (!in_array($object_class, $this->RecursionStack)) { // object [not in recursion stack] if ($this->IsBigObject($array[$key]->$attribute_name)) { - $output .= $tabsign.'['.$attribute_name.'] = SKIPPED'."\n"; + $output .= $tabsign.'['.$attribute_name.'] = SKIPPED (class: '.$object_class.")\n"; continue; } array_push($this->RecursionStack, $object_class); - $output .= $this->print_r($array[$key]->$attribute_name); + $output .= $this->print_r($array[$key]->$attribute_name, true, 50, 200); array_pop($this->RecursionStack); } else { // object [in recursion stack] - $output .= $tabsign.'['.$attribute_name.'] = **** RECURSION ***'."\n"; + $output .= $tabsign.'['.$attribute_name.'] = *** RECURSION *** (class: '.$object_class.")\n"; } } else { - $output .= $tabsign.'['.$attribute_name.'] = '.$this->print_r($array[$key]->$attribute_name)."\n"; + $output .= $tabsign.'['.$attribute_name.'] = '.$this->print_r($array[$key]->$attribute_name, true, 50, 200)."\n"; } } } @@ -433,7 +399,15 @@ } $tab_count--; + + if ($return_output) { return $output; + } + else { + echo $output; + } + + return true; } /**