mdjnelson / moodle-mod_customcert

Enables the creation of dynamically generated certificates with complete customisation via the web browser.
https://moodle.org/plugins/mod_customcert
GNU General Public License v3.0
90 stars 158 forks source link

Coding problem: unsupported modification of PAGE->context from 70 to 70 ++ #501

Closed ewallah closed 1 year ago

ewallah commented 2 years ago

Using the global $PAGE in a scheduled task only works when you execute the task inside the browser. During cron, there is no $PAGE available.

Execute scheduled task: mod_customcert\task\email_certificate_task ... started 05:21:02. Current memory use 29MB. ++ Coding problem: unsupported modification of PAGE->context from 70 to 70 ++

TopSolid commented 1 year ago

I have the same problem here, any news on this bug?

ewallah commented 1 year ago

A possible solution can be to use a $page variable instead of the global $PAGE see

This way you avoid using the global $PAGE, as there is no global $PAGE available during cron, the function runs in the background without user interface.

TopSolid commented 1 year ago

A possible solution can be to use a $page variable instead of the global $PAGE see

This way you avoid using the global $PAGE, as there is no global $PAGE available during cron, the function runs in the background without user interface. Thank you @ewallah, it worked on my instance!

mdjnelson commented 1 year ago

Closing as a duplicate of #443. @ewallah are you able to create a pull request to fix this?

wjroes commented 8 months ago

The error is " Coding problem: unsupported modification of PAGE->context from 70 to 70" and the problem is trying to change the context on the global $PAGE variable, but since it tries to change to the same value why don't you just leave that statement $PAGE->set_context($context); out?