From 80303b6b6a527eb4fa88cd58462bc5d327b10d1d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 25 Jul 2017 18:59:44 +0200 Subject: [locationinfo] Better error handling in hisinone backend --- .../locationinfo/inc/coursebackend.inc.php | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'modules-available/locationinfo/inc/coursebackend.inc.php') diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php index b47fc2c6..1fe87202 100644 --- a/modules-available/locationinfo/inc/coursebackend.inc.php +++ b/modules-available/locationinfo/inc/coursebackend.inc.php @@ -179,9 +179,7 @@ abstract class CourseBackend $remoteIds[$row['locationid']] = $row['serverlocationid']; } } - error_log('Fetching ' . $this->serverId); $backendResponse = $this->fetchSchedulesInternal($remoteIds); - error_log('Reply: ' . print_r($backendResponse, true)); if ($backendResponse === false) { return false; } @@ -250,6 +248,19 @@ abstract class CourseBackend // Convert 'path/syntax/foo/wanteditem' to array for further processing and recursive calls $path = explode('/', $path); } + if (isset($array[0])) { + // The currently handled element of the path exists multiple times on the current level, so it is + // wrapped in a plain array - recurse into each one of them and merge the results + $return = []; + foreach ($array as $item) { + $test = $this->getArrayPath($item, $path); + If (is_array($test)) { + $return = array_merge($return, $test); + } + + } + return $return; + } do { // Get next element from array, loop to ignore empty elements (so double slashes in the path are allowed) $element = array_shift($path); @@ -276,20 +287,7 @@ abstract class CourseBackend // children - error return false; } - if (isset($array[$element][0])) { - // The currently handled element of the path exists multiple times on the current level, so it is - // wrapped in a plain array - recurse into each one of them and merge the results - $return = []; - foreach ($array[$element] as $item) { - $test = $this->getArrayPath($item, $path); - If (gettype($test) == "array") { - $return = array_merge($return, $test); - } - - } - return $return; - } - // Unique non-leaf node - simple recursion + // Non-leaf node - simple recursion return $this->getArrayPath($array[$element], $path); } -- cgit v1.2.3-55-g7522