From: Shinjiman Date: Sat, 8 Aug 2009 10:32:37 +0000 (+0000) Subject: * (bug 20127) Fix regression when the executive does not found in the path specified... X-Git-Tag: 1.31.0-rc.0~40423 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=59a0ceedb57d3de8ca8c5483fa05e30f1260abab;p=lhc%2Fweb%2Fwiklou.git * (bug 20127) Fix regression when the executive does not found in the path specified while the SVG renderer is defined. Added detection by the $PATH variable. --- diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 09aadb1730..04db78ad5b 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -43,6 +43,24 @@ class SpecialVersion extends SpecialPage { $wgOut->addHTML( '' ); } + /** + * check executive path existence + * @param string command + * @return mixed existsIn + */ + static function checkExecPath( $cmd ) { + $existsIn = false; + $pathDirArray = explode( ';' , $_SERVER['PATH'] ); + foreach ( $pathDirArray as $pathDir ) { + $pathDir = str_replace('\\', '/', $pathDir); + $pathDir .= '/'; + if ( ( file_exists ( $pathDir . '/' . $cmd ) ) || ( file_exists( trim( $pathDir . '/' . $cmd, '"' ) . '.exe' ) ) ) { + $existsIn = $pathDir; + } + } + return $existsIn; + } + /** * execuate command for output * @param string command @@ -196,6 +214,7 @@ class SpecialVersion extends SpecialPage { // Look for SVG converter and print the version info if ( in_array( 'svg', $wgFileExtensions ) ) { $swSVGConvName = $wgSVGConverter; + $swSVGConvInfo = ''; $haveSVGConvVer = false; $pathVar = '$path/'; $binPath = '/usr/bin/'; @@ -203,6 +222,7 @@ class SpecialVersion extends SpecialPage { $execPath = substr_replace($execPath, '', 0, strlen($pathVar)); $execFullPath = trim($wgSVGConverterPath,'"') . $execPath; $execBinPath = $binPath . $execPath; + $execPathVal = checkExecPath( $execPath ); if (strstr($execFullPath, ' ') != false) { $execFullPath = '"' . $execFullPath . '"'; } @@ -212,6 +232,8 @@ class SpecialVersion extends SpecialPage { $swSVGConvInfo = self::execOutput( $execBinPath . ' -version' ); else if ( file_exists( trim( $execFullPath, '"' ) ) || ( file_exists( trim( $execFullPath, '"' ) . '.exe' ) ) ) $swSVGConvInfo = self::execOutput( $execFullPath . ' -version' ); + else if ( $execPathVal != false ) + $swSVGConvInfo = self::execOutput( $execPathVal . $execPath . ' -version' ); list( $head, $tail ) = explode( 'ImageMagick', $swSVGConvInfo ); list( $swSVGConvVer ) = explode('http://www.imagemagick.org', $tail ); $swSVGConvURL = 'http://www.imagemagick.org/'; @@ -222,6 +244,8 @@ class SpecialVersion extends SpecialPage { $swSVGConvInfo = self::execOutput( $execBinPath . ' -v' ); else if ( file_exists( trim( $execFullPath, '"' ) ) || ( file_exists( trim( $execFullPath, '"' ) . '.exe' ) ) ) $swSVGConvInfo = self::execOutput( $execFullPath . ' -v' ); + else if ( $execPathVal != false ) + $swSVGConvInfo = self::execOutput( $execPathVal . $execPath . ' -v' ); $swSVGConvLine = explode("\n",$swSVGConvInfo ,2); $swSVGConvVer = $swSVGConvLine[0]; $swSVGConvURL = 'http://librsvg.sourceforge.net/'; @@ -232,6 +256,8 @@ class SpecialVersion extends SpecialPage { $swSVGConvInfo = self::execOutput( $execBinPath . ' -z -V' ); else if ( file_exists( trim( $execFullPath, '"' ) ) || ( file_exists( trim( $execFullPath, '"' ) . '.exe' ) ) ) $swSVGConvInfo = self::execOutput( $execFullPath . ' -z -V' ); + else if ( $execPathVal != false ) + $swSVGConvInfo = self::execOutput( $execPathVal . $execPath . ' -z -V' ); $swSVGConvLine = explode("\n",$swSVGConvInfo ,2); $swSVGConvVer = ltrim( $swSVGConvLine[0], 'Inkscape ' ); $swSVGConvURL = 'http://www.inkscape.org/';