From: Kevin Israel Date: Wed, 30 Oct 2013 01:46:27 +0000 (-0400) Subject: wfShellExec: Work around PHP 5.3 stream_select() issue X-Git-Tag: 1.31.0-rc.0~18347 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22calendrier%22%2C%22type=semaine%22%29%20.%20%22?a=commitdiff_plain;h=8bd6f698ccb990c9a9d37f495b8b5b7620832018;p=lhc%2Fweb%2Fwiklou.git wfShellExec: Work around PHP 5.3 stream_select() issue Follows-up e53af95c9301ca092ffa1f7de022beb24d60ea52. Bug: 56360 Change-Id: I66f2dc8a2f43236799c23f6e25bbbd0a440f4283 --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 7547d74194..1ec7ba9fe8 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2837,6 +2837,14 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array $eintr = defined( 'SOCKET_EINTR' ) ? SOCKET_EINTR : 4; $eintrMessage = "stream_select(): unable to select [$eintr]"; + // Build a table mapping resource IDs to pipe FDs to work around a + // PHP 5.3 issue in which stream_select() does not preserve array keys + // . + $fds = array(); + foreach ( $pipes as $fd => $pipe ) { + $fds[(int)$pipe] = $fd; + } + while ( true ) { $status = proc_get_status( $proc ); if ( !$status['running'] ) { @@ -2858,8 +2866,9 @@ function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array break; } } - foreach ( $readyPipes as $fd => $pipe ) { + foreach ( $readyPipes as $pipe ) { $block = fread( $pipe, 65536 ); + $fd = $fds[(int)$pipe]; if ( $block === '' ) { // End of file fclose( $pipes[$fd] );