Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions classes/collabora.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ private function get_discovery_xml() {
$url = rtrim($baseurl, '/').'/hosting/discovery';
$curl = new \curl();
$xml = $curl->get($url);
if ($curl->get_errno()) {
// $xml possibly contains some error message, which isn't a valid xml.
return ''; // TODO: throw exception to avoid causing secondary errors.
}

$cache->set($baseurl, $xml);
}
return $xml;
Expand All @@ -299,8 +304,12 @@ private function get_discovery_xml() {
* @return string
*/
private function get_url_from_mimetype($discoveryxml, $mimetype) {
$xml = new \SimpleXMLElement($discoveryxml);
$app = $xml->xpath("//app[@name='{$mimetype}']");
$app = null;
if ($discoveryxml) {
$xml = new \SimpleXMLElement($discoveryxml);
$app = $xml->xpath("//app[@name='{$mimetype}']");
}

if (!$app) {
throw new \moodle_exception('unsupportedtype', 'mod_collabora', '', $mimetype);
}
Expand Down