Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Watch Value for Array vs Object Access in Xdebug #976

Open
stgpepper opened this issue Oct 24, 2024 · 2 comments
Open

Incorrect Watch Value for Array vs Object Access in Xdebug #976

stgpepper opened this issue Oct 24, 2024 · 2 comments

Comments

@stgpepper
Copy link

PHP version: 8.2
Xdebug version: 3.3.1
VS Code extension version: v1.35.0

Your launch.json:

    "version": "0.2.0",
    "configurations": [
        {
            "name": "Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/var/www/html/": "${workspaceFolder}/src/"
            },
            "log": false
        },
    ]
}

Xdebug php.ini config: -

Xdebug logfile (from setting xdebug.log in php.ini): -
VS Code extension logfile (from setting "log": true in launch.json): -

Code snippet to reproduce:

$myarr['myval'] = "test";
echo $myarr['myval']."\n";
echo $myarr->myval;

I added two watch expressions:

$myarr['myval']
$myarr->myval
Both watches incorrectly show the value "test", even though only the array access $myarr['myval'] is valid and the object access $myarr->myval should be null or result in an error.
image

@zobo
Copy link
Contributor

zobo commented Oct 24, 2024

I'll do a quick test to see if this "issue" is part of Xdebug or the plugin.

@zobo
Copy link
Contributor

zobo commented Oct 28, 2024

Hi. Sorry for the late reply. This does not present here.
PHP 8.2.8
Xdebug: 3.4.0-alpha

image

-> evaluateRequest
{ command: 'evaluate',
  arguments: { expression: "$myarr['myval']", frameId: 1, context: 'watch' },
  type: 'request',
  seq: 11 }

xd(1) <- eval -i 12 -- JG15YXJyWydteXZhbCdd
xd(1) -> <?xml version="1.0" encoding="iso-8859-1"?><response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="12"><property type="string" size="4" encoding="base64"><![CDATA[dGVzdA==]]></property></response>

<- evaluateResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 11,
  command: 'evaluate',
  success: true,
  body: { result: '"test"', variablesReference: 0 } }

and

-> evaluateRequest
{ command: 'evaluate',
  arguments: { expression: '$myarr->myval', frameId: 1, context: 'watch' },
  type: 'request',
  seq: 12 }

xd(1) <- eval -i 13 -- JG15YXJyLT5teXZhbA==
xd(1) -> <?xml version="1.0" encoding="iso-8859-1"?><response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="eval" transaction_id="13"><property type="null"></property></response>
<- evaluateResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 12,
  command: 'evaluate',
  success: true,
  body: { result: 'null', variablesReference: 0 } }

Please repeat your test and set log to true and attack the whole output in Debug Console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants