class C { protected $foo = 'bar'; }
$c = new C;
dsm($c);
dprint_r($c);

The first call will display $c as an empty object, while the second will correctly display the $c->foo property.

This is due to krumo::__vars(&$data) using get_object_vars() instead of the Reflection API to introspect objects. get_object_vars() specifically hides non-public members (see http://php.net/manual/en/function.get-object-vars.php for an example illustrating this).

Which, incidently, begs for another question: not even considering the fact that libraries (like Krumo) are not supposed to be in Drupal CVS, can we package Krumo within a Drupal module under the GPL2+ since Krumo is licensed under the LGPL and not the GPL ? Did we get a specific exemption ? AIUI redistribution itself does not seem to be a problem, due to the specifics of the LGPL. But redistributing it under the GPL as is implied ?

Maybe we should do as Drush does for the Pear console table, download it on first run, not within our package ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fgm’s picture

Note: similar issue regarding property_exists() as get_object_vars(), apparently in a state of flux: http://bugs.php.net/bug.php?id=45743

Toktik’s picture

Version: 6.x-1.x-dev » 7.x-1.2

same problem.

star-szr’s picture

torotil’s picture

The referenced bug in #1 has been fixed since 2 years before this bug report was created.

There are two upstream feature requests for krumo that have been untouched since 2007:
http://sourceforge.net/tracker/?func=detail&aid=1703502&group_id=194198&...
http://sourceforge.net/tracker/?func=detail&aid=1703503&group_id=194198&...

The last krumo-version is from 2007.

Subscribing.

torotil’s picture

Status: Active » Needs review
FileSize
1.17 KB

Here's a patch that hacks the bundled krumo to use the Reflection-API to expose protected and private properties.

I think we can as well start maintaining it ourselves - the last commit to krumo's repository was 2008. http://sourceforge.net/projects/krumo/stats/scm?repo=SVNRepository&dates...

torotil’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
torotil’s picture

Issue tags: -licensing, -Legal

And AFAIK the LGPL allows redistribution under GPL. From https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License :

"One feature of the LGPL is that one can convert any LGPLed piece of software into a GPLed piece of software (section 3 of the license). This feature allows for direct reuse of LGPLed code in GPLed libraries and applications."

fgm’s picture

Status: Needs review » Needs work

Assuming we want to assume krumo maintenance for devel, such a change probably needs tests around the part being changed.

salvis’s picture

rudiedirkx’s picture

Patch in #5 works fine for devel 7.x-1.3. Acceptable for me.

rudiedirkx’s picture

No, it doesn't. stdClass objects (quite common in Drupal) aren't rendered properly.

I changed line 978 from

  if ($_is_object) {

to

  if ($_is_object && get_class($data) != 'stdClass') {

and now it is acceptable.

salvis’s picture

Category: bug » feature
Status: Needs work » Closed (won't fix)

Thank you for your work on this, but donquixote is rewriting krumo in #1853112: Replacement for Krumo?.

Please chime in there...

rudiedirkx’s picture

That'll take another year or so though. Long live open source communities.

salvis’s picture

Hehehe, I had to become Devel maintainer for some of my patches to get in...

It's no secret that we wanted to get rid of krumo. In the meantime you're free to use the patch...

That should make you happy!   :-)

mbaggett’s picture

Since nobody wants to maintain Krumo any more, and that I still really like Krumo and have some improvements/bugfixes I wish to make to it anyway, I've volunteered to be maintainer.

I've forked the code to github here: https://github.com/matthewbaggett/krumo and applied torotils patch.

Pull requests welcome.

moshe weitzman’s picture

Devel has added a few patches to its krumo over the years. Would be good if you would consider those on Github. After that, we could consider switching to using your project. Thanks!

torotil’s picture

Just for convenience: Here's the patch including the suggestion from comment #11.

Mav-im’s picture

Hi guys,
patch from #11 and #17 loses public properties when use __get and __set.

Attached patch which uses reflection to get protected and private properties and normal krumo algorithm to retrieve public properties.
Protected properties are suffixed with ":protected" and private properties are suffixed with ":private".

nwoodland’s picture

I found the patch from #18 to be extremely helpful. Thanks Mav-im and everyone else who worked on this.

salvis’s picture

Status: Closed (won't fix) » Needs review

#18 looks nice and clean, except, please don't touch any unrelated lines:

+++ b/krumo/class.krumo.php
@@ -988,18 +1011,18 @@ This is a list of all the values from the <code><b><?php echo realpath($ini_file
-      }
+    }
 
     // get real value
     //
     if ($_is_object) {
       $v =& $data->$k;
-      } else {
+    } else {
       $v =& $data[$k];
-      }
+    }
 
     krumo::_dump($v,$k);
-    } ?>
+  } ?>

Leave the bad indenting as it is. We want to touch Krumo as little as possible.

Mav-im’s picture

>> #18 looks nice and clean, except, please don't touch any unrelated lines:

Sorry, PHPStorm insisted this )
Please, change it if needed.

SocialNicheGuru’s picture

patch works well

kenorb’s picture

Status: Needs review » Reviewed & tested by the community
Chris Charlton’s picture

Status bump. :)

salvis’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, PHPStorm insisted this )

So do I... :-)

joe_carvajal’s picture

Status: Needs work » Needs review
FileSize
971 bytes

Patch in #18 worked as a charm for me... I reupload this patch without last unneeded lines.

  • salvis committed de728df on 7.x-1.x
    Issue #927690 by joe_carvajal, Mav-im, torotil: Add support to dsm() and...
salvis’s picture

Ok, thanks all!

joe_carvajal’s picture

Status: Fixed » Needs review

Thank you Salvis!

Edited, I thought there was a problem but there's no problem.

joe_carvajal’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.