Merge branch 'MDL-37584-28' of git://github.com/ankitagarwal/moodle into MOODLE_28_STABLE

This commit is contained in:
Eloy Lafuente (stronk7)
2015-01-08 00:46:41 +01:00
@@ -28,6 +28,9 @@ namespace core\task;
*/
class send_failed_login_notifications_task extends scheduled_task {
/** The maximum time period to look back (30 days = 30 * 24 * 3600) */
const NOTIFY_MAXIMUM_TIME = 2592000;
/**
* Get a descriptive name for this task (shown to admins).
*
@@ -50,8 +53,10 @@ class send_failed_login_notifications_task extends scheduled_task {
$recip = get_users_from_config($CFG->notifyloginfailures, 'moodle/site:config');
if (empty($CFG->lastnotifyfailure)) {
$CFG->lastnotifyfailure = 0;
// Do not look back more than 1 month to avoid crashes due to huge number of records.
$maximumlastnotifytime = time() - self::NOTIFY_MAXIMUM_TIME;
if (empty($CFG->lastnotifyfailure) || ($CFG->lastnotifyfailure < $maximumlastnotifytime)) {
$CFG->lastnotifyfailure = $maximumlastnotifytime;
}
// If it has been less than an hour, or if there are no recipients, don't execute.