Skip to content

Commit

Permalink
MDL-76362 core: Test coursealias before using
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jan 23, 2023
1 parent ddf0f08 commit de4de9c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/accesslib.php
Expand Up @@ -4519,15 +4519,15 @@ 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;
}
}

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;
Expand Down

0 comments on commit de4de9c

Please sign in to comment.