From: Platonides Date: Fri, 15 Oct 2010 19:48:21 +0000 (+0000) Subject: r71546 broke imagemagick usage in Windows, since cmd.exe takes the variable X-Git-Tag: 1.31.0-rc.0~34489 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=f91decf221f6bcb36850540887d775d7407d3373;p=lhc%2Fweb%2Fwiklou.git r71546 broke imagemagick usage in Windows, since cmd.exe takes the variable names as the program name. I'm just not exporting those variables here, but we need to support them in Windows, too. We could use putenv() but that seems ugly (and risky). A better solution would be to have wfShellExec() call proc_open() with a modified environment. A POSIX shell is required to accept variable assignments before the command so we shouldn't have problems on any UNIX-like system. http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01 --- diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php index 4909af2f4e..7e9edb732c 100644 --- a/includes/media/Bitmap.php +++ b/includes/media/Bitmap.php @@ -147,16 +147,13 @@ class BitmapHandler extends ImageHandler { } } + // Use one thread only, to avoid deadlock bugs on OOM + $tempEnv = 'OMP_NUM_THREADS=1 '; if ( strval( $wgImageMagickTempDir ) !== '' ) { - $tempEnv = 'MAGICK_TMPDIR=' . wfEscapeShellArg( $wgImageMagickTempDir ) . ' '; - } else { - $tempEnv = ''; + $tempEnv .= 'MAGICK_TMPDIR=' . wfEscapeShellArg( $wgImageMagickTempDir ) . ' '; } $cmd = - $tempEnv . - // Use one thread only, to avoid deadlock bugs on OOM - 'OMP_NUM_THREADS=1 ' . wfEscapeShellArg( $wgImageMagickConvertCommand ) . // Specify white background color, will be used for transparent images // in Internet Explorer/Windows instead of default black. @@ -173,6 +170,12 @@ class BitmapHandler extends ImageHandler { " -depth 8 $sharpen" . " {$animation_post} " . wfEscapeShellArg( $this->escapeMagickOutput( $dstPath ) ) . " 2>&1"; + + if ( !wfIsWindows() ) { + // Assume we have a POSIX compliant shell which accepts variable assignments preceding the command + $cmd = $tempEnv . $cmd; + } + wfDebug( __METHOD__.": running ImageMagick: $cmd\n" ); wfProfileIn( 'convert' ); $err = wfShellExec( $cmd, $retval );