Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixing warnings in stats lib - rather than doing an include_once and …

…noticing for every missing mod, check the file exists first
  • Loading branch information...
commit 284060cc7e4d8097971d2af1131c736482ce2387 1 parent 20a37a1
mjollnir_ authored
Showing with 20 additions and 4 deletions.
  1. +20 −4 lib/statslib.php
View
24 lib/statslib.php
@@ -82,7 +82,11 @@ function stats_cron_daily () {
$daily_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_daily_stats';
if (function_exists($fname)) {
$daily_modules[$mod] = $fname;
@@ -222,7 +226,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;
@@ -331,7 +339,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;
@@ -630,7 +642,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());

0 comments on commit 284060c

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