Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-48098

moodle_page class method set_url() outputs extraneous warning if passed url prefix doesn't match $CFG->httpswwwroot

XMLWordPrintable

    • MOODLE_26_STABLE, MOODLE_27_STABLE

      moodle_page class method set_url() outputs extraneous warning if passed url prefix doesn't match $CFG->httpswwwroot

      This is incorrect when site is just a standard http:// site BUT has $CFG->loginhttps enabled.

      Remote-Learners ELISAdmin block menu uses the moodle_page class to setup pages and links to them on the site which must be http:// links for most pages (except where page calls $PAGE->https_required(); as on /user/editadvanced.php ), but, on those loginhttps pages set_url() is incorrectly warning about all our http:// menu items ...
      i.e.

      Most probably incorrect set_page() url argument, it does not match the httpswwwroot!
       
          line 1190 of /lib/pagelib.php: call to debugging()
          line 61 of /local/eliscore/lib/page.class.php: call to moodle_page->set_url()
          line 304 of /local/.elisprogram/usersetpage.class.php: call to elis_page->__construct()
          line 345 of /local/.elisprogram/lib/menuitem.class.php: call to usersetpage->__construct()
          line 79 of /blocks/.elisadmin/lib.php: call to menuitempage->menuitempage()
          line 159 of /blocks/.elisadmin/block_elisadmin.php: call to block_elisadmin_get_menu_item()
          line 296 of /blocks/moodleblock.class.php: call to block_elisadmin->get_content()
          line 238 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
          line 956 of /lib/blocklib.php: call to block_base->get_content_for_output()
          line 1008 of /lib/blocklib.php: call to block_manager->create_block_contents()
          line 353 of /lib/blocklib.php: call to block_manager->ensure_content_created()
          line 43 of /theme/rlmaster/layout/general.php: call to block_manager->region_has_content()
          line 870 of /lib/outputrenderers.php: call to include()
          line 800 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
          line 279 of /user/editadvanced.php: call to core_renderer->header()
      

      The test in moodle_page::set_url() should include tests for either $PAGE or $page->_https_login_required
      e.g. (code diff below based on Moodle 2.6.5 version)

      diff --git a/lib/pagelib.php b/lib/pagelib.php
      index 8d6ad6e..c5cd347 100644
      --- a/lib/pagelib.php
      +++ b/lib/pagelib.php
      @@ -1175,7 +1175,7 @@ class moodle_page {
            * @throws coding_exception
            */
           public function set_url($url, array $params = null) {
      -        global $CFG;
      +        global $CFG, $PAGE;
       
               if (is_string($url) && strpos($url, 'http') !== 0) {
                   if (strpos($url, '/') === 0) {
      @@ -1189,7 +1189,7 @@ class moodle_page {
               $this->_url = new moodle_url($url, $params);
       
               $fullurl = $this->_url->out_omit_querystring();
      -        if (strpos($fullurl, "$CFG->httpswwwroot/") !== 0) {
      +        if ((!$this->_https_login_required || $this == $PAGE) && 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);
      

            Unassigned Unassigned
            brentboghosian Brent Boghosian
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.