Skip to content
Browse files

Merge branch 'MDL-29470-21' of git://github.com/FMCorz/moodle into MO…

…ODLE_21_STABLE
  • Loading branch information...
2 parents bdeeadb + e1abf00 commit c54cd379ac317dfa325fbc170f57b6887bad2c22 Sam Hemelryk committed Jul 10, 2012
Showing with 11 additions and 9 deletions.
  1. +11 −9 backup/util/helper/backup_cron_helper.class.php
View
20 backup/util/helper/backup_cron_helper.class.php
@@ -281,23 +281,25 @@ public static function calculate_next_automated_backup($timezone, $now) {
$midnight = usergetmidnight($now, $timezone);
$date = usergetdate($now, $timezone);
- //Get number of days (from today) to execute backups
- $automateddays = substr($config->backup_auto_weekdays,$date['wday']) . $config->backup_auto_weekdays;
- $daysfromtoday = strpos($automateddays, "1");
+ // Get number of days (from today) to execute backups
+ $automateddays = substr($config->backup_auto_weekdays, $date['wday']) . $config->backup_auto_weekdays;
+ $daysfromtoday = strpos($automateddays, "1", 1);
+
+ // If we can't find the next day, we set it to tomorrow
if (empty($daysfromtoday)) {
$daysfromtoday = 1;
}
- //If some day has been found
+ // If some day has been found
if ($daysfromtoday !== false) {
- //Calculate distance
- $dist = ($daysfromtoday * 86400) + //Days distance
- ($config->backup_auto_hour * 3600) + //Hours distance
- ($config->backup_auto_minute * 60); //Minutes distance
+ // Calculate distance
+ $dist = ($daysfromtoday * 86400) + // Days distance
+ ($config->backup_auto_hour * 3600) + // Hours distance
+ ($config->backup_auto_minute * 60); // Minutes distance
$result = $midnight + $dist;
}
- //If that time is past, call the function recursively to obtain the next valid day
+ // If that time is past, call the function recursively to obtain the next valid day
if ($result > 0 && $result < time()) {
$result = self::calculate_next_automated_backup($timezone, $result);
}

0 comments on commit c54cd37

Please sign in to comment.
Something went wrong with that request. Please try again.