Skip to content

Commit

Permalink
MDL-73427 core: Remove $SESSION->fromurl
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron1729 committed Jan 5, 2022
1 parent 541d999 commit 776bfb1
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 44 deletions.
5 changes: 0 additions & 5 deletions lib/moodlelib.php
Expand Up @@ -2742,11 +2742,6 @@ function require_login($courseorid = null, $autologinguest = true, $cm = null, $
$SESSION->wantsurl = qualified_me();
}

$referer = get_local_referer(false);
if (!empty($referer)) {
$SESSION->fromurl = $referer;
}

// Give auth plugins an opportunity to authenticate or redirect to an external login page
$authsequence = get_enabled_auth_plugins(); // Auths, in sequence.
foreach($authsequence as $authname) {
Expand Down
7 changes: 1 addition & 6 deletions lib/setuplib.php
Expand Up @@ -588,12 +588,7 @@ function get_exception_info($ex) {
$moreinfourl = $errordoclink . 'error/' . $modulelink . '/' . $errorcode;

if (empty($link)) {
if (!empty($SESSION->fromurl)) {
$link = $SESSION->fromurl;
unset($SESSION->fromurl);
} else {
$link = $CFG->wwwroot .'/';
}
$link = get_local_referer(false) ?: ($CFG->wwwroot . '/');
}

// When printing an error the continue button should never link offsite.
Expand Down
26 changes: 0 additions & 26 deletions lib/tests/setuplib_test.php
Expand Up @@ -412,32 +412,6 @@ public function test_get_exception_info_link() {
$exception = new moodle_exception('none', 'error', $url);
$infos = $this->get_exception_info($exception);
$this->assertSame($CFG->wwwroot . '/', $infos->link);

// Internal link from fromurl.
$SESSION->fromurl = $url = $CFG->wwwroot . '/something/here?really=yes';
$exception = new moodle_exception('none');
$infos = $this->get_exception_info($exception);
$this->assertSame($url, $infos->link);

// Internal HTTPS link from fromurl.
$SESSION->fromurl = $url = $httpswwwroot . '/something/here?really=yes';
$exception = new moodle_exception('none');
$infos = $this->get_exception_info($exception);
$this->assertSame($url, $infos->link);

// External link from fromurl.
$SESSION->fromurl = 'http://moodle.org/something/here?really=yes';
$exception = new moodle_exception('none');
$infos = $this->get_exception_info($exception);
$this->assertSame($CFG->wwwroot . '/', $infos->link);

// External HTTPS link from fromurl.
$SESSION->fromurl = 'https://moodle.org/something/here?really=yes';
$exception = new moodle_exception('none');
$infos = $this->get_exception_info($exception);
$this->assertSame($CFG->wwwroot . '/', $infos->link);

$SESSION->fromurl = '';
}

/**
Expand Down
8 changes: 1 addition & 7 deletions mod/forum/post.php
Expand Up @@ -160,8 +160,6 @@
);
}

$SESSION->fromurl = get_local_referer(false);

// Load up the $post variable.

$post = new stdClass();
Expand Down Expand Up @@ -786,11 +784,7 @@
}
} else if ($mformpost->is_submitted() && !$mformpost->no_submit_button_pressed() && $fromform = $mformpost->get_data()) {

if (empty($SESSION->fromurl)) {
$errordestination = $urlfactory->get_forum_view_url_from_forum($forumentity);
} else {
$errordestination = $SESSION->fromurl;
}
$errordestination = get_local_referer(false) ?: $urlfactory->get_forum_view_url_from_forum($forumentity);

$fromform->itemid = $fromform->message['itemid'];
$fromform->messageformat = $fromform->message['format'];
Expand Down

0 comments on commit 776bfb1

Please sign in to comment.