Description | In a Netbeans PHP project, I want to debug a php file called via cURL.
When Netbeans starts the project in debug mode, it runs the browser to send a index.php request with XDEBUG_SESSION_START=netbeans-xdebug.
Then XDEBUG connects normally with the Netbeans debug server with a <init xmlns="urn:debugger_protocol_v1" ...> using an appid parameter value.
The same appid value is used in the <init> message for each of the other php files of the projet, as long as they are called by the browser with the debug cookie.
But if a PHP file uses cURL to send a GET request with the debug cookie, XDEBUG send again a <init xmlns="urn:debugger_protocol_v1" ...>, but with a different appid value.
The Netbeans server then doesn't answer, which blocks the execution of the php scripts. |
---|
Steps To Reproduce | I join 3 files.
The index.php file makes an AJAX call to page2.php, which returns a content got through a cURL call to page3.php.
It works perfectly in non debug mode.
In debug mode, with line 11 in page2.php to send the debug cookie in the cURL headers, the php execution is bloqued.
Of course, if line 11 in page2.php is commented, there is no execution problem, but page3.php cannot be debbugged. |
---|
Additional Information | I'm using XDEBUG 3.1.1 with Netbeans IDE 15, on Windows 10 Pro, build 19045.2486.
php -v returns :
PHP 8.1.0 (cli) (built: Nov 23 2021 21:48:28) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
with Xdebug v3.1.1, Copyright (c) 2002-2021, by Derick Rethans
Below is the communication between XDEBUG and the Netbeans server for the 3 joined files.
Start of index.php : appid="11040"
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///D:/....index.php" language="PHP" xdebug:language_version="8.1.0" protocol_version="1.0" appid="11040" idekey="netbeans-xdebug"><engine version="3.2.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init>
.feature_set -i 75 -n show_hidden -v 1.220.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="75" feature="show_hidden" success="1"></response>.
feature_set -i 76 -n resolved_breakpoints -v 1.229.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="76" feature="resolved_breakpoints" success="1"></response>
.feature_set -i 77 -n max_depth -v 10.218.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="77" feature="max_depth" success="1"></response>.
feature_set -i 78 -n max_children -v 500.221.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="78" feature="max_children" success="1"></response>.
feature_set -i 79 -n max_data -v 8192.217.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="79" feature="max_data" success="1"></response>.
eval -i 80 -- KGlzc2V0KCRfU0VSVkVSWydTU0wnXSkgPyAnaHR0cHMnIDogJ2h0dHAnKS4nOi8vJy4kX1NFUlZFUlsnU0VSVkVSX05BTUUnXS4nOicuJF9TRVJWRVJbJ1NFUlZFUl9QT1JUJ10uJF9TRVJWRVJbJ1JFUVVFU1RfVVJJJ10=.342.
<?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="80"><property type="string" size="66" encoding="base64"><![CDATA[aHR0cDovL3Rlc3QxLm1jbzo4MC9pbmRleC5waHA/WERFQlVHX1NFU1NJT05fU1RBUlQ9bmV0YmVhbnMteGRlYnVn]]></property></response>
.run -i 81.208.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="81" status="stopping" reason="ok"></response>.
Start of page2.php : appid="11040"
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///D:/.../page2.php" language="PHP" xdebug:language_version="8.1.0" protocol_version="1.0" appid="11040" idekey="netbeans-xdebug"><engine version="3.2.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init>
.feature_set -i 82 -n show_hidden -v 1.220.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="82" feature="show_hidden" success="1"></response>
.feature_set -i 83 -n resolved_breakpoints -v 1.229.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="83" feature="resolved_breakpoints" success="1"></response>
.feature_set -i 84 -n max_depth -v 10.218.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="84" feature="max_depth" success="1"></response>
.feature_set -i 85 -n max_children -v 500.221.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="85" feature="max_children" success="1"></response>
.feature_set -i 86 -n max_data -v 8192.217.<?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="86" feature="max_data" success="1"></response>
.eval -i 87 -- KGlzc2V0KCRfU0VSVkVSWydTU0wnXSkgPyAnaHR0cHMnIDogJ2h0dHAnKS4nOi8vJy4kX1NFUlZFUlsnU0VSVkVSX05BTUUnXS4nOicuJF9TRVJWRVJbJ1NFUlZFUl9QT1JUJ10uJF9TRVJWRVJbJ1JFUVVFU1RfVVJJJ10=.294.<?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="87"><property type="string" size="29" encoding="base64"><![CDATA[aHR0cDovL3Rlc3QxLm1jbzo4MC9wYWdlMi5waHA=]]></property></response>
.run -i 88.
**** waiting for cURL return
Start of page3.php : appid="5372"
<?xml version="1.0" encoding="iso-8859-1"?>
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///D:/....page3.php" language="PHP" xdebug:language_version="8.1.0" protocol_version="1.0" appid="5372" idekey="netbeans-xdebug"><engine version="3.2.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init>.
**** no answer from the Netbeans server |
---|
Attached Files |
index.php (1,440 bytes)
<?php
/*==============================================================================
* Makes an AJAX call to page2.php
==============================================================================*/
?>
<!DOCTYPE html>
<html>
<head>
<title>page1</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="data:,"> <!-- no favicon -->
<script>
function getContent() {
let response = document.getElementById('content');
let URL = "./page2.php";
fetch(URL)
.then(reponse => {
if ( ! reponse.ok) throw new Error("NOK - HTTP error="+reponse.status);
return reponse.text();
})
.then(data => {
response.innerHTML = data;
return 0;
})
.catch(error => {
response.innerHTML = "NOK - fetch().catch() : "+error;
});
}
</script>
</head>
<body>
<h2>I am page1.php</h2>
<div style="background-color:lightgreen">
<h3>AJAX call of page2.php which uses cURL to get page3.php content</h3>
<input type="button" onclick="getContent()" value="Call">
<p id="content"></p>
</div>
</body>
</html>
page2.php (736 bytes)
<?php
/*==============================================================================
* Makes a cURL call to get page3.php content.
* With line 11, execution stops in debug mode
==============================================================================*/
$answer = "";
try {
$ch = curl_init("http://test1.mco/page3.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Cookie: XDEBUG_SESSION=netbeans-xdebug'));
$answer = curl_exec($ch);
if ($answer === false) throw new Exception("curl_exec returns FALSE - curlError=".curl_error($ch));
} catch (Throwable $ex) {
$answer = 'Exception '.$ex->getCode().' message='.$ex->getMessage();
}
?>
<?=$answer?>
page3.php (94 bytes)
<?php
$retour = "I am page3.php content"; // wants to put a breakpoint here
?>
<?= $retour ?>
|
---|