Merge "RCFilters: Move parameter operations to ViewModel"
[lhc/web/wiklou.git] / includes / shell / Command.php
index fb2d787..4fc282c 100644 (file)
@@ -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,7 +261,7 @@ 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 = [