-
Bug
-
Resolution: Fixed
-
Minor
-
1.6, 1.6.1, 1.6.2, 1.6.3, 1.7
-
None
-
MOODLE_16_STABLE, MOODLE_17_STABLE
-
MOODLE_19_STABLE
Bug discovered with Moodle 1.6.3 on Linux and PHP 5.2 .
I think this is a new bug which has nothing to do with other the registered bugs about statistics (in particular bug MDL-7385)
The script admin/report.php tell me that "Statistics is currently in catchup mode. So far 63 day(s) have been processed and 2 are pending".
- 63 days is quite right: I started statistics for about two months. This number is incremented day after day: OK.
- 2 days are pending. Why?
I debug and found that actually the last fully elapsed day (I mean "yesterday") has not be processed. And would never be processed, in my case.
For example:
- suppose previous statistics have been processed until Monday (included); therefore last timeend in stats_daily table has been set to "Tuesday 00:00" (Tuesday early morning). OK.
- on Wednesday, statistics is starting again and should be gather Tuesday's records, from Tuesday morning 00:00 till Wednesday morning 00:00 . But it does nothing. Because it believes that we are still on Tuesday.
Indeed, in function stats_cron_daily of statslib.ph (line #101), days are processed one by one: "while ($midnight > $nextmidnight)". In other words: "if today midnight (Wednesday tonight 23:59) is after Tuesday midnight 00:00". But "today midnight" seems bad measured (with stats_getmidnight function) and is set to Tuesday midnight 00:00 (in place of Wednesday midnight 00:00). So the loop stops one step too early.
****************************
So I have patched function stats_cron_daily of statslib.ph, replacing line #67
$midnight = stats_getmidnight(time());
with
$midnight = stats_get_next_dayend(time());
****************************
And, for me, it works fine: the "yesterday" is always well processed.
See also some part of this discuss:
http://moodle.org/mod/forum/discuss.php?d=57242#274543