Fix php_debugger.* INI aliases being silently ignored#32
Merged
Conversation
The OnUpdatePhpDebugger* wrapper handlers used entry->modified to decide whether to apply a value. During zend_register_ini_entries() (MINIT stage), PHP always sets entry->modified=0 for newly registered entries, even when the user explicitly set the value via -d or php.ini. This caused all php_debugger.* settings to be silently ignored. Replace the entry->modified check with a helper that also consults zend_get_configuration_directive(), which correctly returns non-NULL when the value was explicitly set. Fixes #31
b33fc6b to
195202a
Compare
When php_debugger.* and xdebug.* are both set, php_debugger.* must
take precedence. The wrapper handlers already wrote to the correct
struct field, but ini_get("xdebug.foo") still returned the xdebug.*
value because each INI entry maintains its own value string.
Add php_debugger_sync_canonical() which directly updates the canonical
xdebug.* entry value string after a successful php_debugger.* update.
Uses zend_hash_find_ptr on EG(ini_directives) to avoid re-triggering
the canonical handler.
Three new tests verify precedence:
- ini_alias_precedence: php_debugger.* before xdebug.* in -d order
- ini_alias_precedence_reverse: xdebug.* before php_debugger.*
- ini_alias_precedence_ini_get: ini_get() reflects php_debugger.* values
for both xdebug.* and php_debugger.* names (mixed INI order)
195202a to
6c5fa02
Compare
Collaborator
carlos-granados
left a comment
There was a problem hiding this comment.
Looks good and well tested, thanks @pronskiy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
php_debugger.*INI aliases were silently ignored, and when both prefixes were set,ini_get("xdebug.*")did not reflect thephp_debugger.*override.Fixes #31
Changes
Fix alias detection during MINIT —
entry->modifiedis always 0 duringzend_register_ini_entries(). Addedphp_debugger_ini_is_explicitly_set()which falls back tozend_get_configuration_directive()for MINIT-stage detection.Sync canonical entries — When a
php_debugger.*alias is set,php_debugger_sync_canonical()updates the correspondingxdebug.*entry value directly, soini_get("xdebug.foo")reflects the effective value.php_debugger.*takes precedence — When both prefixes are set, thephp_debugger.*value wins regardless of directive order.Deduplicate wrappers — All 6 identical
OnUpdatePhpDebugger*handlers replaced with aPHP_DEBUGGER_INI_WRAPPERmacro.Tests
ini_alias_client_host— DBGp session using onlyphp_debugger.*prefixini_alias_idekey—php_debugger.idekeyappears in DBGp init packetini_alias_precedence—php_debugger.*wins when set beforexdebug.*ini_alias_precedence_reverse—php_debugger.*wins when set afterxdebug.*ini_alias_precedence_ini_get—ini_get("xdebug.*")returnsphp_debugger.*values (mixed order)