diff --git a/mod/lti/locallib.php b/mod/lti/locallib.php index 7668e676631..b0e05eba707 100644 --- a/mod/lti/locallib.php +++ b/mod/lti/locallib.php @@ -4392,6 +4392,13 @@ function lti_load_cartridge($url, $map, $propertiesmap = array()) { $curl = new curl(); $response = $curl->get($url); + // Got a completely empty response (real or error), cannot process this with + // DOMDocument::loadXML() because it errors with ValueError. So let's throw + // the moodle_exception before waiting to examine the errors later. + if (trim($response) === '') { + throw new moodle_exception('errorreadingfile', '', '', $url); + } + // TODO MDL-46023 Replace this code with a call to the new library. $origerrors = libxml_use_internal_errors(true); $origentity = lti_libxml_disable_entity_loader(true);