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

cfile://// url make the course inaccessible.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 3.10.8
    • Resource
    • None
    • MOODLE_310_STABLE

          1. Problem

      I have found an inaccessible course due to a mod/url that had the form:

      cfile:///C:/Users/[...]

      and produced this stack trace:

      Exception found: L'URL no és vàlid

      • line 565 of /mod/url/locallib.php: call to moodle_url->__construct()
      • line 223 of /mod/url/lib.php: call to url_guess_icon()
        [...]

      in Moodle 3.10.

      Maybe it was accepted in Moodle 3.8 or before and upgrading to Moodle 3.10 made this course inaccessible. It was an old course, from 3 years ago.

          1. Context

      The code that produces this exception and breaks the course, is just to calculate which icon to show beside the URL. So, it is not a critical point.

          1. Proposal

      Make this piece of code behave as "best effort".

      In Moodle 3.10, the function locallib.php::url_guess_icon($fullurl, $size = null)

      the breaking part is:

      $moodleurl = new moodle_url($fullurl); //<--- breaking line
      $fullurl = $moodleurl->out_omit_querystring();
      $icon = file_extension_icon($fullurl, $size);
      $htmlicon = file_extension_icon('.htm', $size);
      $unknownicon = file_extension_icon('', $size);

      // We do not want to return those icon types, the module icon is more appropriate.
      if ($icon === $unknownicon || $icon === $htmlicon)

      { return null; }

      return $icon;
      }

      //// end of piece of code

      I propose to catch the exception and make sure the site works properly always and use the module icon instead.

      Like:

      try { r$moodleurl = new moodle_url($fullurl); } catch(moodle_exception $e) { return null; }

      $fullurl = $moodleurl->out_omit_querystring();
      [...]

            Unassigned Unassigned
            jpahullo Jordi Pujol-Ahulló
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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