Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/flow-flo.../libs/cakephp/core/Retry
File: CommandRetry.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
[2] Fix | Delete
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[3] Fix | Delete
*
[4] Fix | Delete
* Licensed under The MIT License
[5] Fix | Delete
* For full copyright and license information, please see the LICENSE.txt
[6] Fix | Delete
* Redistributions of files must retain the above copyright notice.
[7] Fix | Delete
*
[8] Fix | Delete
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[9] Fix | Delete
* @link https://cakephp.org CakePHP(tm) Project
[10] Fix | Delete
* @since 3.6.0
[11] Fix | Delete
* @license https://opensource.org/licenses/mit-license.php MIT License
[12] Fix | Delete
*/
[13] Fix | Delete
namespace Cake\Core\Retry;
[14] Fix | Delete
[15] Fix | Delete
use Exception;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Allows any action to be retried in case of an exception.
[19] Fix | Delete
*
[20] Fix | Delete
* This class can be parametrized with a strategy, which will be followed
[21] Fix | Delete
* to determine whether or not the action should be retried.
[22] Fix | Delete
*/
[23] Fix | Delete
class CommandRetry
[24] Fix | Delete
{
[25] Fix | Delete
/**
[26] Fix | Delete
* The strategy to follow should the executed action fail.
[27] Fix | Delete
*
[28] Fix | Delete
* @var \Cake\Core\Retry\RetryStrategyInterface
[29] Fix | Delete
*/
[30] Fix | Delete
protected $strategy;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* The number of retries to perform in case of failure.
[34] Fix | Delete
*
[35] Fix | Delete
* @var int
[36] Fix | Delete
*/
[37] Fix | Delete
protected $retries;
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Creates the CommandRetry object with the given strategy and retry count
[41] Fix | Delete
*
[42] Fix | Delete
* @param \Cake\Core\Retry\RetryStrategyInterface $strategy The strategy to follow should the action fail
[43] Fix | Delete
* @param int $retries The number of times the action has been already called
[44] Fix | Delete
*/
[45] Fix | Delete
public function __construct(RetryStrategyInterface $strategy, $retries = 1)
[46] Fix | Delete
{
[47] Fix | Delete
$this->strategy = $strategy;
[48] Fix | Delete
$this->retries = $retries;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* The number of retries to perform in case of failure
[53] Fix | Delete
*
[54] Fix | Delete
* @param callable $action The callable action to execute with a retry strategy
[55] Fix | Delete
* @return mixed The return value of the passed action callable
[56] Fix | Delete
* @throws \Exception
[57] Fix | Delete
*/
[58] Fix | Delete
public function run(callable $action)
[59] Fix | Delete
{
[60] Fix | Delete
$retryCount = 0;
[61] Fix | Delete
$lastException = null;
[62] Fix | Delete
[63] Fix | Delete
do {
[64] Fix | Delete
try {
[65] Fix | Delete
return $action();
[66] Fix | Delete
} catch (Exception $e) {
[67] Fix | Delete
$lastException = $e;
[68] Fix | Delete
if (!$this->strategy->shouldRetry($e, $retryCount)) {
[69] Fix | Delete
throw $e;
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
} while ($this->retries > $retryCount++);
[73] Fix | Delete
[74] Fix | Delete
if ($lastException !== null) {
[75] Fix | Delete
throw $lastException;
[76] Fix | Delete
}
[77] Fix | Delete
}
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function