runner = $runner ?: new \DeliciousBrains\WP_Offload_Media\Gcp\Google\Cloud\Core\Batch\BatchRunner(); $this->initFailureFile(); } /** * Retry all the failed items. */ public function retryAll() { foreach ($this->getFailedFiles() as $file) { // Rename the file first $tmpFile = dirname($file) . '/retrying-' . basename($file); rename($file, $tmpFile); $fp = @fopen($tmpFile, 'r'); if ($fp === false) { fwrite(STDERR, sprintf('Could not open the file: %s' . PHP_EOL, $tmpFile)); continue; } while ($line = fgets($fp)) { $a = unserialize($line); $idNum = key($a); $job = $this->runner->getJobFromIdNum($idNum); if (!$job->callFunc($a[$idNum])) { $this->handleFailure($idNum, $a[$idNum]); } } @fclose($fp); @unlink($tmpFile); } } }