summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc
diff options
context:
space:
mode:
authorSimon Rettberg2018-04-18 12:03:52 +0200
committerSimon Rettberg2018-04-18 12:03:52 +0200
commit1c18aa67abaf179602458909e50d983a44ee2dc7 (patch)
tree4f1745be78e642d6fbcda3107d40f852ba4ffd9f /modules-available/locationinfo/inc
parent[locationinfo] hisinone: Query relevant days only, not whole year/semester (diff)
downloadslx-admin-1c18aa67abaf179602458909e50d983a44ee2dc7.tar.gz
slx-admin-1c18aa67abaf179602458909e50d983a44ee2dc7.tar.xz
slx-admin-1c18aa67abaf179602458909e50d983a44ee2dc7.zip
[locationinfo] davinchi: Reuse curl handle
Diffstat (limited to 'modules-available/locationinfo/inc')
-rw-r--r--modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php22
1 files changed, 17 insertions, 5 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
index 8843e372..ed3d7ec2 100644
--- a/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_davinci.inc.php
@@ -6,6 +6,10 @@ class CourseBackend_Davinci extends CourseBackend
private $location;
private $verifyHostname = true;
private $verifyCert = true;
+ /**
+ * @var bool|resource
+ */
+ private $curlHandle = false;
public function setCredentialsInternal($data)
{
@@ -69,7 +73,9 @@ class CourseBackend_Davinci extends CourseBackend
{
$url = $this->location . "content=xml&type=room&name=" . urlencode($roomId)
. "&startdate=" . $startDate->format('d.m.Y') . "&enddate=" . $endDate->format('d.m.Y');
- $ch = curl_init();
+ if ($this->curlHandle === false) {
+ $this->curlHandle = curl_init();
+ }
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
@@ -78,16 +84,15 @@ class CourseBackend_Davinci extends CourseBackend
CURLOPT_URL => $url,
);
- curl_setopt_array($ch, $options);
- $output = curl_exec($ch);
+ curl_setopt_array($this->curlHandle, $options);
+ $output = curl_exec($this->curlHandle);
if ($output === false) {
- $this->error = 'Curl error: ' . curl_error($ch);
+ $this->error = 'Curl error: ' . curl_error($this->curlHandle);
return false;
} else {
$this->error = false;
///Operation completed successfully
}
- curl_close($ch);
return $output;
}
@@ -142,4 +147,11 @@ class CourseBackend_Davinci extends CourseBackend
}
return $schedules;
}
+
+ public function __destruct()
+ {
+ if ($this->curlHandle !== false) {
+ curl_close($this->curlHandle);
+ }
+ }
}