Closed (outdated)
Project:
Devel
Version:
7.x-1.x-dev
Component:
devel
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Nov 2012 at 21:33 UTC
Updated:
14 Apr 2019 at 20:49 UTC
Jump to comment: Most recent
And.. here is my original motivation for
#1853112: Replacement for Krumo?
I had a strange case where a dpm($node) would change the way that Drupal works.
In one case, the node was rendered by an advanced_forum template. In another case it was rendered by a theme node.tpl.php.
Ouch!
After hours of pain, I can now present sth reproducible:
function testme() {
$x = new stdClass;
$x->foo = array('bar');
$is_reference = _check_ref($x, 'foo');
dpm($is_reference ? 'yes' : 'no');
// Let's do it again, to show that the side effect is not caused by repeated _check_ref().
$is_reference = _check_ref($x, 'foo');
dpm($is_reference ? 'yes' : 'no');
dpm($x);
$is_reference = _check_ref($x, 'foo');
dpm($is_reference ? 'yes' : 'no');
}
function _check_ref($obj, $key) {
$orig = $obj->$key;
$c = clone $obj;
$c->$key = 'tmp';
$is_reference = ($obj->$key === $c->$key);
$c->$key = $orig;
return $is_reference;
}
Result:
no
no
(krumo output)
yes
Pretty bad, isn't it?
Comments
Comment #1
donquixote commentedThat's on PHP 5.3.5
Comment #2
donquixote commentedbetter title
Comment #3
donquixote commentedAnd, just saying, krumong()->dpm() does not have this effect.
EDIT:
I only tested this for objects so far, not for arrays.
Comment #4
donquixote commentedUpdate:
- krumo does have this side effect on objects, but not on arrays.
- krumong does not have this side effect, neither for arrays nor for objects.
I suppose there is some PHP 4.x logic in krumo causing this mess.
Comment #5
salvisWe've seen unexplained odd behavior before, after calls to krumo, and this may well be the cause.
It's rare that it makes a difference, but when it does, it's really nasty!
Thank you for the analysis and for your work in #1853112: Replacement for Krumo?!
Comment #6
ttkaminski commentedWow, this is a major bug. I just started using dpm() recently and ran into this problem right away. I created a module that displays all forms so that I can easily alter and style them.
However, because of this bug, the node fields will become corrupted in the
template_preprocess_node()resulting in a corrupt $node object for subsequent preprocess_node hooks.Comment #7
ttkaminski commentedI installed krumong and the integration patch for devel #1853112: Replacement for Krumo? and I no longer have any corruption issues with
dpm(). Thanks @donquixote!Comment #8
donquixote commentedHere is an interesting background article.
Seems to be a problem in PHP itself. So we should be careful not to blame the authors of Krumo.
http://float-middle.blogspot.de/2010/02/php-references-to-array-elements...
Comment #9
cmonnow commentedIf it doesn't already, this bug should probably have a higher profile. It seems somewhat serious when one of the primary methods of debugging could cause such unexpected results.
Comment #10
frobIt is quite possible that this nasty bug is related #2366797: Running dpm on global $user object logs the user in as user 1.
Comment #11
willzyx commentedClosing for lack of activity. Feel free to reopen if the issue still exists