diff --git a/src/app/history/controllers/HistoryController.php b/src/app/history/controllers/HistoryController.php index 8172da6e5d46725767c94aa420f87761b1f3f728..e11f591c7e7203fbf51d92e40a2dbadf6b420599 100644 --- a/src/app/history/controllers/HistoryController.php +++ b/src/app/history/controllers/HistoryController.php @@ -552,7 +552,7 @@ class HistoryController if (!empty($content['errors'])) { return $response->withStatus(400)->withJson(['errors' => $content['errors']]); } - $content = $content['fileContent']; + $content = $content['fileContent'] ?? null; $format = 'zip'; $mimeType = 'application/zip'; @@ -568,7 +568,7 @@ class HistoryController if (empty($queryParams['mode']) || $queryParams['mode'] == 'base64') { return $response->withJson(['encodedProofDocument' => base64_encode($content), 'format' => $format]); } else { - $response->write($content); + $response->write($content ?? ''); $response = $response->withAddedHeader('Content-Disposition', "inline; filename=maarch_history_proof." . $format); return $response->withHeader('Content-Type', $mimeType); } @@ -581,6 +581,8 @@ class HistoryController $tmpPath = CoreConfigModel::getTmpPath(); $zipFilename = $tmpPath . 'archivedProof' . $GLOBALS['id'] . '_' . rand() . '.zip'; + if (empty($zipFilename)) + if ($zip->open($zipFilename, \ZipArchive::CREATE) === true) { foreach ($aArgs['documents'] as $document) { if(file_exists($document['path']) && filesize($document['path']) > 0) {