Skip to content

Commit

Permalink
MDL-79370 user: set profile page URL earlier, avoid subsequent error.
Browse files Browse the repository at this point in the history
Co-authored-by: Dominique Palumbo <[email protected]>
  • Loading branch information
paulholden and Dominique Palumbo committed Sep 18, 2023
1 parent 88f4aaf commit cff812f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions user/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
$edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and off.
$reset = optional_param('reset', null, PARAM_BOOL);

// Even if the user didn't supply a userid, we treat page URL as if they did; this is needed so navigation works correctly.
$userid = $userid ?: $USER->id;
$PAGE->set_url('/user/profile.php', ['id' => $userid]);

if (!empty($CFG->forceloginforprofiles)) {
require_login();
if (isguestuser()) {
Expand All @@ -57,12 +61,6 @@
require_login();
}

$userid = $userid ? $userid : $USER->id; // Owner of the page.

// Even if the user didn't supply a userid, we treat page URL as if they did; this is needed
// so navigation works correctly.
$PAGE->set_url('/user/profile.php', ['id' => $userid]);

if ((!$user = $DB->get_record('user', array('id' => $userid))) || ($user->deleted)) {
$PAGE->set_context(context_system::instance());
echo $OUTPUT->header();
Expand Down

0 comments on commit cff812f

Please sign in to comment.