mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
MDL-13660: Allow admin reports to have db tables, cron
This commit is contained in:
parent
c2acd8318b
commit
d9b063277b
@ -109,6 +109,7 @@
|
||||
$cron_function = $mod->name."_cron";
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing module function $cron_function ...", '');
|
||||
$pre_dbqueries = null;
|
||||
if (!empty($PERF->dbqueries)) {
|
||||
$pre_dbqueries = $PERF->dbqueries;
|
||||
$pre_time = microtime(1);
|
||||
@ -159,6 +160,33 @@
|
||||
}
|
||||
mtrace('Finished blocks');
|
||||
|
||||
mtrace('Starting admin reports');
|
||||
// Admin reports do not have a database table that lists them. Instead a
|
||||
// report includes cron.php with function report_reportname_cron() if it wishes
|
||||
// to be cronned. It is up to cron.php to handle e.g. if it only needs to
|
||||
// actually do anything occasionally.
|
||||
$reports = get_list_of_plugins($CFG->admin.'/report');
|
||||
foreach($reports as $report) {
|
||||
$cronfile = $CFG->dirroot.'/'.$CFG->admin.'/report/'.$report.'/cron.php';
|
||||
if (file_exists($cronfile)) {
|
||||
require_once($cronfile);
|
||||
$cronfunction = 'report_'.$report.'_cron';
|
||||
mtrace('Processing cron function for '.$report.'...', '');
|
||||
$pre_dbqueries = null;
|
||||
if (!empty($PERF->dbqueries)) {
|
||||
$pre_dbqueries = $PERF->dbqueries;
|
||||
$pre_time = microtime(true);
|
||||
}
|
||||
$cronfunction();
|
||||
if (isset($pre_dbqueries)) {
|
||||
mtrace("... used " . ($PERF->dbqueries - $pre_dbqueries) . " dbqueries");
|
||||
mtrace("... used " . round(microtime(true) - $pre_time, 2) . " seconds");
|
||||
}
|
||||
mtrace('done.');
|
||||
}
|
||||
}
|
||||
mtrace('Finished admin reports');
|
||||
|
||||
if (!empty($CFG->langcache)) {
|
||||
mtrace('Updating languages cache');
|
||||
get_list_of_languages(true);
|
||||
@ -191,6 +219,7 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
mtrace('Starting main gradebook job ...');
|
||||
grade_cron();
|
||||
mtrace('done.');
|
||||
|
@ -466,6 +466,9 @@
|
||||
/// Check all message output plugins and upgrade if necessary
|
||||
upgrade_plugins('message','message/output',"$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
/// Check all admin report plugins and upgrade if necessary
|
||||
upgrade_plugins('report', $CFG->admin.'/report', "$CFG->wwwroot/$CFG->admin/index.php");
|
||||
|
||||
|
||||
/// just make sure upgrade logging is properly terminated
|
||||
upgrade_log_finish();
|
||||
|
@ -814,6 +814,13 @@ function get_db_directories() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Now admin report plugins (admin/report/xxx/db)
|
||||
if ($plugins = get_list_of_plugins($CFG->admin.'/report', 'db')) {
|
||||
foreach ($plugins as $plugin) {
|
||||
$dbdirs[] = $CFG->dirroot.'/'.$CFG->admin.'/report/'.$plugin.'/db';
|
||||
}
|
||||
}
|
||||
|
||||
/// Local database changes, if the local folder exists.
|
||||
if (file_exists($CFG->dirroot . '/local')) {
|
||||
$dbdirs[] = $CFG->dirroot.'/local/db';
|
||||
|
Loading…
x
Reference in New Issue
Block a user