General developer forum

"Failed to load task" error for non-existent plugin

 
Picture of Diane Villemure
"Failed to load task" error for non-existent plugin
Core developers

When I turned on DEVELOPER DEBUG, I discovered that I kept getting the following errors:

line 66 of /lib/cronlib.php: call to core\\task\\manager::get_next_scheduled_task()
line 81 of /admin/cron.php: call to cron_run()
/lib/weblib.php on line 3145
Failed to load task: \\mod_certificate\\task\\auto_issue_certificates* line 309 of /lib/classes/task/manager.php: call to debugging()
line 544 of /lib/classes/task/manager.php: call to core\\task\\manager::scheduled_task_from_record()

I have not had a mod_certificate since version 2.7 in 2015. That plugin was uninstalled. I searched the config table, the config_log, config_plugin and there is no certificate plugin. But in config_log, there are the following entries:

plugin    name                            value

NULL    certificate_autocourse   0

NULL    certificate_recertify        0

NULL    feature_histcerts            0

NULL    locsendcert                   0

NULL    certificate_recertrem      none

NULL    certificate_autoissue      0

NULL    certificate_autoissue_roles         5

I changed the name of them to cort instead of cert but the errors continued.

More detail about the lines pointed to in the error log:

- line 66 of /lib/cronlib.php: call to core\\task\\manager::get_next_scheduled_task()

    // Run all scheduled tasks.
    while (!\core\task\manager::static_caches_cleared_since($timenow) &&
           $task = \core\task\manager::get_next_scheduled_task($timenow)) {
        cron_run_inner_scheduled_task($task);
        unset($task);
    }

- line 81 of /admin/cron.php: call to cron_run()

// execute the cron
cron_run();

- /lib/weblib.php on line 3145

          if (CLI_SCRIPT) {
                echo "++ $message ++\n$from";
            } else {
                echo '<div class="notifytiny debuggingmessage" data-rel="debugging">' , $message , $from , '</div>';
            }

        } else {
            trigger_error($message . $from, E_USER_NOTICE);      [[[ this is line 3145 ]]]
        }

- line 309 of /lib/classes/task/manager.php: call to debugging()

    public static function scheduled_task_from_record($record) {
        $classname = $record->classname;
        if (strpos($classname, '\\') !== 0) {
            $classname = '\\' . $classname;
        }
        if (!class_exists($classname)) {
            debugging("Failed to load task: " . $classname, DEBUG_DEVELOPER);  [[ this is line 309 ]]
            return false;
        }

I would appreciate suggestions about how to stop this "phantom" error.

 
Average of ratings: -
Davo
Re: "Failed to load task" error for non-existent plugin
Core developersParticularly helpful MoodlersPlugin developers

Hi Diane,

If you have access to the database, then take a look in the table mdl_task_scheduled. This table lists all the scheduled tasks that Moodle knows about.

You should be able to locate the record with classname='\mod_certificate\task\auto_issue_certificates' and then delete it.

(There is a possibility that you'd also need to purge site caches after that, but you probably won't need to do so).

Uninstalling plugins usually cleans up such tasks, but sometimes the clean-up goes wrong.


 
Average of ratings: -
Picture of Diane Villemure
Re: "Failed to load task" error for non-existent plugin
Core developers

Thank you VERY much Davo. That was the problem. There was two entries in the task_schedule table with mod_certificate as the component: \mod_certificate\task\certificate_cron  and  \mod_certificate\task\auto_issue_certificates. Once I deleted those, there were no more errors in DEVELOPER DEBUG on the server.

 
Average of ratings: -