From e6e2aff26da7fb2b705cc5c4de92a1034dbd6ecf Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Tue, 21 Aug 2012 20:08:18 +0200 Subject: [PATCH] Add optional $wgTexCmdEnvironment parameter to give a chance to the user to set PATH variable for the latex commands. Often users can't edit php environment and it works in the command line but not when calling latex binaries from php. Bug #8625 --- Math.body.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Math.body.php b/Math.body.php index 0fab0f5..46a5ff1 100644 --- a/Math.body.php +++ b/Math.body.php @@ -55,7 +55,7 @@ class MathRenderer { function render() { global $wgTmpDirectory; - global $wgTexvc, $wgMathCheckFiles, $wgTexvcBackgroundColor; + global $wgTexvc, $wgMathCheckFiles, $wgTexvcBackgroundColor, $wgTexCmdEnvironment; if( $this->mode == MW_MATH_SOURCE || $this->mode == MW_MATH_MATHJAX ) { # No need to render or parse anything more! @@ -103,7 +103,13 @@ class MathRenderer { } wfDebug( "TeX: $cmd\n" ); - $contents = wfShellExec( $cmd ); + if (isset($wgTexCmdEnvironment) && is_array($wgTexCmdEnvironment)) { + wfDebug("Using environment: " . print_r($wgTexCmdEnvironment, true) ); + $nullRef = null; + $contents = wfShellExec( $cmd, $nullRef, $wgTexCmdEnvironment ); + } else { + $contents = wfShellExec( $cmd ); + } wfDebug( "TeX output:\n $contents\n---\n" ); if ( strlen( $contents ) == 0 ) { -- 1.7.9.5