Make WordPress Core

Opened 11 years ago

Closed 10 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:
Priority: normal Milestone:
Component: Build/Test Tools Version:
Severity: normal Keywords: needs-patch needs-testing reporter-feedback
Cc: Focuses:

Description (last modified by johnbillion)

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?

Change History (3)

#1 @johnbillion
11 years ago

  • Description modified (diff)
  • Keywords needs-patch needs-testing added
  • Version trunk

#2 in reply to: ↑ description @JPry
11 years ago

  • Keywords reporter-feedback added

Replying to aussieguy123:

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.

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?

#3 @johnbillion
10 years ago

  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → closed

Closing due to lack of feedback. Please re-open with further details if necessary.

Note: See TracTickets for help on using tickets.