Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adhoc Task Failures in Moodle 3.9 version #18

Open
vithushau opened this issue May 1, 2024 · 0 comments
Open

Adhoc Task Failures in Moodle 3.9 version #18

vithushau opened this issue May 1, 2024 · 0 comments

Comments

@vithushau
Copy link

Description:

Adhoc tasks in the Moodle plugin block_mhaairs are encountering failures, likely due to compatibility issues and error handling.

Initial Error:

 Execute adhoc task: block_mhaairs\task\add_grade_category_task
 Adhoc task id: 1000
 Adhoc task custom data: {"catname":"quiz","courseid":"100","itemid":"1000"}
 ... started 07:02:20. Current memory use 2.8MB.
 Debugging increased temporarily due to faildelay of 86400
 ... used 0 dbqueries
 ... used 0.00012397766113281 seconds
 Adhoc task failed: block_mhaairs\task\add_grade_category_task,Class 'grade_category' not found
 Backtrace:
 line 367 of /lib/cronlib.php: call to block_mhaairs\task\add_grade_category_task->execute()
 line 198 of /lib/cronlib.php: call to cron_run_inner_adhoc_task()
 line 131 of /admin/cli/adhoc_task.php: call to cron_run_adhoc_tasks()

Version Affected: Moodle 3.9

Subsequent Error:


Execute adhoc task: block_mhaairs\task\add_grade_category_task
Adhoc task id: 1001
Adhoc task custom data: {"catname":"quiz","courseid":"100","itemid":"1000"}
... started 09:59:06. Current memory use 22MB.

Warning: Creating default object from empty value in /blocks/mhaairs/classes/task/add_grade_category_task.php on line 85
... used 2 dbqueries
... used 0.0055229663848877 seconds
Adhoc task failed: block_mhaairs\task\add_grade_category_task,Call to undefined method stdClass::update()
Backtrace:
* line 367 of /lib/cronlib.php: call to block_mhaairs\task\add_grade_category_task->execute()
* line 198 of /lib/cronlib.php: call to cron_run_inner_adhoc_task()
* line 131 of /admin/cli/adhoc_task.php: call to cron_run_adhoc_tasks()

Cause:

The initial error appears to stem from a compatibility issue between the plugin and Moodle version 3.9, where the 'grade_category' class is not found. The subsequent error suggests insufficient error handling within the adhoc task code.

Solution:

To address these issues, the following patches have been proposed and applied:

Compatibility patch to ensure support for Moodle 3.9 by handling the 'grade_category' class.

To improve error handling, we need to address situations where grade items are removed before adhoc tasks run. If a grade item is deleted after the task is created but before it's executed, it could cause issues. The code should handle this scenario by ensuring adhoc tasks aren't created if the associated grade item doesn't exist. This precaution prevents potential errors from occurring when tasks are executed in such cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant