Permalink
Browse files

MDL-27809 navigation: Reworked the caching within navigation and impr…

…oved the ordering of events in order to reduce the use of session without serious impact on serverload
  • Loading branch information...
1 parent 50d32a2 commit e26507b361969c3e1f1f3a42d9d4f7eb732c37bf Sam Hemelryk committed Jun 24, 2011
Showing with 424 additions and 327 deletions.
  1. +16 −12 course/switchrole.php
  2. +407 −310 lib/navigationlib.php
  3. +1 −5 lib/simpletest/testnavigationlib.php
View
@@ -33,9 +33,9 @@
require_once('../config.php');
require_once($CFG->dirroot.'/course/lib.php');
-$id = required_param('id', PARAM_INT);
-$switchrole = optional_param('switchrole',-1, PARAM_INT);
-$returnurlkey = optional_param('returnurl', false, PARAM_INT);
+$id = required_param('id', PARAM_INT);
+$switchrole = optional_param('switchrole',-1, PARAM_INT);
+$returnurl = optional_param('returnurl', false, PARAM_URL);
$PAGE->set_url('/course/switchrole.php', array('id'=>$id));
@@ -69,17 +69,21 @@
}
}
-$returnurl = false;
-if ($returnurlkey && !empty($SESSION->returnurl) && strpos($SESSION->returnurl, 'moodle_url')!==false) {
- $returnurl = @unserialize($SESSION->returnurl);
- if (!($returnurl instanceof moodle_url)) {
- $returnurl = false;
+// TODO: Using SESSION->returnurl is deprecated and should be removed in the future.
+// Till then this code remains to support any external applications calling this script.
+if (!empty($returnurl) && is_numeric($returnurl)) {
+ $returnurl = false;
+ if (!empty($SESSION->returnurl) && strpos($SESSION->returnurl, 'moodle_url')!==false) {
+ debugging('Code calling switchrole should be passing a URL as a param.', DEBUG_DEVELOPER);
+ $returnurl = @unserialize($SESSION->returnurl);
+ if (!($returnurl instanceof moodle_url)) {
+ $returnurl = false;
+ }
}
- unset($SESSION->returnurl);
}
-if ($returnurl===false) {
- $returnurl = new moodle_url('/course/view.php', array('id'=>$course->id));
+if ($returnurl === false) {
+ $returnurl = new moodle_url('/course/view.php', array('id' => $course->id));
}
-redirect($returnurl);
+redirect($returnurl);
Oops, something went wrong.

0 comments on commit e26507b

Please sign in to comment.