Opened 9 years ago
Closed 8 years ago
#33580 closed defect (bug) (invalid)
Having xdebug enabled causes wordpress tests to hang because bootstrap.php calls php directly using system()
Reported by: | aussieguy123 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | needs-patch needs-testing reporter-feedback |
Focuses: | Cc: |
Description (last modified by )
In wp-tests/tests/phpunit/includes/bootstrap.php there is this line:
system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite);
To reproduce the bug, make sure xdebug.remote_enable=1
and that xdebug is configured to connect back to your ide (xdebug.remote_connect_back=1
xdebug.remote_host=x.x.x.x
).
When this system line is called from phpunit and you have xdebug listening in your IDE (I use PHPStorm), phpunit will hang.
I'm not sure what happens internally with xdebug to cause this, its possible that the php process spawned by system() conflicts with the previous one. You only get the error if the IDE is listening.
To fix this issue, I've made a simple change locally, updating the system call to:
system( WP_PHP_BINARY . ' -d xdebug.remote_enable=0' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite);
This disables xdebug in the process spawned by system(). I can have xdebug enabled and I get no errors and set breakpoints in my tests.
Should I make a patch with my fix or does someone have a better way?
Replying to aussieguy123:
PHPStorm has the ability to define how many XDebug connections at once it can accept. The default is one, but you can set it to a higher number if needed (I use 3). I believe that this is configurable with the "Max. simultaneous connections" setting. If you adjust that setting to a higher number, are you able to intercept the second PHP connection and prevent the process from hanging?