Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../vendor/guzzle/guzzle/src/Guzzle/Plugin/Backoff
File: AbstractBackoffStrategy.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Guzzle\Plugin\Backoff;
[2] Fix | Delete
[3] Fix | Delete
use Guzzle\Http\Message\RequestInterface;
[4] Fix | Delete
use Guzzle\Http\Message\Response;
[5] Fix | Delete
use Guzzle\Http\Exception\HttpException;
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Abstract backoff strategy that allows for a chain of responsibility
[9] Fix | Delete
*/
[10] Fix | Delete
abstract class AbstractBackoffStrategy implements BackoffStrategyInterface
[11] Fix | Delete
{
[12] Fix | Delete
/** @var AbstractBackoffStrategy Next strategy in the chain */
[13] Fix | Delete
protected $next;
[14] Fix | Delete
[15] Fix | Delete
/** @param AbstractBackoffStrategy $next Next strategy in the chain */
[16] Fix | Delete
public function setNext(AbstractBackoffStrategy $next)
[17] Fix | Delete
{
[18] Fix | Delete
$this->next = $next;
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Get the next backoff strategy in the chain
[23] Fix | Delete
*
[24] Fix | Delete
* @return AbstractBackoffStrategy|null
[25] Fix | Delete
*/
[26] Fix | Delete
public function getNext()
[27] Fix | Delete
{
[28] Fix | Delete
return $this->next;
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
public function getBackoffPeriod(
[32] Fix | Delete
$retries,
[33] Fix | Delete
RequestInterface $request,
[34] Fix | Delete
Response $response = null,
[35] Fix | Delete
HttpException $e = null
[36] Fix | Delete
) {
[37] Fix | Delete
$delay = $this->getDelay($retries, $request, $response, $e);
[38] Fix | Delete
if ($delay === false) {
[39] Fix | Delete
// The strategy knows that this must not be retried
[40] Fix | Delete
return false;
[41] Fix | Delete
} elseif ($delay === null) {
[42] Fix | Delete
// If the strategy is deferring a decision and the next strategy will not make a decision then return false
[43] Fix | Delete
return !$this->next || !$this->next->makesDecision()
[44] Fix | Delete
? false
[45] Fix | Delete
: $this->next->getBackoffPeriod($retries, $request, $response, $e);
[46] Fix | Delete
} elseif ($delay === true) {
[47] Fix | Delete
// if the strategy knows that it must retry but is deferring to the next to determine the delay
[48] Fix | Delete
if (!$this->next) {
[49] Fix | Delete
return 0;
[50] Fix | Delete
} else {
[51] Fix | Delete
$next = $this->next;
[52] Fix | Delete
while ($next->makesDecision() && $next->getNext()) {
[53] Fix | Delete
$next = $next->getNext();
[54] Fix | Delete
}
[55] Fix | Delete
return !$next->makesDecision() ? $next->getBackoffPeriod($retries, $request, $response, $e) : 0;
[56] Fix | Delete
}
[57] Fix | Delete
} else {
[58] Fix | Delete
return $delay;
[59] Fix | Delete
}
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Check if the strategy does filtering and makes decisions on whether or not to retry.
[64] Fix | Delete
*
[65] Fix | Delete
* Strategies that return false will never retry if all of the previous strategies in a chain defer on a backoff
[66] Fix | Delete
* decision.
[67] Fix | Delete
*
[68] Fix | Delete
* @return bool
[69] Fix | Delete
*/
[70] Fix | Delete
abstract public function makesDecision();
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* Implement the concrete strategy
[74] Fix | Delete
*
[75] Fix | Delete
* @param int $retries Number of retries of the request
[76] Fix | Delete
* @param RequestInterface $request Request that was sent
[77] Fix | Delete
* @param Response $response Response that was received. Note that there may not be a response
[78] Fix | Delete
* @param HttpException $e Exception that was encountered if any
[79] Fix | Delete
*
[80] Fix | Delete
* @return bool|int|null Returns false to not retry or the number of seconds to delay between retries. Return true
[81] Fix | Delete
* or null to defer to the next strategy if available, and if not, return 0.
[82] Fix | Delete
*/
[83] Fix | Delete
abstract protected function getDelay(
[84] Fix | Delete
$retries,
[85] Fix | Delete
RequestInterface $request,
[86] Fix | Delete
Response $response = null,
[87] Fix | Delete
HttpException $e = null
[88] Fix | Delete
);
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function