Пример #1
0
 /**
  * Skip the test if 'gzip' is not in $PATH.
  *
  * @return bool
  */
 protected function checkHasGzip()
 {
     if (self::$hasGzip === null) {
         self::$hasGzip = Installer::locateExecutableInDefaultPaths('gzip') !== false;
     }
     if (!self::$hasGzip) {
         $this->markTestSkipped("Skip test, requires the gzip utility in PATH");
     }
     return self::$hasGzip;
 }
Пример #2
0
 /**
  * Determine if there is a usable tidy.
  */
 public function __construct($useConfiguration = false)
 {
     global $IP, $wgUseTidy, $wgTidyBin, $wgTidyInternal, $wgTidyConfig, $wgTidyConf, $wgTidyOpts;
     $this->enabled = true;
     if ($useConfiguration) {
         if ($wgTidyConfig !== null) {
             $this->config = $wgTidyConfig;
         } elseif ($wgUseTidy) {
             $this->config = ['tidyConfigFile' => $wgTidyConf, 'debugComment' => false, 'tidyBin' => $wgTidyBin, 'tidyCommandLine' => $wgTidyOpts];
             if ($wgTidyInternal) {
                 $this->config['driver'] = wfIsHHVM() ? 'RaggettInternalHHVM' : 'RaggettInternalPHP';
             } else {
                 $this->config['driver'] = 'RaggettExternal';
             }
         } else {
             $this->enabled = false;
         }
     } else {
         $this->config = ['tidyConfigFile' => "{$IP}/includes/tidy/tidy.conf", 'tidyCommandLine' => ''];
         if (extension_loaded('tidy') && class_exists('tidy')) {
             $this->config['driver'] = wfIsHHVM() ? 'RaggettInternalHHVM' : 'RaggettInternalPHP';
         } else {
             if (is_executable($wgTidyBin)) {
                 $this->config['driver'] = 'RaggettExternal';
                 $this->config['tidyBin'] = $wgTidyBin;
             } else {
                 $path = Installer::locateExecutableInDefaultPaths($wgTidyBin);
                 if ($path !== false) {
                     $this->config['driver'] = 'RaggettExternal';
                     $this->config['tidyBin'] = $wgTidyBin;
                 } else {
                     $this->enabled = false;
                 }
             }
         }
     }
     if (!$this->enabled) {
         $this->config = ['driver' => 'disabled'];
     }
 }
Пример #3
0
 /**
  * Emulate readline()
  * @param $prompt String what to begin the line with, like '> '
  * @return String
  */
 private static function readlineEmulation($prompt)
 {
     $bash = Installer::locateExecutableInDefaultPaths(array('bash'));
     if (!wfIsWindows() && $bash) {
         $retval = false;
         $encPrompt = wfEscapeShellArg($prompt);
         $command = "read -er -p {$encPrompt} && echo \"\$REPLY\"";
         $encCommand = wfEscapeShellArg($command);
         $line = wfShellExec("{$bash} -c {$encCommand}", $retval);
         if ($retval == 0) {
             return $line;
         } elseif ($retval == 127) {
             // Couldn't execute bash even though we thought we saw it.
             // Shell probably spit out an error message, sorry :(
             // Fall through to fgets()...
         } else {
             // EOF/ctrl+D
             return false;
         }
     }
     // Fallback... we'll have no editing controls, EWWW
     if (feof(STDIN)) {
         return false;
     }
     print $prompt;
     return fgets(STDIN, 1024);
 }