catalyst / moodle-report_coursesize

upgraded coursesize report
14 stars 19 forks source link

Error for 4.2 version scheduled task after cache is cleared #55

Closed turf212 closed 1 year ago

turf212 commented 1 year ago

When you run the task by hand you get the following error message:

Execute scheduled task: Course size (report_coursesize\task\report_async) ... started 16:46:19. Current memory use 13.9 MB. Generating report_coursesize cache... ... used 7 dbqueries ... used 0.15534400939941 seconds Scheduled task failed: Course size (report_coursesize\task\report_async),Undefined constant "REPORT_COURSESIZE_NUMBEROFUSERS"

The locallib.php references this constant but only index.php has something which defines it if it's missing. Changing the following the the async task sorts the issue:

Change

public function execute() {
    global $DB, $CFG;

    require_once($CFG->dirroot . '/report/coursesize/locallib.php');

to

public function execute() {
    global $DB, $CFG;

    // How many users should we show in the User list.
    if (!defined('REPORT_COURSESIZE_NUMBEROFUSERS')) {
        define('REPORT_COURSESIZE_NUMBEROFUSERS', 10);
    }

    require_once($CFG->dirroot . '/report/coursesize/locallib.php');`
danmarsden commented 1 year ago

what version of the code are you using? - we dropped that constant in b1f3ade42d3878fd69cfb3e7a8a76c625f5bdaee

you probably just need to update to a newer version of the plugin?

turf212 commented 1 year ago

Site is 4.2 so hadn't "discovered" the latest version in the plugin repo. Will upgrade and check.

turf212 commented 1 year ago

Confirmed working OK with latest version on plugin DB!