r54627 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54626‎ | r54627 | r54628 >
Date:10:32, 8 August 2009
Author:shinjiman
Status:reverted
Tags:
Comment:
* (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.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialVersion.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialVersion.php
@@ -44,6 +44,24 @@
4545 }
4646
4747 /**
 48+ * check executive path existence
 49+ * @param string command
 50+ * @return mixed existsIn
 51+ */
 52+ static function checkExecPath( $cmd ) {
 53+ $existsIn = false;
 54+ $pathDirArray = explode( ';' , $_SERVER['PATH'] );
 55+ foreach ( $pathDirArray as $pathDir ) {
 56+ $pathDir = str_replace('\\', '/', $pathDir);
 57+ $pathDir .= '/';
 58+ if ( ( file_exists ( $pathDir . '/' . $cmd ) ) || ( file_exists( trim( $pathDir . '/' . $cmd, '"' ) . '.exe' ) ) ) {
 59+ $existsIn = $pathDir;
 60+ }
 61+ }
 62+ return $existsIn;
 63+ }
 64+
 65+ /**
4866 * execuate command for output
4967 * @param string command
5068 * @return string output
@@ -196,6 +214,7 @@
197215 // Look for SVG converter and print the version info
198216 if ( in_array( 'svg', $wgFileExtensions ) ) {
199217 $swSVGConvName = $wgSVGConverter;
 218+ $swSVGConvInfo = '';
200219 $haveSVGConvVer = false;
201220 $pathVar = '$path/';
202221 $binPath = '/usr/bin/';
@@ -203,6 +222,7 @@
204223 $execPath = substr_replace($execPath, '', 0, strlen($pathVar));
205224 $execFullPath = trim($wgSVGConverterPath,'"') . $execPath;
206225 $execBinPath = $binPath . $execPath;
 226+ $execPathVal = checkExecPath( $execPath );
207227 if (strstr($execFullPath, ' ') != false) {
208228 $execFullPath = '"' . $execFullPath . '"';
209229 }
@@ -212,6 +232,8 @@
213233 $swSVGConvInfo = self::execOutput( $execBinPath . ' -version' );
214234 else if ( file_exists( trim( $execFullPath, '"' ) ) || ( file_exists( trim( $execFullPath, '"' ) . '.exe' ) ) )
215235 $swSVGConvInfo = self::execOutput( $execFullPath . ' -version' );
 236+ else if ( $execPathVal != false )
 237+ $swSVGConvInfo = self::execOutput( $execPathVal . $execPath . ' -version' );
216238 list( $head, $tail ) = explode( 'ImageMagick', $swSVGConvInfo );
217239 list( $swSVGConvVer ) = explode('http://www.imagemagick.org', $tail );
218240 $swSVGConvURL = 'http://www.imagemagick.org/';
@@ -222,6 +244,8 @@
223245 $swSVGConvInfo = self::execOutput( $execBinPath . ' -v' );
224246 else if ( file_exists( trim( $execFullPath, '"' ) ) || ( file_exists( trim( $execFullPath, '"' ) . '.exe' ) ) )
225247 $swSVGConvInfo = self::execOutput( $execFullPath . ' -v' );
 248+ else if ( $execPathVal != false )
 249+ $swSVGConvInfo = self::execOutput( $execPathVal . $execPath . ' -v' );
226250 $swSVGConvLine = explode("\n",$swSVGConvInfo ,2);
227251 $swSVGConvVer = $swSVGConvLine[0];
228252 $swSVGConvURL = 'http://librsvg.sourceforge.net/';
@@ -232,6 +256,8 @@
233257 $swSVGConvInfo = self::execOutput( $execBinPath . ' -z -V' );
234258 else if ( file_exists( trim( $execFullPath, '"' ) ) || ( file_exists( trim( $execFullPath, '"' ) . '.exe' ) ) )
235259 $swSVGConvInfo = self::execOutput( $execFullPath . ' -z -V' );
 260+ else if ( $execPathVal != false )
 261+ $swSVGConvInfo = self::execOutput( $execPathVal . $execPath . ' -z -V' );
236262 $swSVGConvLine = explode("\n",$swSVGConvInfo ,2);
237263 $swSVGConvVer = ltrim( $swSVGConvLine[0], 'Inkscape ' );
238264 $swSVGConvURL = 'http://www.inkscape.org/';

Follow-up revisions

RevisionCommit summaryAuthorDate
r54668Fix PHP Fatal error for r54627.shinjiman16:04, 9 August 2009

Status & tagging log