jenkins-bot has submitted this change and it was merged.

Change subject: wfShellExec: Work around PHP 5.3 stream_select() issue
......................................................................


wfShellExec: Work around PHP 5.3 stream_select() issue

Follows-up e53af95c9301ca092ffa1f7de022beb24d60ea52.

Bug: 56360
Change-Id: I66f2dc8a2f43236799c23f6e25bbbd0a440f4283
---
M includes/GlobalFunctions.php
1 file changed, 10 insertions(+), 1 deletion(-)

Approvals:
  Tim Starling: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 7547d74..1ec7ba9 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -2837,6 +2837,14 @@
        $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
+       // <https://bugs.php.net/bug.php?id=53427>.
+       $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 @@
                                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] );

-- 
To view, visit https://gerrit.wikimedia.org/r/92607
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I66f2dc8a2f43236799c23f6e25bbbd0a440f4283
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: PleaseStand <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to