From 06538f5fd51ac20d780d39f18a294136046ad22b Mon Sep 17 00:00:00 2001 From: Tatiana Glushchenko Date: Mon, 13 Oct 2025 20:40:51 +1300 Subject: [PATCH] mod_customcert: Fix deprecated utf8_encode() This function has been deprecated as of PHP 8.2.0. --- tests/email_certificate_task_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/email_certificate_task_test.php b/tests/email_certificate_task_test.php index cfa56c9f5..5a305e6ea 100644 --- a/tests/email_certificate_task_test.php +++ b/tests/email_certificate_task_test.php @@ -150,11 +150,11 @@ public function test_email_certificates_teachers() { // Confirm that we only sent out 2 emails, both emails to the teacher for the two students. $this->assertCount(2, $emails); - $this->assertStringContainsString(fullname($user3), utf8_encode($emails[0]->header)); + $this->assertStringContainsString(fullname($user3), mb_convert_encoding($emails[0]->header, 'UTF-8', 'ISO-8859-1')); $this->assertEquals($CFG->noreplyaddress, $emails[0]->from); $this->assertEquals($user3->email, $emails[0]->to); - $this->assertStringContainsString(fullname($user3), utf8_encode($emails[1]->header)); + $this->assertStringContainsString(fullname($user3), mb_convert_encoding($emails[1]->header, 'UTF-8', 'ISO-8859-1')); $this->assertEquals($CFG->noreplyaddress, $emails[1]->from); $this->assertEquals($user3->email, $emails[1]->to); } @@ -189,11 +189,11 @@ public function test_email_certificates_others() { // Confirm that we only sent out 2 emails, both emails to the other address that was valid for the two students. $this->assertCount(2, $emails); - $this->assertStringContainsString(fullname(get_admin()), utf8_encode($emails[0]->header)); + $this->assertStringContainsString(fullname(get_admin()), mb_convert_encoding($emails[0]->header, 'UTF-8', 'ISO-8859-1')); $this->assertEquals($CFG->noreplyaddress, $emails[0]->from); $this->assertEquals('testcustomcert@example.com', $emails[0]->to); - $this->assertStringContainsString(fullname(get_admin()), utf8_encode($emails[1]->header)); + $this->assertStringContainsString(fullname(get_admin()), mb_convert_encoding($emails[1]->header, 'UTF-8', 'ISO-8859-1')); $this->assertEquals($CFG->noreplyaddress, $emails[1]->from); $this->assertEquals('testcustomcert@example.com', $emails[1]->to); }