MDL-58596 core_stats: fixed infinite loop cause by DST change

This commit is contained in:
Leon Stringer 2018-12-11 17:22:59 +00:00 committed by Víctor Déniz Falcón
parent 5007d1cb04
commit 8f402dbc66

View File

@ -987,18 +987,24 @@ function stats_get_base_daily($time=0) {
function stats_get_base_weekly($time=0) {
global $CFG;
$time = stats_get_base_daily($time);
$datetime = new DateTime();
$datetime->setTimestamp(stats_get_base_daily($time));
$startday = $CFG->calendar_startwday;
core_date::set_default_server_timezone();
$thisday = date('w', $time);
$days = 0;
if ($thisday > $startday) {
$time = $time - (($thisday - $startday) * 60*60*24);
$days = $thisday - $startday;
} else if ($thisday < $startday) {
$time = $time - ((7 + $thisday - $startday) * 60*60*24);
$days = 7 + $thisday - $startday;
}
return $time;
$datetime->sub(new DateInterval("P{$days}D"));
return $datetime->getTimestamp();
}
/**