Skip to content

fix: don't report the xdebug module by default - #108

Merged
carlos-granados merged 3 commits into
php-debugger:mainfrom
carlos-granados:xdebug-impersonation
Sep 8, 2026
Merged

carlos-granados merged 3 commits into
php-debugger:mainfrom
carlos-granados:xdebug-impersonation

Conversation

@carlos-granados

Copy link
Copy Markdown
Collaborator

We had configured PHP debugger so that it would report the XDebug module as installed, in theory to provide better compatibility, but this turned out to be counterproductive: tools like composer or phpunit detect it, try to disable it and they can't because it's not actually loaded, and end up reporting that it's enabled and making things slow, which we don't want.

This PR makes reporting that XDebug is loaded optional, defaulting to reporting that it's not loaded

@carlos-granados

Copy link
Copy Markdown
Collaborator Author

@claude review

@claude

claude Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Claude finished @carlos-granados's task in 3m 1s —— View job


Claude Code Review

  • Read the PR diff
  • Examine the changed files for correctness
  • Check test coverage
  • Post review feedback

Reviewed the four commits against origin/main. Overall the change is well‑scoped and correct — the default flip is a sensible UX fix, and the MINIT reordering to register the php_debugger.* aliases before checking settings.library.report_xdebug_module is exactly right so the flag can be set through either namespace.

What looks good

  • xdebug.c MINIT reordering (xdebug.c:493‑517): REGISTER_INI_ENTRIES() populates the setting from xdebug.*, then zend_register_ini_entries(php_debugger_ini_entries, …) applies any php_debugger.* override, and only then is XG(settings.library.report_xdebug_module) read. Correct dataflow.
  • PHP_INI_SYSTEM scope is the right choice — module registration only happens at MINIT, so allowing per‑request toggling would be misleading.
  • src/lib/log.c:460 swap from "xdebug" → "php_debugger" is the right fix; otherwise phpinfo()'s settings table would silently show nothing whenever the alias is disabled (the default). Both name sets share module_number, so the iteration below still finds everything.
  • Three‑case test matrix (default / xdebug.*=1 / php_debugger.*=1) covers the interesting branches.
  • CI + Docker smoke tests, README, run-xdebug-tests.php, and src/lib/lib.h are all updated in lockstep — nothing was missed.

Suggestions (nits, non‑blocking)

  1. Sync direction not verified — tests/base/report_xdebug_module-002.phpt sets xdebug.report_xdebug_module=1 but never asserts ini_get('php_debugger.report_xdebug_module'). Symmetric coverage would prove the canonical→alias direction still works for this key. Same for -003.phpt and the reverse. One extra var_dump() per file. Fix this →

  2. String literal for the module name — src/lib/log.c:460 and xdebug.c:77 both hard‑code "php_debugger". A #define XDEBUG_MODULE_NAME "php_debugger" in php_xdebug.h (alongside the existing XDEBUG_NAME "PHP Debugger") would remove the duplication. Cosmetic.

  3. README omits the xdebug.* form — the "Reporting the xdebug module" section only shows php_debugger.report_xdebug_module = 1, but xdebug.report_xdebug_module = 1 also works (as -002.phpt proves). One extra sentence would keep the doc consistent with the rest of the "Xdebug‑compatible names" story just above it.

  4. report_xdebug_module-002.phpt title says "re‑enables the module alias" — accurate but slightly misleading if a reader hasn't seen the default‑off change; something like "enables the xdebug module alias" reads a bit cleaner. Pure wording.

  5. Static‑variable lifetime — the static zend_module_entry xdebug_compat_module_entry = {0}; inside the if block is fine (only initialized once), but if MINIT ever ran twice in the same process (odd embedded SAPI cases), zend_hash_add_ptr would silently return NULL on the second insert. Pre‑existing behavior — not introduced by this PR — but worth being aware of.

Testing note

The "temporarily drop tests to isolate Windows CI failure" commit was followed by re‑adding them in 969d90e, and the working tree currently has all three test files. Confirm CI (particularly Windows) is now green on the final commit before merging, since the intermediate commit history suggests the Windows failure may have been sensitive to the test‑runner change in run-xdebug-tests.php:877‑880.

Verdict

LGTM. No correctness issues found; the items above are polish, not blockers.
• Branch: xdebug-impersonation

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR makes reporting the xdebug module name (i.e., extension_loaded("xdebug")) optional and off by default, to avoid ecosystem tools (e.g., Composer/PHPUnit) detecting “xdebug” and attempting to disable it via restart/unload logic that doesn’t apply to this project.

Changes:

  • Added xdebug.report_xdebug_module / php_debugger.report_xdebug_module (default 0) to control whether an xdebug module alias is registered.
  • Adjusted MINIT ordering so php_debugger.* INI aliases are registered before deciding whether to create the xdebug alias (so the alias works when configured via php_debugger.report_xdebug_module=1).
  • Updated tests, docs, CI/workflows, and Docker smoke checks to key off php_debugger by default.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
xdebug.c Adds the INI toggle and makes xdebug module alias registration conditional (default off).
src/lib/lib.h Introduces the report_xdebug_module settings flag in library settings.
src/lib/log.c Updates settings display lookup to use the real module name php_debugger (works even when xdebug alias is disabled).
tests/base/report_xdebug_module-001.phpt Verifies extension_loaded("xdebug") is false by default and INI defaults are 0.
tests/base/report_xdebug_module-002.phpt Verifies enabling via xdebug.report_xdebug_module=1 re-enables the xdebug alias.
tests/base/report_xdebug_module-003.phpt Verifies enabling via php_debugger.report_xdebug_module=1 also re-enables the xdebug alias.
run-xdebug-tests.php Ensures test runner special-casing applies whether the module appears as xdebug or php_debugger.
README.md Documents the new default behavior and how to re-enable extension_loaded("xdebug").
docker/Dockerfile.debian Updates smoke checks to assert php_debugger is present instead of xdebug.
docker/Dockerfile.alpine Updates smoke checks to assert php_debugger is present instead of xdebug.
.github/workflows/static-build.yml Removes assumptions that xdebug is present in module list / extension_loaded.
.github/workflows/release.yml Removes xdebug module presence assertions; keeps function-level compatibility checks.
.github/workflows/docker.yml Updates container smoke checks to assert php_debugger is present instead of xdebug.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pronskiy pronskiy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch, agree

@carlos-granados
carlos-granados merged commit 80cd0a8 into php-debugger:main Sep 8, 2026
34 checks passed
@carlos-granados
carlos-granados deleted the xdebug-impersonation branch September 8, 2026 16:08
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.

3 participants