Skip to content

Commit cc3ea63

Browse files
committed
Merged pull request xdebug#1047
* pr/1047: Fixed issue #2382: LazyProxyObject causes PHPStorm to drop out of debugging due to double XML attribute Issue #2382: Add test to show XML structure with double type property
2 parents 749ecb9 + 9e6ce72 commit cc3ea63

File tree

4 files changed

+62
-3
lines changed

4 files changed

+62
-3
lines changed

src/lib/var_export_xml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,10 @@ void xdebug_var_export_xml_node(zval **struc, xdebug_str *name, xdebug_xml_node
612612

613613
#if PHP_VERSION_ID >= 80400
614614
if (ce->type != ZEND_INTERNAL_CLASS && zend_object_is_lazy(Z_OBJ_P(*struc))) {
615-
xdebug_xml_add_attribute(node, "type", "object");
616615
if (zend_object_is_lazy_proxy(Z_OBJ_P(*struc))) {
617616
xdebug_xml_expand_attribute_value(node, "facet", "lazy-proxy");
618617
} else if (!zend_lazy_object_initialized(Z_OBJ_P(*struc))) {
618+
xdebug_xml_add_attribute(node, "type", "object");
619619
xdebug_xml_expand_attribute_value(node, "facet", "lazy-ghost");
620620

621621
break; /* Jump out of the function */

tests/debugger/bug02371-003.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ dbgpRunFile( $filename, $commands );
4040

4141
-> property_get -i 4 -n $user
4242
<?xml version="1.0" encoding="iso-8859-1"?>
43-
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="4"><property name="$user" fullname="$user" type="object" facet="lazy-proxy" type="object" classname="User" children="1" numchildren="2" page="0" pagesize="32"><property name="id" fullname="$user-&gt;id" facet="public" type="int"><![CDATA[43]]></property><property name="name" fullname="$user-&gt;name" facet="public" type="string" size="5" encoding="base64"><![CDATA[Qmx1ZXk=]]></property></property></response>
43+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="4"><property name="$user" fullname="$user" facet="lazy-proxy" type="object" classname="User" children="1" numchildren="2" page="0" pagesize="32"><property name="id" fullname="$user-&gt;id" facet="public" type="int"><![CDATA[43]]></property><property name="name" fullname="$user-&gt;name" facet="public" type="string" size="5" encoding="base64"><![CDATA[Qmx1ZXk=]]></property></property></response>
4444

4545
-> run -i 5
4646
<?xml version="1.0" encoding="iso-8859-1"?>
4747
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="5" status="break" reason="ok"><xdebug:message filename="file://bug02371-003.inc" lineno="20"></xdebug:message></response>
4848

4949
-> property_get -i 6 -n $user
5050
<?xml version="1.0" encoding="iso-8859-1"?>
51-
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="6"><property name="$user" fullname="$user" type="object" facet="lazy-proxy" type="object" classname="User" children="1" numchildren="2" page="0" pagesize="32"><property name="id" fullname="$user-&gt;id" facet="public" type="int"><![CDATA[43]]></property><property name="name" fullname="$user-&gt;name" facet="public" type="string" size="5" encoding="base64"><![CDATA[Qmx1ZXk=]]></property></property></response>
51+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="6"><property name="$user" fullname="$user" facet="lazy-proxy" type="object" classname="User" children="1" numchildren="2" page="0" pagesize="32"><property name="id" fullname="$user-&gt;id" facet="public" type="int"><![CDATA[43]]></property><property name="name" fullname="$user-&gt;name" facet="public" type="string" size="5" encoding="base64"><![CDATA[Qmx1ZXk=]]></property></property></response>
5252

5353
-> detach -i 7
5454
<?xml version="1.0" encoding="iso-8859-1"?>

tests/debugger/bug02382.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
class User
3+
{
4+
public int $id;
5+
public User $subUser;
6+
}
7+
8+
$user = new User();
9+
$reflection = new ReflectionClass(User::class);
10+
$user->subUser = $reflection->newLazyProxy(function (User $user): User {
11+
return new User();
12+
});
13+
14+
var_dump($user);

tests/debugger/bug02382.phpt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
--TEST--
2+
Test for bug #2382: LazyProxyObject causes PHPStorm to drop out of debugging
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/../utils.inc';
6+
check_reqs('PHP >= 8.4; dbgp');
7+
?>
8+
--FILE--
9+
<?php
10+
require 'dbgp/dbgpclient.php';
11+
$filename = dirname(__FILE__) . '/bug02382.inc';
12+
13+
$commands = array(
14+
"breakpoint_set -t exception -x *",
15+
"breakpoint_set -t line -f file://{$filename} -n 14",
16+
'run',
17+
'property_get -n $user',
18+
'detach',
19+
);
20+
21+
dbgpRunFile( $filename, $commands );
22+
?>
23+
--EXPECTF--
24+
<?xml version="1.0" encoding="iso-8859-1"?>
25+
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file://bug02382.inc" language="PHP" xdebug:language_version="" protocol_version="1.0" appid=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>
26+
27+
-> breakpoint_set -i 1 -t exception -x *
28+
<?xml version="1.0" encoding="iso-8859-1"?>
29+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="1" id="{{PID}}0001"></response>
30+
31+
-> breakpoint_set -i 2 -t line -f file://bug02382.inc -n 14
32+
<?xml version="1.0" encoding="iso-8859-1"?>
33+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="{{PID}}0002"></response>
34+
35+
-> run -i 3
36+
<?xml version="1.0" encoding="iso-8859-1"?>
37+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="3" status="break" reason="ok"><xdebug:message filename="file://bug02382.inc" lineno="14"></xdebug:message></response>
38+
39+
-> property_get -i 4 -n $user
40+
<?xml version="1.0" encoding="iso-8859-1"?>
41+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="4"><property name="$user" fullname="$user" type="object" classname="User" children="1" numchildren="1" page="0" pagesize="32"><property name="subUser" fullname="$user-&gt;subUser" facet="public lazy-proxy" type="object" classname="User" children="0" numchildren="0"></property></property></response>
42+
43+
-> detach -i 5
44+
<?xml version="1.0" encoding="iso-8859-1"?>
45+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="detach" transaction_id="5" status="stopping" reason="ok"></response>

0 commit comments

Comments
 (0)