-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
3.10.8
-
None
-
MOODLE_310_STABLE
-
-
- 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.
-
-
- 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.
-
-
- 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 $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();
[...]
- duplicates
-
MDL-73195 mod_url: Error makes course/view.php unreachable if an invalid URL is saved
-
- Closed
-