fix: handle trigger correctly#59
Conversation
| } | ||
|
|
||
| static int xdebug_handle_start_session() | ||
| int xdebug_handle_start_session() |
There was a problem hiding this comment.
Need to make this function available to be called outside of this file
| ) { | ||
| if (found_trigger_value) { | ||
| xdebug_update_ide_key(found_trigger_value); | ||
| if (EXPECTED(XG_BASE(observer_active))) { |
There was a problem hiding this comment.
If we have already tried to connect and found out that we are not connected, we don't need to try here again
| 'variables_order' => 'PGCS', | ||
| 'xdebug.log' => $xdebugLogFileName, 'xdebug.log_level' => 10, | ||
| 'xdebug.control_socket' => 'off', 'xdebug.path_mapping' => 'off', | ||
| 'xdebug.on_demand_debugging_enabled' => 1 |
There was a problem hiding this comment.
This is actually not needed for this test, once we fix the issue, it works fine even without this setting
| xdebug_lib_start_upon_error() || | ||
| getenv("XDEBUG_SESSION_START") != NULL || | ||
| getenv("PHP_DEBUGGER_SESSION_START") != NULL | ||
| xdebug_handle_start_session() || |
There was a problem hiding this comment.
we need to call this function which correctly checks if we need to start the session or not
| int debug_requested = !xdebug_lib_never_start_with_request() && !xdebug_should_ignore() && ( | ||
| xdebug_lib_start_with_request() || | ||
| xdebug_lib_start_with_trigger(NULL) || | ||
| xdebug_lib_start_upon_error() || |
There was a problem hiding this comment.
We don't need to try to connect if this is set
| xdebug_lib_start_with_request() || | ||
| xdebug_lib_start_with_trigger(NULL) || | ||
| xdebug_lib_start_upon_error() || | ||
| getenv("XDEBUG_SESSION_START") != NULL || |
There was a problem hiding this comment.
We don't need to try to connect just because any of these are set. This is properly handled by xdebug_handle_start_session
| xdebug_lib_start_with_trigger(&found_trigger_value) | ||
| ); | ||
|
|
||
| if (found_trigger_value) { |
There was a problem hiding this comment.
If we have found a trigger value, we need to update the ide_key with it
d59f69a to
d716581
Compare
| if (XG_LIB(headers)) { | ||
| switch (op) { | ||
| case SAPI_HEADER_ADD: | ||
| xdebug_log(XLOG_CHAN_DEBUG, XLOG_DEBUG, "Adding header '%s'.", h->header); |
There was a problem hiding this comment.
Since the xdebug_get_headers is no longer available, we need a way to see the headers that have been set. We add a log entry here that we can later use to check them
| --FILE-- | ||
| <?php | ||
| var_dump( xdebug_get_headers( ) ); | ||
| require_once __DIR__ . '/../utils.inc'; |
There was a problem hiding this comment.
Instead of using the xdebug_get_headers function which is no longer available, we log the header in the xdebug log and then print it to confirm it's working. Previously this tests would not have worked because we were not calling xdebug_handle_start_session in RINIT, so the cookie was not being set
1d5a2f3 to
6a00a52
Compare
6a00a52 to
54050b9
Compare
|
@claude review |
|
Claude finished @carlos-granados's task in 4m 13s —— View job Code ReviewRead the diff, the call sites in Notable issues1. Risk of duplicate side effects when
The two calls only collapse safely when:
But when 2. In This is a pre-existing wart, but the PR makes it newly observable (and is now baked into a test as expected behavior). Worth thinking about: a caller can supply any 3. Inconsistent header logging
Smaller observations
Looks good
|
54050b9 to
2f48e74
Compare
|
@claude updated, review again |
|
Claude finished @carlos-granados's task in 2m 41s —— View job Re-reviewI read commit Previously raised — status
Notes on the new memoizationThe cache approach is the right call — keeps
Minor: behavior change in the third branchIn the Looks good
Nothing blocking from my side. LGTM.
|
|
@claude updated, new review |
|
Claude finished @carlos-granados's task in 1m 12s —— View job Re-review (commit
|
b35aa7d to
73c0596
Compare
When doing the initial check to see if we needed to connect, we were not doing it correctly, which meant that in some cases it would try to connect when it shouldn't. And it was not correctly saving the trigger value. This PR fixes these problems
Solves one of the existing XFAIL tests, which was a real bug