]> git.mjollnir.org Git - moodle.git/commitdiff
NOBUG: Fixed bug in $PAGE->set_url() when moodle_url passed
authormudrd8mz <mudrd8mz>
Sat, 5 Sep 2009 17:32:10 +0000 (17:32 +0000)
committermudrd8mz <mudrd8mz>
Sat, 5 Sep 2009 17:32:10 +0000 (17:32 +0000)
When moodle_url was passed as a param to set_url(), the str_replace() kept
the leading '/' in the $shorturl. This then led to the <body> classes
like '-mod-workshop' instead of correct 'mod-workshop' (the slash
replaced with minus sign).

lib/pagelib.php

index 0b6e9ccef65f1174d528fa2eb947552120508ca5..ea0824474d652752761bed07b285fdce9c73e044 100644 (file)
@@ -783,7 +783,7 @@ 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));
+            $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().');