Skip to content

Commit 9a11c53

Browse files
ewallahmdjnelson
authored andcommitted
#443 Stop PHP notice caused by the email certificate task
1 parent 70218a8 commit 9a11c53

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

classes/task/email_certificate_task.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function get_name() {
4747
* Execute.
4848
*/
4949
public function execute() {
50-
global $DB, $PAGE;
50+
global $DB;
5151

5252
// Get all the certificates that have requested someone get emailed.
5353
$emailotherslengthsql = $DB->sql_length('c.emailothers');
@@ -66,8 +66,9 @@ public function execute() {
6666
}
6767

6868
// The renderers used for sending emails.
69-
$htmlrenderer = $PAGE->get_renderer('mod_customcert', 'email', 'htmlemail');
70-
$textrenderer = $PAGE->get_renderer('mod_customcert', 'email', 'textemail');
69+
$page = new \moodle_page();
70+
$htmlrenderer = $page->get_renderer('mod_customcert', 'email', 'htmlemail');
71+
$textrenderer = $page->get_renderer('mod_customcert', 'email', 'textemail');
7172
foreach ($customcerts as $customcert) {
7273
// Do not process an empty certificate.
7374
$sql = "SELECT ce.*
@@ -84,8 +85,8 @@ public function execute() {
8485
// Get the context.
8586
$context = \context::instance_by_id($customcert->contextid);
8687

87-
// Set the $PAGE context - this ensure settings, such as language, are kept and don't default to the site settings.
88-
$PAGE->set_context($context);
88+
// Set the $page context - this ensures settings, such as language, are kept and don't default to the site settings.
89+
$page->set_context($context);
8990

9091
// Get the person we are going to send this email on behalf of.
9192
$userfrom = \core_user::get_noreply_user();

0 commit comments

Comments
 (0)