如果触发字符串存在,我可以启动 xdebug,但是如何让它*仅*在触发字符串存在时启动?
我试图仅在通过 cookie 传递带有请求的特定触发器字符串时才启动 xdebug 会话,如下所示:
GET https://1.2.3.4
cookie: XDEBUG_TRIGGER=mytriggerstring
虽然我可以使用触发器按计划启动 xdebug,但我可以仍然使用此通用请求在没有触发器的情况下启动会话:
GET https://1.2.3.4?XDEBUG_SESSION_START=anything
这是我完整的 xdebug 配置文件:
xdebug.start_with_request=trigger
xdebug.mode=debug
xdebug.trigger_value=mytriggerstring
xdebug.client_host = 192.168.1.10
xdebug 文档 这里说
仅当特定触发器被激活时,该功能才会被激活 请求开始时出现
我没有看到任何表明必须禁用 XDEBUG_SESSION_START 的内容,或者在需要时如何禁用它。
我缺少什么?
这是在 CentOS 7 上,这是我的 xdebug/php 版本:
PHP 7.4.27 (cli) (built: Dec 14 2021 17:17:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
这是来自 xdebug.log_level=10 的日志:
..传递无 xdebug 参数:
[661] Log opened at 2022-02-24 02:40:03.415677
[661] [Config] DEBUG: Checking if trigger 'XDEBUG_TRIGGER' is enabled for mode 'debug'
[661] [Config] INFO: Trigger value for 'XDEBUG_TRIGGER' not found, falling back to 'XDEBUG_SESSION'
[661] [Config] INFO: Trigger value for 'XDEBUG_SESSION' not found, so not activating
[661] Log closed at 2022-02-24 02:40:03.416915
..通过 cookie 传递我的触发器:
[663] Log opened at 2022-02-24 02:40:38.079079
[663] [Config] DEBUG: Checking if trigger 'XDEBUG_TRIGGER' is enabled for mode 'debug'
[663] [Config] DEBUG: The trigger value 'mytriggerstring' matched the shared secret 'mytriggerstring' for mode 'debug'
[663] [Step Debug] INFO: Connecting to configured address/port: 192.168.1.10:9003.
[663] [Step Debug] INFO: Connected to debugging client: 192.168.1.10:9003 (through xdebug.client_host/xdebug.client_port). :-)
..传递 XDEBUG_SESSION_START=anything cgi 参数
[661] Log opened at 2022-02-24 02:42:39.009885
[661] [Step Debug] DEBUG: Found 'XDEBUG_SESSION_START' HTTP variable, with value 'anything'
[661] [Step Debug] INFO: Connecting to configured address/port: 192.168.1.10:9003.
[661] [Step Debug] INFO: Connected to debugging client: 192.168.1.10:9003 (through xdebug.client_host/xdebug.client_port). :-)
I'm trying to only start an xdebug session only when I pass a certain trigger string with the request via a cookie, like so:
GET https://1.2.3.4
cookie: XDEBUG_TRIGGER=mytriggerstring
Although I can get xdebug to start as planned with the trigger, I can also still start the session without the trigger using this generic request:
GET https://1.2.3.4?XDEBUG_SESSION_START=anything
Here's my complete xdebug config file:
xdebug.start_with_request=trigger
xdebug.mode=debug
xdebug.trigger_value=mytriggerstring
xdebug.client_host = 192.168.1.10
The xdebug docs here say
The functionality only gets activated when a specific trigger is
present when the request starts
I'm not seeing anything there that says XDEBUG_SESSION_START has to be disabled, or how to disable it if that was needed.
What am I missing?
This is on CentOS 7 and here's my xdebug/php version:
PHP 7.4.27 (cli) (built: Dec 14 2021 17:17:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
Here are logs from xdebug.log_level=10:
..passing no xdebug params:
[661] Log opened at 2022-02-24 02:40:03.415677
[661] [Config] DEBUG: Checking if trigger 'XDEBUG_TRIGGER' is enabled for mode 'debug'
[661] [Config] INFO: Trigger value for 'XDEBUG_TRIGGER' not found, falling back to 'XDEBUG_SESSION'
[661] [Config] INFO: Trigger value for 'XDEBUG_SESSION' not found, so not activating
[661] Log closed at 2022-02-24 02:40:03.416915
..passing my trigger via the cookie:
[663] Log opened at 2022-02-24 02:40:38.079079
[663] [Config] DEBUG: Checking if trigger 'XDEBUG_TRIGGER' is enabled for mode 'debug'
[663] [Config] DEBUG: The trigger value 'mytriggerstring' matched the shared secret 'mytriggerstring' for mode 'debug'
[663] [Step Debug] INFO: Connecting to configured address/port: 192.168.1.10:9003.
[663] [Step Debug] INFO: Connected to debugging client: 192.168.1.10:9003 (through xdebug.client_host/xdebug.client_port). :-)
..passing the XDEBUG_SESSION_START=anything cgi param
[661] Log opened at 2022-02-24 02:42:39.009885
[661] [Step Debug] DEBUG: Found 'XDEBUG_SESSION_START' HTTP variable, with value 'anything'
[661] [Step Debug] INFO: Connecting to configured address/port: 192.168.1.10:9003.
[661] [Step Debug] INFO: Connected to debugging client: 192.168.1.10:9003 (through xdebug.client_host/xdebug.client_port). :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
恭喜!我想你已经发现了一个错误。
请您将此问题报告给 Xdebug 开发团队 https://bugs.xdebug.org ?只需复制并粘贴这篇文章中的全部信息,他们的问题跟踪器可能就足以让他们解决这个问题(如果事实证明这是一个真正的错误)。
Congratulations! You have found a bug, I think.
Would you please be so kind to report it to the Xdebug development team at https://bugs.xdebug.org ? Just copying and pasting the whole information from this post their issue tracker will likely be enough for them to fix this (if it turns out to be a real bug).