Leaking object?

Hey Kirbyists,

I’ve noticed a strange behavior when I’m var_dump’ing in my templates, for example

$list = $page->children()->visible()->sortBy('date', 'desc', 'time', 'desc')->paginate(7);
var_dump( $list );

Just barfs out everything including all sorts of sensitive informations about the entire site, instead of just its scope

  protected 'page' => 
      public 'kirby' => 
          public 'roots' => 
              public 'index' => string '******' (length=12)
              public 'site' => string '******' (length=43)
              public 'content' => string '******' (length=46)
              public 'avatars' => string '******' (length=53)
              public 'thumbs' => string '******' (length=45)
          public 'urls' => 
              public 'index' => string '******' (length=26)
              public 'content' => string '******' (length=34)
              public 'avatars' => string '******' (length=41)
              public 'thumbs' => string '******' (length=33)
          public 'cache' => 
              protected 'options' => 
                array (size=0)
          public 'path' => string '******' (length=7)
          public 'options' => 
            array (size=64)
              'url' => boolean false
              'timezone' => string 'Europe/Copenhagen' (length=17)
              'license' => string '******' (length=39)
              'rewrite' => boolean true
              'error' => string '******' (length=5)
              'home' => string '******' (length=7)
              'locale' => string 'en_US.UTF8' (length=10)
              'routes' => 

I think a couple of thousands of lines gets puked out from this, I can’t even find what I’m looking for.

As far as I remember from another CMS, this can happen when something leaks out or is this really just the default behavior of Kirby ?

…or maybe all of this actually is within its scope - not everything seems to be polluted like the above.

It is the default behavior. Since you are dumping out not a string or an int, but a whole object that has pointers to all kind of other objects (as you can see to the kirby object, which points to a Kirby\Roots object etc.).

1 Like

Thanks @distantnative, I would just make sure that it in fact was the case :+1:

For others interested in more readable dumps, see Using var_dump or print_r on Kirby collections? for some great suggestions.

1 Like