如果存在触发字符串,我可以启动 xdebug,但是如果存在触发字符串,我如何让它*仅*启动?

I can start xdebug if trigger string is present, but how do I have it start *only* if the trigger string is present?

我试图仅在我通过 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 文档 here

The functionality only gets activated when a specific trigger is present when the request starts

我没有看到任何内容说明必须禁用 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). :-)

恭喜!我想你发现了一个错误。

能否请您向 https://bugs.xdebug.org 的 Xdebug 开发团队报告此问题?只需复制并粘贴此 post 他们的问题跟踪器中的全部信息就可能足以让他们修复此问题(如果它被证明是一个真正的错误)。