From 8a4f91b671e2f8d2c3334bb64de7bc4a2927391b Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Wed, 11 Apr 2007 23:53:14 +0000 Subject: [PATCH] merged: fixing warnings in stats lib - rather than doing an include_once and noticing for every missing mod, check the file exists first from MOODLE_16_STABLE, and fixed up some weirdness in the reports --- lib/statslib.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/statslib.php b/lib/statslib.php index 34a6907b470..7c6c53d0e45 100644 --- a/lib/statslib.php +++ b/lib/statslib.php @@ -81,9 +81,11 @@ function stats_cron_daily () { $daily_modules = array(); $mods = get_records("modules"); foreach ($mods as $mod) { - // include_once() will only warn if a mod is missing - // as we don't want processing to stop on such minutiae (MDL-7385) - include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php'); + $file = $CFG->dirroot.'/mod/'.$mod->name.'/lib.php'; + if (!is_readable($file)) { + continue; + } + require_once($file); $fname = $mod->name.'_get_daily_stats'; if (function_exists($fname)) { $daily_modules[$mod] = $fname; @@ -238,7 +240,11 @@ function stats_cron_weekly () { $weekly_modules = array(); $mods = get_records("modules"); foreach ($mods as $mod) { - include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php'); + $file = $CFG->dirroot.'/mod/'.$mod->name.'/lib.php'; + if (!is_readable($file)) { + continue; + } + require_once($file); $fname = $mod->name.'_get_weekly_stats'; if (function_exists($fname)) { $weekly_modules[$mod] = $fname; @@ -367,7 +373,11 @@ function stats_cron_monthly () { $monthly_modules = array(); $mods = get_records("modules"); foreach ($mods as $mod) { - include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php'); + $file = $CFG->dirroot.'/mod/'.$mod->name.'/lib.php'; + if (!is_readable($file)) { + continue; + } + require_once($file); $fname = $mod->name.'_get_monthly_stats'; if (function_exists($fname)) { $monthly_modules[$mod] = $fname; @@ -769,7 +779,11 @@ function stats_get_action_sql_in($str) { $function = 'stats_get_'.$str.'_actions'; $actions = $function(); foreach ($mods as $mod) { - include_once($CFG->dirroot.'/mod/'.$mod->name.'/lib.php'); + $file = $CFG->dirroot.'/mod/'.$mod->name.'/lib.php'; + if (!is_readable($file)) { + continue; + } + require_once($file); $function = $mod->name.'_get_'.$str.'_actions'; if (function_exists($function)) { $actions = array_merge($actions,$function());