r52624 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52623‎ | r52624 | r52625 >
Date:13:48, 1 July 2009
Author:shinjiman
Status:reverted (Comments)
Tags:
Comment:
added whereis path support instead of the hardcoded local binary path to get the directory of executeable files, when available.
link to r52547, r52527 and r52525 for CodeReview if any comments are added.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialVersion.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialVersion.php
@@ -203,7 +203,6 @@
204204 // Look for TeX support and print the software version info
205205 if ( $wgUseTeX ) {
206206 $binPath = '/usr/bin/';
207 - $binPathLocal = '/usr/local/bin/';
208207 $swMathName = Array(
209208 'ocaml' => 'OCaml',
210209 'gs' => 'Ghostscript',
@@ -233,7 +232,15 @@
234233 'imagemagick' => '-version',
235234 );
236235 foreach ( $swMathExec as $swMath => $swMathCmd ) {
237 - if ( file_exists( $binPath . $swMathCmd ) || file_exists( $binPathLocal . $swMathCmd ) ) {
 236+ $wBinPath = '';
 237+ if ( file_exists( $binPath . 'whereis' ) ) {
 238+ $swWhereIsInfo = self::execOutput( $binPath . 'whereis -b ' . $swMathCmd );
 239+ $swWhereIsLine = explode( "\n", $swWhereIsInfo, 2);
 240+ $swWhereIsFirstLine = $swWhereIsLine[0];
 241+ $swWhereIsBinPath = explode( ' ', $swWhereIsFirstLine, 3);
 242+ $wBinPath = dirname( $swWhereIsBinPath[1] );
 243+ }
 244+ if ( file_exists( $binPath . $swMathCmd ) || file_exists( $wBinPath . $swMathCmd ) ) {
238245 $swMathInfo = self::execOutput( $swMathCmd . ' ' . $swMathParam[$swMath] );
239246 $swMathLine = explode( "\n", $swMathInfo, 2);
240247 $swMathVerInfo = $swMathLine[0];
@@ -246,8 +253,8 @@
247254 list( $head, $tail ) = explode( 'ImageMagick', $swMathVerInfo );
248255 list( $swMathVerInfo ) = explode('http://www.imagemagick.org', $tail );
249256 }
250 - $swMathVer[$swMath] = $swMathVerInfo;
251 - $software["[$swMathURL[$swMath] $swMathName[$swMath]]"] = trim ( $swMathVer[$swMath] );
 257+ $swMathVer[$swMath] = trim( $swMathVerInfo );
 258+ $software["[$swMathURL[$swMath] $swMathName[$swMath]]"] = $swMathVer[$swMath];
252259 }
253260 }
254261 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r52646quick fix for r52624: handle the case when the executable isn't found, since ...ialex20:08, 1 July 2009
r52653added path value support on the file check on Special:Version....shinjiman21:31, 1 July 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r52525* (bug 14611) Added support showing the version of the Math rendering engine.shinjiman18:42, 28 June 2009
r52527fix up, link to r52525 for CodeReview if any comments are added.shinjiman19:24, 28 June 2009
r52547fix up to add the local bin path, link to r52527 and r52525 for CodeReview if...shinjiman15:35, 29 June 2009

Comments

#Comment by 😂 (talk | contribs)   20:14, 1 July 2009

So we go from one hardcoded thing to another? Whereis doesn't even exist on Windows. Suggest reverting all of this lot (all of these new version # checks) until/unless we can be at least slightly more platform independent.

#Comment by Shinjiman (talk | contribs)   20:31, 1 July 2009

So it have to check the existence of whereis prior to execute the command, as the code listed above.

Hopefully more platforms will be supported soon. :)

#Comment by Shinjiman (talk | contribs)   21:33, 1 July 2009

added path support in r52653.

Status & tagging log