From: Petr Skoda Date: Tue, 29 Dec 2009 14:30:15 +0000 (+0000) Subject: MDL-21210 hopefully fixed $PAGE->set_url() weirdness and added more diagnostics X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=42174e18fbecaef0cb96ae06641af43e759b9855;p=moodle.git MDL-21210 hopefully fixed $PAGE->set_url() weirdness and added more diagnostics --- diff --git a/lib/pagelib.php b/lib/pagelib.php index 6738ea2116..0902a2fb2f 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -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); }