Commit d208ad19 authored by i-trokhanenko's avatar i-trokhanenko Committed by DamienMcKenna

Issue #3028984 by i-trokhanenko, Roman Dyn: Replace deprecated REQUEST_TIME.

parent efbe91ec
......@@ -10,6 +10,7 @@ Backup and Migrate 8.x-4.x-dev, xxxx-xx-xx
#2935402 by DamienMcKenna, ikit-claw: Further improve coding standards
compliance.
#2935402 by DamienMcKenna: Further improve coding standards compliance.
#3028984 by i-trokhanenko, Roman Dyn: Replace deprecated REQUEST_TIME.
Backup and Migrate 8.x-4.0, 2018-03-29
......
......@@ -42,9 +42,10 @@ class ScheduleListBuilder extends ConfigEntityListBuilder {
$row['period'] = $entity->getPeriodFormatted();
$row['last_run'] = $this->t('Never');
$time = \Drupal::time();
if ($last_run = $entity->getLastRun()) {
$row['last_run'] = \Drupal::service('date.formatter')->format($last_run, 'small');
$row['last_run'] .= ' (' . $this->t('@time ago', ['@time' => \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $last_run)]) . ')';
$row['last_run'] .= ' (' . $this->t('@time ago', ['@time' => \Drupal::service('date.formatter')->formatInterval($time->getRequestTime() - $last_run)]) . ')';
}
$row['next_run'] = $this->t('Not Scheduled');
......@@ -52,8 +53,8 @@ class ScheduleListBuilder extends ConfigEntityListBuilder {
$row['next_run'] = $this->t('Disabled');
}
elseif ($next_run = $entity->getNextRun()) {
$interval = \Drupal::service('date.formatter')->formatInterval(abs($next_run - REQUEST_TIME));
if ($next_run > REQUEST_TIME) {
$interval = \Drupal::service('date.formatter')->formatInterval(abs($next_run - $time->getRequestTime()));
if ($next_run > $time->getRequestTime()) {
$row['next_run'] = \Drupal::service('date.formatter')->format($next_run, 'small');
$row['next_run'] .= ' (' . $this->t('in @time', ['@time' => $interval]) . ')';
}
......
......@@ -60,12 +60,13 @@ class Schedule extends ConfigEntityBase {
*/
public function run(BackupMigrateInterface $bam, $force = FALSE) {
$next_run_at = $this->getNextRun();
$should_run_now = (REQUEST_TIME >= $next_run_at);
$time = \Drupal::time();
$should_run_now = ($time->getRequestTime() >= $next_run_at);
$enabled = $this->get('enabled');
if ($force || ($should_run_now && $enabled)) {
// Set the last run time before attempting backup.
// This will prevent a failing schedule from retrying on every cron run.
$this->setLastRun(REQUEST_TIME);
$this->setLastRun($time->getRequestTime());
try {
$config = [];
......@@ -149,7 +150,7 @@ class Schedule extends ConfigEntityBase {
if ($last_run_at) {
return $last_run_at + $this->get('period');
}
return REQUEST_TIME - 1;
return \Drupal::time()->getRequestTime() - 1;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment