From eceb3c49fd9ad857febcef905eb44b771787c750 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 6 Jan 2023 22:29:49 +0800 Subject: [PATCH] MDL-76362 core: Test coursealias before using --- lib/accesslib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index 03253972aae..cdcddc81848 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -4560,7 +4560,7 @@ function role_get_name(stdClass $role, $context = null, $rolenamedisplay = ROLEN } if ($rolenamedisplay == ROLENAME_ALIAS) { - if ($coursecontext and trim($role->coursealias ?? '') !== '') { + if ($coursecontext && $role->coursealias && trim($role->coursealias) !== '') { return format_string($role->coursealias, true, array('context'=>$coursecontext)); } else { return $original; @@ -4568,7 +4568,7 @@ function role_get_name(stdClass $role, $context = null, $rolenamedisplay = ROLEN } if ($rolenamedisplay == ROLENAME_BOTH) { - if ($coursecontext and trim($role->coursealias ?? '') !== '') { + if ($coursecontext && $role->coursealias && trim($role->coursealias) !== '') { return format_string($role->coursealias, true, array('context'=>$coursecontext)) . " ($original)"; } else { return $original;