From: David Mudrak <david.mudrak@gmail.com>
Date: Thu, 7 Jan 2010 20:17:38 +0000 (+0000)
Subject: Fixed a typo in loginas.php + added a parameter control in moodle_url::set_url()... 
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c909711ac58677077656234f498b79b75bbdcf95;p=moodle.git

Fixed a typo in loginas.php + added a parameter control in moodle_url::set_url() to discover similar issues in the future
---

diff --git a/course/loginas.php b/course/loginas.php
index 8a0e7a977f..c642c510f9 100644
--- a/course/loginas.php
+++ b/course/loginas.php
@@ -31,7 +31,7 @@
     if ($id !== SITEID) {
         $url->param('id', $id);
     }
-    $PAGE->set_url($id);
+    $PAGE->set_url($url);
 
     if (!confirm_sesskey()) {
         print_error('confirmsesskeybad');
diff --git a/lib/pagelib.php b/lib/pagelib.php
index 0902a2fb2f..27b0a37aee 100644
--- a/lib/pagelib.php
+++ b/lib/pagelib.php
@@ -813,7 +813,7 @@ class moodle_page {
      * For example, course/view.php does:
      *      $id = optional_param('id', 0, PARAM_INT);
      *      $PAGE->set_url('course/view.php', array('id' => $id));
-     * @param mixed $url moodle_url|string URL relative to $CFG->wwwroot or {@link moodle_url} instance
+     * @param moodle_url|string $url URL relative to $CFG->wwwroot or {@link moodle_url} instance
      * @param array $params paramters to add to the URL (allowed only if $url is string)
      */
     public function set_url($url, $params = array()) {
@@ -832,6 +832,9 @@ class moodle_page {
                 // we have to use httpswwwroot here, because of loginhttps pages
                 $this->_url = new moodle_url($CFG->httpswwwroot . '/' . $url, $params);
             }
+
+        } else {
+            throw new coding_exception('Parameter $url must be either moodle_url or string, ' . gettype($url) . ' given instead.');
         }
 
         $fullurl = $this->_url->out(true);