mirror of https://github.com/MISP/MISP
fix: [internal] Try to cleanup memory when fetching feed
parent
d2911274b5
commit
518b2faa94
|
@ -187,7 +187,7 @@ class CurlClient extends HttpSocketExtended
|
|||
// Share handle between requests to allow keep connection alive between requests
|
||||
$this->ch = curl_init();
|
||||
if (!$this->ch) {
|
||||
throw new \RuntimeException("Could not initialize cURL");
|
||||
throw new \RuntimeException("Could not initialize curl");
|
||||
}
|
||||
} else {
|
||||
// Reset options, so we can do another request
|
||||
|
@ -237,7 +237,7 @@ class CurlClient extends HttpSocketExtended
|
|||
};
|
||||
|
||||
if (!curl_setopt_array($this->ch, $options)) {
|
||||
throw new \RuntimeException('cURL error: Could not set options');
|
||||
throw new \RuntimeException('curl error: Could not set options');
|
||||
}
|
||||
|
||||
// Download the given URL, and return output
|
||||
|
@ -248,7 +248,7 @@ class CurlClient extends HttpSocketExtended
|
|||
if (!empty($errorMessage)) {
|
||||
$errorMessage = ": $errorMessage";
|
||||
}
|
||||
throw new SocketException('cURL error ' . curl_strerror(curl_errno($this->ch)) . $errorMessage);
|
||||
throw new SocketException('curl error ' . curl_strerror(curl_errno($this->ch)) . $errorMessage);
|
||||
}
|
||||
|
||||
$code = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
|
||||
|
|
|
@ -2062,6 +2062,7 @@ class Feed extends AppModel
|
|||
$contentType = $response->getHeader('content-type');
|
||||
if ($contentType === 'application/zip') {
|
||||
$zipFilePath = FileAccessTool::writeToTempFile($response->body);
|
||||
unset($response->body); // cleanup variable to reduce memory usage
|
||||
|
||||
try {
|
||||
$response->body = $this->unzipFirstFile($zipFilePath);
|
||||
|
@ -2198,7 +2199,7 @@ class Feed extends AppModel
|
|||
ZipArchive::ER_READ => 'read error',
|
||||
ZipArchive::ER_SEEK => 'seek error',
|
||||
];
|
||||
$message = isset($errorCodes[$result]) ? $errorCodes[$result] : 'error ' . $result;
|
||||
$message = $errorCodes[$result] ?? 'error ' . $result;
|
||||
throw new Exception("Remote server returns ZIP file, that cannot be open ($message)");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue