Skip to content

Fix php_debugger.* INI aliases being silently ignored#32

Merged
pronskiy merged 2 commits intomainfrom
fix/ini-aliases
Mar 25, 2026
Merged

Fix php_debugger.* INI aliases being silently ignored#32
pronskiy merged 2 commits intomainfrom
fix/ini-aliases

Conversation

@pronskiy
Copy link
Copy Markdown
Collaborator

@pronskiy pronskiy commented Mar 24, 2026

Problem

php_debugger.* INI aliases were silently ignored, and when both prefixes were set, ini_get("xdebug.*") did not reflect the php_debugger.* override.

Fixes #31

Changes

Fix alias detection during MINITentry->modified is always 0 during zend_register_ini_entries(). Added php_debugger_ini_is_explicitly_set() which falls back to zend_get_configuration_directive() for MINIT-stage detection.

Sync canonical entries — When a php_debugger.* alias is set, php_debugger_sync_canonical() updates the corresponding xdebug.* entry value directly, so ini_get("xdebug.foo") reflects the effective value.

php_debugger.* takes precedence — When both prefixes are set, the php_debugger.* value wins regardless of directive order.

Deduplicate wrappers — All 6 identical OnUpdatePhpDebugger* handlers replaced with a PHP_DEBUGGER_INI_WRAPPER macro.

Tests

  • ini_alias_client_host — DBGp session using only php_debugger.* prefix
  • ini_alias_idekeyphp_debugger.idekey appears in DBGp init packet
  • ini_alias_precedencephp_debugger.* wins when set before xdebug.*
  • ini_alias_precedence_reversephp_debugger.* wins when set after xdebug.*
  • ini_alias_precedence_ini_getini_get("xdebug.*") returns php_debugger.* values (mixed order)

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
@pronskiy pronskiy force-pushed the fix/ini-aliases branch 3 times, most recently from b33fc6b to 195202a Compare March 25, 2026 16:37
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)
@pronskiy pronskiy marked this pull request as ready for review March 25, 2026 16:54
Copy link
Copy Markdown
Collaborator

@carlos-granados carlos-granados left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and well tested, thanks @pronskiy

@pronskiy pronskiy merged commit 52b9aba into main Mar 25, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

php_debugger ini settings do not work

2 participants