X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fshell%2FCommand.php;h=4fc282c8c4f8b2dfe0ce20919ce584517afb9742;hp=4e0c0ec309263c5cbbf5b44cb0ea6657b9d2a7bf;hb=cb615a80599a409976518e7564cc6d993b772714;hpb=4fb048ab4ff6eeb50b1d92c9a6028e7ff89c4ba8 diff --git a/includes/shell/Command.php b/includes/shell/Command.php index 4e0c0ec309..4fc282c8c4 100644 --- a/includes/shell/Command.php +++ b/includes/shell/Command.php @@ -135,6 +135,11 @@ class Command { * @return $this */ public function limits( array $limits ) { + if ( !isset( $limits['walltime'] ) && isset( $limits['time'] ) ) { + // Emulate the behavior of old wfShellExec() where walltime fell back on time + // if the latter was overridden and the former wasn't + $limits['walltime'] = $limits['time']; + } $this->limits = $limits + $this->limits; return $this; @@ -227,8 +232,6 @@ class Command { if ( is_executable( '/bin/bash' ) ) { $time = intval( $this->limits['time'] ); $wallTime = intval( $this->limits['walltime'] ); - // for b/c, wall time falls back to time - $wallTime = min( $time, $wallTime ); $mem = intval( $this->limits['memory'] ); $filesize = intval( $this->limits['filesize'] ); @@ -245,10 +248,9 @@ class Command { "MW_USE_LOG_PIPE=yes" ); $useLogPipe = true; - } elseif ( $this->useStderr ) { - $cmd .= ' 2>&1'; } - } elseif ( $this->useStderr ) { + } + if ( !$useLogPipe && $this->useStderr ) { $cmd .= ' 2>&1'; } wfDebug( __METHOD__ . ": $cmd\n" ); @@ -259,13 +261,13 @@ class Command { // 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' ); + '(): total length of $cmd must not exceed SHELL_MAX_ARG_STRLEN' ); } $desc = [ 0 => [ 'file', 'php://stdin', 'r' ], 1 => [ 'pipe', 'w' ], - 2 => [ 'file', 'php://stderr', 'w' ], + 2 => [ 'pipe', 'w' ], ]; if ( $useLogPipe ) { $desc[3] = [ 'pipe', 'w' ]; @@ -278,6 +280,7 @@ class Command { throw new ProcOpenError(); } $outBuffer = $logBuffer = ''; + $errBuffer = null; $emptyArray = []; $status = false; $logMsg = false; @@ -352,6 +355,9 @@ class Command { } elseif ( $fd == 1 ) { // From stdout $outBuffer .= $block; + } elseif ( $fd == 2 ) { + // From stderr + $errBuffer .= $block; } elseif ( $fd == 3 ) { // From log FD $logBuffer .= $block; @@ -402,6 +408,6 @@ class Command { $this->logger->warning( "$logMsg: {command}", [ 'command' => $cmd ] ); } - return new Result( $retval, $outBuffer ); + return new Result( $retval, $outBuffer, $errBuffer ); } }