Skip to content

Commit 4b28be1

Browse files
committed
Merge branch 'xdebug_3_4'
2 parents 8fd1a39 + 7727a72 commit 4b28be1

File tree

3 files changed

+98
-24
lines changed

3 files changed

+98
-24
lines changed

src/lib/var_export_xml.c

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -412,34 +412,14 @@ static int xdebug_object_element_export_xml_node(xdebug_object_item *item_nptr,
412412

413413
#if PHP_VERSION_ID >= 80400
414414
{
415-
zval tmp_for_is_ptr;
416-
zval *tmp_value_for_ptr = NULL;
415+
zend_property_info *prop_info = Z_PTR_P((*item)->zv);
416+
HashTable *props = zend_get_properties_no_lazy_init((*item)->zobj);
417417

418+
// IS_PTR is for properties with hooks
418419
if (Z_TYPE_P((*item)->zv) == IS_PTR) {
419-
// IS_PTR is for properties with hooks
420-
zend_property_info *prop_info = Z_PTR_P((*item)->zv);
421-
const char *unmangled_name_cstr;
422-
zend_string *unmangled_name;
423-
424-
if ((prop_info->flags & ZEND_ACC_VIRTUAL) && !prop_info->hooks[ZEND_PROPERTY_HOOK_GET]) {
425-
return 0;
426-
}
427-
428-
unmangled_name_cstr = zend_get_unmangled_property_name(prop_info->name);
429-
unmangled_name = zend_string_init(unmangled_name_cstr, strlen(unmangled_name_cstr), false);
430-
431-
tmp_value_for_ptr = zend_read_property_ex(prop_info->ce, (*item)->zobj, unmangled_name, /* silent */ true, &tmp_for_is_ptr);
432-
433-
zend_string_release_ex(unmangled_name, false);
434-
if (EG(exception)) {
435-
return 0;
436-
}
420+
zval *tmp_value_for_ptr = zend_symtable_str_find(props, ZSTR_VAL(prop_info->name), ZSTR_LEN(prop_info->name));
437421

438422
xdebug_var_export_xml_node(&tmp_value_for_ptr, tmp_fullname ? tmp_fullname : NULL, node, options, level + 1);
439-
440-
if (tmp_value_for_ptr == &tmp_for_is_ptr) {
441-
zval_ptr_dtor(tmp_value_for_ptr);
442-
}
443423
} else {
444424
xdebug_var_export_xml_node(&((*item)->zv), tmp_fullname ? tmp_fullname : NULL, node, options, level + 1);
445425
}

tests/debugger/bug02356.inc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
class TEEST {
4+
public string $time_string {
5+
get => date_create()->format('H:i:s');
6+
}
7+
8+
public String $AAA = '' {
9+
get {
10+
if (str_contains($this->AAA, ':')) {
11+
$Sub_Script_Depth = explode(':', $this->AAA)[1];
12+
$Sub_Script_Depth = (int)$Sub_Script_Depth + 1;
13+
$New_Script_Depth = explode(':', $this->AAA)[0] . ':' . $Sub_Script_Depth;
14+
$this->AAA = $New_Script_Depth;
15+
return $this->AAA;
16+
} else {
17+
$this->AAA .= ':0';
18+
}
19+
return $this->AAA;
20+
}
21+
set (String $value) {
22+
$this->AAA = $value;
23+
}
24+
}
25+
26+
public function __construct()
27+
{
28+
$this->main();
29+
}
30+
31+
public function main()
32+
{
33+
$this->AAA = 'Hello World.';
34+
$fff = $this->AAA;
35+
echo $fff;
36+
}
37+
}
38+
39+
$aaa = new TEEST();

tests/debugger/bug02356.phpt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
--TEST--
2+
Test for bug #2356: Reading properties with get hooks may modify property value
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__) . '/bug02356.inc';
12+
13+
$commands = array(
14+
'step_into',
15+
'breakpoint_set -t line -n 28',
16+
'run',
17+
'context_get -c 0',
18+
'context_get -c 0',
19+
'context_get -c 0',
20+
'detach',
21+
);
22+
23+
dbgpRunFile( $filename, $commands );
24+
?>
25+
--EXPECTF--
26+
<?xml version="1.0" encoding="iso-8859-1"?>
27+
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file://bug02356.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>
28+
29+
-> step_into -i 1
30+
<?xml version="1.0" encoding="iso-8859-1"?>
31+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="1" status="break" reason="ok"><xdebug:message filename="file://bug02356.inc" lineno="%d"></xdebug:message></response>
32+
33+
-> breakpoint_set -i 2 -t line -n 28
34+
<?xml version="1.0" encoding="iso-8859-1"?>
35+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="{{PID}}0001"></response>
36+
37+
-> run -i 3
38+
<?xml version="1.0" encoding="iso-8859-1"?>
39+
<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://bug02356.inc" lineno="28"></xdebug:message></response>
40+
41+
-> context_get -i 4 -c 0
42+
<?xml version="1.0" encoding="iso-8859-1"?>
43+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="4" context="0"><property name="$this" fullname="$this" type="object" classname="TEEST" children="1" numchildren="1" page="0" pagesize="32"><property name="AAA" fullname="$this-&gt;AAA" facet="public" type="string" size="0" encoding="base64"><![CDATA[]]></property></property></response>
44+
45+
-> context_get -i 5 -c 0
46+
<?xml version="1.0" encoding="iso-8859-1"?>
47+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="5" context="0"><property name="$this" fullname="$this" type="object" classname="TEEST" children="1" numchildren="1" page="0" pagesize="32"><property name="AAA" fullname="$this-&gt;AAA" facet="public" type="string" size="0" encoding="base64"><![CDATA[]]></property></property></response>
48+
49+
-> context_get -i 6 -c 0
50+
<?xml version="1.0" encoding="iso-8859-1"?>
51+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="6" context="0"><property name="$this" fullname="$this" type="object" classname="TEEST" children="1" numchildren="1" page="0" pagesize="32"><property name="AAA" fullname="$this-&gt;AAA" facet="public" type="string" size="0" encoding="base64"><![CDATA[]]></property></property></response>
52+
53+
-> detach -i 7
54+
<?xml version="1.0" encoding="iso-8859-1"?>
55+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="detach" transaction_id="7" status="stopping" reason="ok"></response>

0 commit comments

Comments
 (0)