Merge "API: Allow anonymous CORS from anywhere, when specifically requested"
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index c5637ee..66e2440 100644 (file)
@@ -2461,7 +2461,8 @@ function wfShellExec( $cmd, &$retval = null, $environ = [],
        // accomodating, because very long commands probably include user
        // input. See T129506.
        if ( strlen( $cmd ) > SHELL_MAX_ARG_STRLEN ) {
-               throw new Exception( __METHOD__ . '(): total length of $cmd must not exceed SHELL_MAX_ARG_STRLEN' );
+               throw new Exception( __METHOD__ .
+                       '(): total length of $cmd must not exceed SHELL_MAX_ARG_STRLEN' );
        }
 
        $desc = [
@@ -2498,14 +2499,6 @@ function wfShellExec( $cmd, &$retval = null, $environ = [],
        $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 = [];
-       foreach ( $pipes as $fd => $pipe ) {
-               $fds[(int)$pipe] = $fd;
-       }
-
        $running = true;
        $timeout = null;
        $numReadyPipes = 0;
@@ -2538,9 +2531,8 @@ function wfShellExec( $cmd, &$retval = null, $environ = [],
                                break;
                        }
                }
-               foreach ( $readyPipes as $pipe ) {
+               foreach ( $readyPipes as $fd => $pipe ) {
                        $block = fread( $pipe, 65536 );
-                       $fd = $fds[(int)$pipe];
                        if ( $block === '' ) {
                                // End of file
                                fclose( $pipes[$fd] );