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

Version 404.1.2 adhoc task fails #222

Open
Syxton opened this issue Sep 28, 2024 · 10 comments
Open

Version 404.1.2 adhoc task fails #222

Syxton opened this issue Sep 28, 2024 · 10 comments
Assignees
Labels

Comments

@Syxton
Copy link

Syxton commented Sep 28, 2024

Describe the bug
Adhoc task failed: format_grid\task\update_displayed_images_adhoc,Call to undefined function format_grid\course_get_format()
Backtrace:

  • line 670 of /course/format/grid/classes/toolbox.php: call to format_grid\toolbox::update_the_displayed_images()
  • line 58 of /course/format/grid/classes/task/update_displayed_images_adhoc.php: call to format_grid\toolbox::update_displayed_images()
  • line 47 of /course/format/grid/classes/task/update_displayed_images_adhoc.php: call to format_grid\task\update_displayed_images_adhoc::do_update_displayed_images_task()
  • line 519 of /lib/classes/cron.php: call to format_grid\task\update_displayed_images_adhoc->execute()
  • line 348 of /lib/classes/cron.php: call to core\cron::run_inner_adhoc_task()
  • line 371 of /lib/classes/cron.php: call to core\cron::run_adhoc_task()
  • line 154 of /admin/cli/adhoc_task.php: call to core\cron::run_failed_adhoc_tasks()

To Reproduce
Steps to reproduce the behaviour:

  1. after install, ad hoc tasks start failing.

Versions (please complete the following information):

  • Moodle: 4.4
@gjb2048
Copy link
Collaborator

gjb2048 commented Sep 28, 2024

Strange given https://github.com/gjbarnard/moodle-format_grid/blob/main/classes/task/update_displayed_images_task.php#L47 - is your Moodle in maintenance mode to prevent changes to the course course format setting?

@gjb2048
Copy link
Collaborator

gjb2048 commented Sep 28, 2024

@Syxton And.... what version of the format please.

@gjb2048
Copy link
Collaborator

gjb2048 commented Sep 28, 2024

@gjb2048
Copy link
Collaborator

gjb2048 commented Sep 28, 2024

Humm... strange that it worked in testing though... odd.

@gjb2048
Copy link
Collaborator

gjb2048 commented Sep 28, 2024

@Syxton Having said about the backslash though, it's odd given the stack trace as https://github.com/gjbarnard/moodle-format_grid/blob/main/classes/task/update_displayed_images_adhoc.php#L58 should never happen in a non-grid format course because the adhoc task would not be scheduled for a course that isn't a grid one by https://github.com/gjbarnard/moodle-format_grid/blob/main/classes/task/update_displayed_images_task.php#L47.

@gjb2048
Copy link
Collaborator

gjb2048 commented Sep 28, 2024

Or perhaps I've not missed a backslash as everywhere else doesn't use one, even with a name space.

@gjb2048
Copy link
Collaborator

gjb2048 commented Sep 28, 2024

@Syxton How are you running cron exactly please?

@gjb2048
Copy link
Collaborator

gjb2048 commented Sep 28, 2024

@Syxton Okay, I've tried to replicate and cannot:

Execute adhoc task: format_grid\task\update_displayed_images_adhoc
Adhoc task id: 14
Adhoc task custom data: "2"
... started 17:32:40. Current memory use 58.1 MB.
Executing Grid update displayed images adhoc task on course id 2.
... used 84 dbqueries
... used 1.2127048969269 seconds
Adhoc task complete: format_grid\task\update_displayed_images_adhoc
Ran 1 adhoc tasks found at Sat, 28 Sep 2024 17:32:40 +0100
Cron run completed correctly

Running via UI cron.

@gjb2048
Copy link
Collaborator

gjb2048 commented Sep 28, 2024

Ah, okay, with cli cron:

Adhoc task failed: format_grid\task\update_displayed_images_adhoc,Call to undefined function format_grid\course_get_format()
Backtrace:
* line 670 of \course\format\grid\classes\toolbox.php: call to format_grid\toolbox::update_the_displayed_images()
* line 58 of \course\format\grid\classes\task\update_displayed_images_adhoc.php: call to format_grid\toolbox::update_displayed_images()
* line 47 of \course\format\grid\classes\task\update_displayed_images_adhoc.php: call to format_grid\task\update_displayed_images_adhoc::do_update_displayed_images_task
()
* line 519 of \lib\classes\cron.php: call to format_grid\task\update_displayed_images_adhoc->execute()
* line 302 of \lib\classes\cron.php: call to core\cron::run_inner_adhoc_task()
* line 128 of \lib\classes\cron.php: call to core\cron::run_adhoc_tasks()
* line 186 of \admin\cli\cron.php: call to core\cron::run_main_process()

Ran 1 adhoc tasks found at Sat, 28 Sep 2024 17:41:06 +0100

Therefore the UI cron loads with /course/format/lib.php that has 'course_get_format()' and the CLI version doesn't!

@gjb2048
Copy link
Collaborator

gjb2048 commented Sep 28, 2024

Okay, have a fix:

Execute adhoc task: format_grid\task\update_displayed_images_adhoc
Adhoc task id: 16
Adhoc task custom data: "2"
... started 17:53:36. Current memory use 52.4 MB.
Executing Grid update displayed images adhoc task on course id 2.
... used 86 dbqueries
... used 0.76198315620422 seconds
Adhoc task complete: format_grid\task\update_displayed_images_adhoc
Ran 1 adhoc tasks found at Sat, 28 Sep 2024 17:53:36 +0100

@gjb2048 gjb2048 changed the title latest release adhoc task fails Version 404.1.2 adhoc task fails Sep 28, 2024
gjb2048 added a commit that referenced this issue Sep 28, 2024
…ase as previous adhoc tasks could have failed!
gjb2048 added a commit that referenced this issue Sep 28, 2024
…ase as previous adhoc tasks could have failed!
gjb2048 added a commit that referenced this issue Sep 28, 2024
…ase as previous adhoc tasks could have failed!
gjb2048 added a commit that referenced this issue Sep 28, 2024
…ase as previous adhoc tasks could have failed!
gjb2048 added a commit that referenced this issue Sep 28, 2024
…ase as previous adhoc tasks could have failed!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants