Laravel version update
Laravel version update
This commit is contained in:
50
vendor/symfony/process/Pipes/WindowsPipes.php
vendored
50
vendor/symfony/process/Pipes/WindowsPipes.php
vendored
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Process\Pipes;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\Exception\RuntimeException;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* WindowsPipes implementation uses temporary files as handles.
|
||||
@@ -26,23 +26,19 @@ use Symfony\Component\Process\Exception\RuntimeException;
|
||||
*/
|
||||
class WindowsPipes extends AbstractPipes
|
||||
{
|
||||
/** @var array */
|
||||
private $files = array();
|
||||
/** @var array */
|
||||
private $fileHandles = array();
|
||||
/** @var array */
|
||||
private $readBytes = array(
|
||||
Process::STDOUT => 0,
|
||||
Process::STDERR => 0,
|
||||
);
|
||||
/** @var bool */
|
||||
private $disableOutput;
|
||||
private $haveReadSupport;
|
||||
|
||||
public function __construct($disableOutput, $input)
|
||||
public function __construct($input, $haveReadSupport)
|
||||
{
|
||||
$this->disableOutput = (bool) $disableOutput;
|
||||
$this->haveReadSupport = (bool) $haveReadSupport;
|
||||
|
||||
if (!$this->disableOutput) {
|
||||
if ($this->haveReadSupport) {
|
||||
// Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big.
|
||||
// Workaround for this problem is to use temporary files instead of pipes on Windows platform.
|
||||
//
|
||||
@@ -51,9 +47,10 @@ class WindowsPipes extends AbstractPipes
|
||||
Process::STDOUT => Process::OUT,
|
||||
Process::STDERR => Process::ERR,
|
||||
);
|
||||
$tmpCheck = false;
|
||||
$tmpDir = sys_get_temp_dir();
|
||||
$error = 'unknown reason';
|
||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
$lastError = 'unknown reason';
|
||||
set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
|
||||
for ($i = 0;; ++$i) {
|
||||
foreach ($pipes as $pipe => $name) {
|
||||
$file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
|
||||
@@ -61,7 +58,11 @@ class WindowsPipes extends AbstractPipes
|
||||
continue 2;
|
||||
}
|
||||
$h = fopen($file, 'xb');
|
||||
if (!$h && false === strpos($error, 'File exists')) {
|
||||
if (!$h) {
|
||||
$error = $lastError;
|
||||
if ($tmpCheck || $tmpCheck = unlink(tempnam(false, 'sf_check_'))) {
|
||||
continue;
|
||||
}
|
||||
restore_error_handler();
|
||||
throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $error));
|
||||
}
|
||||
@@ -92,7 +93,7 @@ class WindowsPipes extends AbstractPipes
|
||||
*/
|
||||
public function getDescriptors()
|
||||
{
|
||||
if ($this->disableOutput) {
|
||||
if (!$this->haveReadSupport) {
|
||||
$nullstream = fopen('NUL', 'c');
|
||||
|
||||
return array(
|
||||
@@ -140,7 +141,7 @@ class WindowsPipes extends AbstractPipes
|
||||
$data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
|
||||
|
||||
if (isset($data[0])) {
|
||||
$this->readBytes[$type] += strlen($data);
|
||||
$this->readBytes[$type] += \strlen($data);
|
||||
$read[$type] = $data;
|
||||
}
|
||||
if ($close) {
|
||||
@@ -152,6 +153,14 @@ class WindowsPipes extends AbstractPipes
|
||||
return $read;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function haveReadSupport()
|
||||
{
|
||||
return $this->haveReadSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -172,19 +181,6 @@ class WindowsPipes extends AbstractPipes
|
||||
$this->fileHandles = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new WindowsPipes instance.
|
||||
*
|
||||
* @param Process $process The process
|
||||
* @param $input
|
||||
*
|
||||
* @return WindowsPipes
|
||||
*/
|
||||
public static function create(Process $process, $input)
|
||||
{
|
||||
return new static($process->isOutputDisabled(), $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes temporary files.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user