Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

In one vital part of code I started to get "Trying to get a property on a non-object" type of errors. So I wanted to investigate it.

var_dump($download);
die();

Gives:

array(3) {
  [1]=>
  array(5) {
    [5]=>
    object(stdClass)#156 (11) {
      ["idDownload"]=>
      string(1) "5"
      ...
    }
    [6]=>
    object(stdClass)#155 (11) {
      ["idDownload"]=>
      string(1) "6"
      ...
    }
    [7]=>
    object(stdClass)#151 (11) {
      ["idDownload"]=>
      string(1) "7"
      ...
    }
    [8]=>
    object(stdClass)#185 (11) {
      ["idDownload"]=>
      ...
    }
    [10]=>
    object(stdClass)#177 (11) {
      ["idDownload"]=>
      string(2) "10"
      ...
    }
  }
  [2]=>
  array(5) {
    [5]=>
    object(stdClass)#186 (11) {
      ["idDownload"]=>
      string(1) "5"
      ...
    }
    [6]=>
    object(stdClass)#155 (11) {
      ["idDownload"]=>
      string(1) "6"
      ...
    }
    [7]=>
    object(stdClass)#151 (11) {
      ["idDownload"]=>
      string(1) "7"
      ...
    }
    [10]=>
    object(stdClass)#177 (11) {
      ["idDownload"]=>
      string(2) "10"
      ...
    }
  }
  [3]=>
  array(5) {
    [5]=>
    object(stdClass)#184 (11) {
      ["idDownload"]=>
      string(1) "5"
      ...
    }
    [6]=>
    object(stdClass)#155 (11) {
      ["idDownload"]=>
      string(1) "6"
      ...
    }
    [7]=>
    object(stdClass)#151 (11) {
      ["idDownload"]=>
      string(1) "7"
      ...
    }
    [8]=>
    object(stdClass)#185 (11) {
      ["idDownload"]=>
      string(1) "8"
      ...
    }
    [10]=>
    object(stdClass)#177 (11) {
      ["idDownload"]=>
      string(2) "10"
      ...
    }
  }
}

But if I'll switch to kpr() like this:

kpr($download);
//die();

I get this:

Screenshot

Why can it happen? And can how I get kpr() to work? using var_dump() in form debugging is not really an option.

share|improve this question
    
Note: I don't think it's really a bug in devel module, because I know for a fact that something is wrong with my data. It's just that on var_dump() objects 5 and 6 looks exactly alike, and on kpr() they don't. –  Mołot Feb 7 at 12:40
add comment

1 Answer 1

up vote 2 down vote accepted

$download[1][6] and $download[2][6] are the exact same object (object(stdClass)#155), not just two objects with equal values. To avoid potential infinite recursion, Krumo (the k in kpr()) only display a single object once. The screenshot shows this, $download[2][6] is displayed as "∞ (Recursion)" because the object is already displayed (but collapsed in the screenshot) above as $download[1][6].

var_dump() does not have this limitation as it does not try to prevent infinite recursion.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.