DebugSubscriber - Fix activation check #24554
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This component injects debug info about API calls. It only does so if XDebug is configured with the suitable mode (ie
xdebug.mode=develop
orXDEBUG_MODE=develop
)This requires a guard based on XDebug configuration. This guard is slightly wrong, which can sometimes raise spurious errors.
The key thing is that XDebug reads configuration from multiple sources (eg
php.ini
or env-var). A recent buildkit update relied on env-var working (civicrm/civicrm-buildkit#727).Before
The guard only consults
ini_get('xdebug.mode')
. If an env-var exists (egXDEBUG_MODE
), thenini_get()
does not correctly reveal the effective policy.This sometimes leads to failures like this (where in
xdebug.mode
looked like it haddevelop
enabled, butXDEBUG_MODE
actually disabled it, so anything that relies ondevelop
mode fails):After
The guard works with both php.ini's
xdebug.mode
and env-varXDEBUG_MODE
. It does this by asking XDebug for the effective mode (rather than looking at specific config flags).Technical Details
See also: https://xdebug.org/docs/all_functions#xdebug_info
The option will behave correctly on XDebug 3.1+. On 3.0, it falls back to the older (less-accurate) check. All the systems I care about have 3.1.+