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 ?
Comment | File | Size | Author |
---|---|---|---|
#26 | krumo_with_protected_private_and_PUBLIC.patch | 971 bytes | joe_carvajal |
|
Comments
Comment #1
fgmNote: similar issue regarding property_exists() as get_object_vars(), apparently in a state of flux: http://bugs.php.net/bug.php?id=45743
Comment #2
Toktik CreditAttribution: Toktik commentedsame problem.
Comment #3
star-szrClosed #1246380: Expose module defined objects and their properties in Krumo as a duplicate of this issue.
Comment #4
torotil CreditAttribution: torotil commentedThe 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.
Comment #5
torotil CreditAttribution: torotil commentedHere'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...
Comment #6
torotil CreditAttribution: torotil commentedComment #7
torotil CreditAttribution: torotil commentedAnd 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."
Comment #8
fgmAssuming we want to assume krumo maintenance for devel, such a change probably needs tests around the part being changed.
Comment #9
salvisSee
#1003570-1: Krumo outputs DateTime on date objects - might as well just print the text time
and
#1002462-7: Show "trail of keys" for nested krumo items
for Moshe's view on this.
Comment #10
rudiedirkx CreditAttribution: rudiedirkx commentedPatch in #5 works fine for devel 7.x-1.3. Acceptable for me.
Comment #11
rudiedirkx CreditAttribution: rudiedirkx commentedNo, it doesn't.
stdClass
objects (quite common in Drupal) aren't rendered properly.I changed line 978 from
to
and now it is acceptable.
Comment #12
salvisThank you for your work on this, but donquixote is rewriting krumo in #1853112: Replacement for Krumo?.
Please chime in there...
Comment #13
rudiedirkx CreditAttribution: rudiedirkx commentedThat'll take another year or so though. Long live open source communities.
Comment #14
salvisHehehe, 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! :-)
Comment #15
mbaggett CreditAttribution: mbaggett commentedSince 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.
Comment #16
moshe weitzman CreditAttribution: moshe weitzman commentedDevel 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!
Comment #17
torotil CreditAttribution: torotil commentedJust for convenience: Here's the patch including the suggestion from comment #11.
Comment #18
Mav-im CreditAttribution: Mav-im commentedHi 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".
Comment #19
nwoodland CreditAttribution: nwoodland commentedI found the patch from #18 to be extremely helpful. Thanks Mav-im and everyone else who worked on this.
Comment #20
salvis#18 looks nice and clean, except, please don't touch any unrelated lines:
Leave the bad indenting as it is. We want to touch Krumo as little as possible.
Comment #21
Mav-im CreditAttribution: Mav-im commented>> #18 looks nice and clean, except, please don't touch any unrelated lines:
Sorry, PHPStorm insisted this )
Please, change it if needed.
Comment #22
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedpatch works well
Comment #23
kenorb CreditAttribution: kenorb commentedComment #24
Chris CharltonStatus bump. :)
Comment #25
salvisSo do I... :-)
Comment #26
joe_carvajalPatch in #18 worked as a charm for me... I reupload this patch without last unneeded lines.
Comment #28
salvisOk, thanks all!
Comment #29
joe_carvajalThank you Salvis!
Edited, I thought there was a problem but there's no problem.
Comment #30
joe_carvajal