Update to Drupal 8.1.7. For more information, see https://www.drupal.org/project/drupal/releases/8.1.7
This commit is contained in:
parent
38ba7c357d
commit
e9f047ccf8
61 changed files with 1613 additions and 561 deletions
31
vendor/guzzlehttp/promises/src/EachPromise.php
vendored
31
vendor/guzzlehttp/promises/src/EachPromise.php
vendored
|
|
@ -24,6 +24,9 @@ class EachPromise implements PromisorInterface
|
|||
/** @var Promise */
|
||||
private $aggregate;
|
||||
|
||||
/** @var bool */
|
||||
private $mutex;
|
||||
|
||||
/**
|
||||
* Configuration hash can include the following key value pairs:
|
||||
*
|
||||
|
|
@ -72,6 +75,8 @@ class EachPromise implements PromisorInterface
|
|||
$this->createPromise();
|
||||
$this->iterable->rewind();
|
||||
$this->refillPending();
|
||||
} catch (\Throwable $e) {
|
||||
$this->aggregate->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
$this->aggregate->reject($e);
|
||||
}
|
||||
|
|
@ -81,8 +86,14 @@ class EachPromise implements PromisorInterface
|
|||
|
||||
private function createPromise()
|
||||
{
|
||||
$this->mutex = false;
|
||||
$this->aggregate = new Promise(function () {
|
||||
reset($this->pending);
|
||||
if (empty($this->pending) && !$this->iterable->valid()) {
|
||||
$this->aggregate->resolve(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Consume a potentially fluctuating list of promises while
|
||||
// ensuring that indexes are maintained (precluding array_shift).
|
||||
while ($promise = current($this->pending)) {
|
||||
|
|
@ -164,11 +175,25 @@ class EachPromise implements PromisorInterface
|
|||
|
||||
private function advanceIterator()
|
||||
{
|
||||
// Place a lock on the iterator so that we ensure to not recurse,
|
||||
// preventing fatal generator errors.
|
||||
if ($this->mutex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->mutex = true;
|
||||
|
||||
try {
|
||||
$this->iterable->next();
|
||||
$this->mutex = false;
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
$this->aggregate->reject($e);
|
||||
$this->mutex = false;
|
||||
return false;
|
||||
} catch (\Exception $e) {
|
||||
$this->aggregate->reject($e);
|
||||
$this->mutex = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -181,9 +206,11 @@ class EachPromise implements PromisorInterface
|
|||
}
|
||||
|
||||
unset($this->pending[$idx]);
|
||||
$this->advanceIterator();
|
||||
|
||||
if (!$this->checkIfFinished()) {
|
||||
// Only refill pending promises if we are not locked, preventing the
|
||||
// EachPromise to recursively invoke the provided iterator, which
|
||||
// cause a fatal error: "Cannot resume an already running generator"
|
||||
if ($this->advanceIterator() && !$this->checkIfFinished()) {
|
||||
// Add more pending promises if possible.
|
||||
$this->refillPending();
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue