From 533a2964535bcae48eb30ded2edaa6dd6d2c321b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 29 Jan 2019 09:20:55 +0100 Subject: [locationinfo] Suppress XML parsing error spam The SimpleXML constructor is quite verbose if you pass it e.g. an HTML error page instead of the expected XML. Suppress those errors, we'll do our own (more concise) logging in the exception handler. --- modules-available/locationinfo/inc/coursebackend.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules-available/locationinfo/inc') diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php index 1da0086a..dcd92f6f 100644 --- a/modules-available/locationinfo/inc/coursebackend.inc.php +++ b/modules-available/locationinfo/inc/coursebackend.inc.php @@ -334,7 +334,7 @@ abstract class CourseBackend { $cleanresponse = preg_replace('/(<\/?)(\w+):([^>]*>)/', '$1$2$3', $response); try { - $xml = new SimpleXMLElement($cleanresponse); + $xml = @new SimpleXMLElement($cleanresponse); // This spams before throwing exception } catch (Exception $e) { $this->error = 'Could not parse reply as XML, got ' . get_class($e) . ': ' . $e->getMessage(); if (CONFIG_DEBUG) { -- cgit v1.2.3-55-g7522 From f538335087e18ad5950eee0ec1c9654fff5addc5 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 29 Jan 2019 09:22:28 +0100 Subject: [locationinfo] HisInOne: Properly handle multiple plannedDates If a course has been running for several semesters, older plannedDate entries tend to have no individualDate entries. Ignore those and don't error_log about it. --- .../locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules-available/locationinfo/inc') diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php index 22b1d8fb..c71623b3 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php @@ -271,6 +271,7 @@ class CourseBackend_HisInOne extends CourseBackend $eventDetails = array_merge($eventDetails, $event); } $name = false; + $now = time(); foreach ($eventDetails as $event) { foreach (array('/hisdefaulttext', '/hisshorttext', @@ -293,6 +294,12 @@ class CourseBackend_HisInOne extends CourseBackend foreach ($planElements as $planElement) { if (empty($planElement['hisplannedDates'])) continue; + $checkDate = $this->getArrayPath($planElement, '/hisplannedDates/hisplannedDate/hisenddate'); + if (!empty($checkDate) && strtotime($checkDate[0]) + 86400 < $now) + continue; // Course ended + $checkDate = $this->getArrayPath($planElement, '/hisplannedDates/hisplannedDate/hisstartdate'); + if (!empty($checkDate) && strtotime($checkDate[0]) - 86400 > $now) + continue; // Course didn't start yet $unitPlannedDates = $this->getArrayPath($planElement, '/hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate'); if ($unitPlannedDates === false) { -- cgit v1.2.3-55-g7522