Skip to content

Commit

Permalink
MDL-77156 enrol_self: deprecated trim() of null in PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Feb 10, 2023
1 parent 1ea152c commit d19685b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion enrol/self/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ protected function email_welcome_message($instance, $user) {
$a->coursename = format_string($course->fullname, true, array('context'=>$context));
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id";

if (trim($instance->customtext1) !== '') {
if (!is_null($instance->customtext1) && trim($instance->customtext1) !== '') {
$message = $instance->customtext1;
$key = array('{$a->coursename}', '{$a->profileurl}', '{$a->fullname}', '{$a->email}');
$value = array($a->coursename, $a->profileurl, fullname($user), $user->email);
Expand Down
16 changes: 16 additions & 0 deletions enrol/self/tests/behat/self_enrolment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,19 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe
And I navigate to "Unenrol me from C1" in current page administration
And I click on "Continue" "button" in the "Confirm" "dialogue"
Then I should see "You are unenrolled from the course \"Course 1\""

@javascript
Scenario: Self-enrolment enabled with simultaneous guest access
Given I log in as "teacher1"
And I am on the "Course 1" "enrolment methods" page
And I click on "Enable" "link" in the "Self enrolment (Student)" "table_row"
And I click on "Edit" "link" in the "Guest access" "table_row"
And I set the following fields to these values:
| Allow guest access | Yes |
And I press "Save changes"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I navigate to "Enrol me in this course" in current page administration
And I click on "Enrol me" "button"
Then I should see "Topic 1"

0 comments on commit d19685b

Please sign in to comment.