Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -383,6 +383,21 @@ |
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
| 387 | + * Get an array of likely places we can find executables. Check a bunch |
| 388 | + * of known Unix-like defaults, as well as the PATH environment variable |
| 389 | + * (which should maybe make it work for Windows?) |
| 390 | + * |
| 391 | + * @return Array |
| 392 | + */ |
| 393 | + protected function getPossibleBinPaths() { |
| 394 | + return array_merge( |
| 395 | + array( '/usr/bin', '/usr/local/bin', '/opt/csw/bin', |
| 396 | + '/usr/gnu/bin', '/usr/sfw/bin', '/sw/bin', '/opt/local/bin' ), |
| 397 | + explode( PATH_SEPARATOR, getenv( 'PATH' ) ) |
| 398 | + ); |
| 399 | + } |
| 400 | + |
| 401 | + /** |
387 | 402 | * Check if we're installing the latest version. |
388 | 403 | */ |
389 | 404 | public function envLatestVersion() { |
— | — | @@ -590,23 +605,12 @@ |
591 | 606 | * Search for GNU diff3. |
592 | 607 | */ |
593 | 608 | public function envCheckDiff3() { |
594 | | - $paths = array_merge( |
595 | | - array( |
596 | | - "/usr/bin", |
597 | | - "/usr/local/bin", |
598 | | - "/opt/csw/bin", |
599 | | - "/usr/gnu/bin", |
600 | | - "/usr/sfw/bin" |
601 | | - ), |
602 | | - explode( PATH_SEPARATOR, getenv( "PATH" ) ) |
603 | | - ); |
604 | | - |
605 | 609 | $names = array( "gdiff3", "diff3", "diff3.exe" ); |
606 | 610 | $versionInfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' ); |
607 | 611 | |
608 | 612 | $haveDiff3 = false; |
609 | 613 | |
610 | | - foreach ( $paths as $path ) { |
| 614 | + foreach ( $this->getPossibleBinPaths() as $path ) { |
611 | 615 | $exe = $this->locateExecutable( $path, $names, $versionInfo ); |
612 | 616 | |
613 | 617 | if ($exe !== false) { |
— | — | @@ -628,28 +632,28 @@ |
629 | 633 | * Environment check for ImageMagick and GD. |
630 | 634 | */ |
631 | 635 | public function envCheckGraphics() { |
632 | | - $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" ); |
| 636 | + $names = array( 'convert', 'convert.exe' ); |
| 637 | + $haveConvert = false; |
633 | 638 | |
634 | | - foreach( $imcheck as $dir ) { |
635 | | - $im = "$dir/convert"; |
| 639 | + foreach ( $this->getPossibleBinPaths() as $path ) { |
| 640 | + $exe = $this->locateExecutable( $path, $names ); |
636 | 641 | |
637 | | - wfSuppressWarnings(); |
638 | | - $file_exists = file_exists( $im ); |
639 | | - wfRestoreWarnings(); |
640 | | - |
641 | | - if( $file_exists ) { |
642 | | - $this->showMessage( 'config-imagemagick', $im ); |
643 | | - $this->setVar( 'wgImageMagickConvertCommand', $im ); |
644 | | - return true; |
| 642 | + if ($exe !== false) { |
| 643 | + $this->setVar( 'wgImageMagickConvertCommand', $exe ); |
| 644 | + $haveConvert = true; |
| 645 | + break; |
645 | 646 | } |
646 | 647 | } |
647 | 648 | |
648 | | - if ( function_exists( 'imagejpeg' ) ) { |
| 649 | + if ( $haveConvert ) { |
| 650 | + $this->showMessage( 'config-imagemagick', $exe ); |
| 651 | + return true; |
| 652 | + } elseif ( function_exists( 'imagejpeg' ) ) { |
649 | 653 | $this->showMessage( 'config-gd' ); |
650 | 654 | return true; |
| 655 | + } else { |
| 656 | + $this->showMessage( 'no-scaling' ); |
651 | 657 | } |
652 | | - |
653 | | - $this->showMessage( 'no-scaling' ); |
654 | 658 | } |
655 | 659 | |
656 | 660 | /** |