Skip to content

Commit

Permalink
Fixed issue #2223: Xdebug's constants are not available with xdebug.m…
Browse files Browse the repository at this point in the history
…ode=off
  • Loading branch information
derickr committed Dec 6, 2023
1 parent f79b4f0 commit 5c1f364
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
8 changes: 4 additions & 4 deletions tests/coverage/bug01903-002.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Test for bug #1903: XDEBUG_CC_DEAD_CODE and XDEBUG_CC_UNUSED should not be defined with mode=off
Test for bug #1903: XDEBUG_CC_DEAD_CODE and XDEBUG_CC_UNUSED should be defined with mode=off
--INI--
xdebug.mode=off
--FILE--
Expand All @@ -11,6 +11,6 @@ var_dump(
);
?>
--EXPECT--
bool(false)
bool(false)
bool(false)
bool(true)
bool(true)
bool(true)
15 changes: 15 additions & 0 deletions tests/library/xdebug_constants.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Test for bug #2223: Xdebug's constants are not available with xdebug.mode=off
--INI--
xdebug.mode=off
--FILE--
<?php
$constants = get_defined_constants(true);

echo "Constants: ", array_key_exists( 'xdebug', $constants ) ? "available: " : "not available\n";
if (array_key_exists('xdebug', $constants)) {
echo count(array_keys($constants['xdebug'])), "\n";
}
?>
--EXPECT--
Constants: available: 17
8 changes: 4 additions & 4 deletions tests/tracing/bug01903-002.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Test for bug #1903: Tracing constants should not be defined with mode=off
Test for bug #1903: Tracing constants should be defined with mode=off
--INI--
xdebug.mode=off
--FILE--
Expand All @@ -11,6 +11,6 @@ var_dump(
);
?>
--EXPECT--
bool(false)
bool(false)
bool(false)
bool(true)
bool(true)
bool(true)
8 changes: 4 additions & 4 deletions xdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,10 @@ PHP_MINIT_FUNCTION(xdebug)
ZEND_INIT_MODULE_GLOBALS(xdebug, php_xdebug_init_globals, php_xdebug_shutdown_globals);
REGISTER_INI_ENTRIES();

xdebug_coverage_register_constants(INIT_FUNC_ARGS_PASSTHRU);
xdebug_filter_register_constants(INIT_FUNC_ARGS_PASSTHRU);
xdebug_tracing_register_constants(INIT_FUNC_ARGS_PASSTHRU);

/* Locking in mode as it currently is */
if (!xdebug_lib_set_mode(XG(settings.library.requested_mode))) {
xdebug_lib_set_mode("develop");
Expand Down Expand Up @@ -595,10 +599,6 @@ PHP_MINIT_FUNCTION(xdebug)
zend_error(E_WARNING, "Xdebug MUST be loaded as a Zend extension");
}

xdebug_coverage_register_constants(INIT_FUNC_ARGS_PASSTHRU);
xdebug_filter_register_constants(INIT_FUNC_ARGS_PASSTHRU);
xdebug_tracing_register_constants(INIT_FUNC_ARGS_PASSTHRU);

return SUCCESS;
}

Expand Down

0 comments on commit 5c1f364

Please sign in to comment.