Can't get scheduled tasks to work in plugin.

Can't get scheduled tasks to work in plugin.

על ידי Tom Smith בתאריך
מספר תגובות: 5

I'm developing a plugin that automatically imports gradebook from CSV-file in server.

I have following files on my plugin directory (local/flagimport/):

version.php
settings.php
db/tasks.php
classes/task/import_gradebook.php

I have tried incrementing version number and reinstalling plugin but it doesn't add my scheduled task anywhere and task doesn't run.

What am I doing wrong?

ממוצע דרוגים: -
בתגובה ל: Tom Smith

Re: Can't get scheduled tasks to work in plugin.

על ידי Tom Smith בתאריך

Contents of my plugins files:

Content of import_gradebook.php: pastebin.com/ppAEtr5m

Content of tasks.php: pastebin.com/3NPsDBry 

Content of version.php: pastebin.com/ZADkTsvC 

Content of settings.php: pastebin.com/iJRc9bkB 

בתגובה ל: Tom Smith

Re: Can't get scheduled tasks to work in plugin.

על ידי Adrian Lorenc בתאריך

Hi

I think it is bug in Moodle, scheduled tasks implemented in local plugins are not performed by cron job

core\plugininfo\local does not overwrite get_enabled_plugins method, it returns NULL for all local plugins

get_next_scheduled_task method checks if plugin is enabled, 

                if ($plugininfo) {
                    if (!$task->get_run_if_component_disabled() && !$plugininfo->is_enabled()) {
                        $lock->release();
                        continue;
                    }
                }

is_enabled() returns NULL for all local plugins so task is not performed


בתגובה ל: Adrian Lorenc

Re: Can't get scheduled tasks to work in plugin.

על ידי Sam Chaffee בתאריך
תמונה של Core developers

You're right, Adrian - it was fixed in 2.8.1 with MDL-48156. If you're not on a Moodle version >= 2.8.1 it looks like it would be pretty safe to backport.

בתגובה ל: Sam Chaffee

Re: Can't get scheduled tasks to work in plugin.

על ידי Paul Holden בתאריך
תמונה של Core developers תמונה של Moodle HQ תמונה של Moodle Workplace team תמונה של Particularly helpful Moodlers תמונה של Peer reviewers תמונה של Plugin developers תמונה של Testers

The bug you've linked to only affected 2.8 so you wouldn't need to backport anything to a version prior to that - I can confirm scheduled tasks from local plugins are working fine in the 2.7 branch as we're using that here מאשר