]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-21210 hopefully fixed $PAGE->set_url() weirdness and added more diagnostics
authorPetr Skoda <skodak@moodle.org>
Tue, 29 Dec 2009 14:30:15 +0000 (14:30 +0000)
committerPetr Skoda <skodak@moodle.org>
Tue, 29 Dec 2009 14:30:15 +0000 (14:30 +0000)
lib/pagelib.php

index 6738ea2116c43b9f20113855c543fa9be8099d7e..0902a2fb2f46b0da118af7a9153b7719857dca51 100644 (file)
@@ -818,16 +818,28 @@ class moodle_page {
      */
     public function set_url($url, $params = array()) {
         global $CFG;
+
         if ($url instanceof moodle_url) {
-            $shorturl = str_replace($CFG->wwwroot . '/', '', $url->out(true));
-            $this->_url = clone($url);
             if (!empty($params)) {
                 throw new coding_exception('Cannot pass params together with moodle_url to moodle_page::set_url().');
             }
-        } else {
-            $shorturl = $url;
-            $this->_url = new moodle_url($CFG->wwwroot . '/' . $url, $params);
+            $this->_url = clone($url);
+
+        } else if (is_string($url)) {
+            if (strpos($url, 'http') === 0) {
+                $this->_url = new moodle_url($url, $params);
+            } else {
+                // we have to use httpswwwroot here, because of loginhttps pages
+                $this->_url = new moodle_url($CFG->httpswwwroot . '/' . $url, $params);
+            }
         }
+
+        $fullurl = $this->_url->out(true);
+        if (strpos($fullurl, "$CFG->httpswwwroot/") !== 0) {
+            debugging('Most probably incorrect set_page() url argument, it does not match the httpswwwroot!');
+        }
+        $shorturl = str_replace("$CFG->httpswwwroot/", '', $fullurl);
+
         if (is_null($this->_pagetype)) {
             $this->initialise_default_pagetype($shorturl);
         }