From fb43e1e6a92044035cf9bdd4a4cc7511a96c9cc3 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Sun, 14 Jan 2024 18:19:10 +0100 Subject: [PATCH] fix: [internal] Access log errors from test --- app/Model/AccessLog.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Model/AccessLog.php b/app/Model/AccessLog.php index 55a7ae2f9..3c27ac3b7 100644 --- a/app/Model/AccessLog.php +++ b/app/Model/AccessLog.php @@ -71,12 +71,6 @@ class AccessLog extends AppModel { $accessLog = &$this->data['AccessLog']; - $this->externalLog($accessLog); - - if (Configure::read('MISP.log_paranoid_skip_db')) { - return; - } - // Truncate foreach (['request_id', 'user_agent', 'url'] as $field) { if (isset($accessLog[$field]) && strlen($accessLog[$field]) > 255) { @@ -214,6 +208,12 @@ class AccessLog extends AppModel $data['query_count'] = $queryCount; $data['duration'] = (int)((microtime(true) - $requestTime->format('U.u')) * 1000); // in milliseconds + $this->externalLog($data); + + if (Configure::read('MISP.log_paranoid_skip_db')) { + return true; // do not save access log to database + } + try { return $this->save($data, ['atomic' => false]); } catch (Exception $e) { @@ -226,7 +226,7 @@ class AccessLog extends AppModel * @param array $data * @return void */ - public function externalLog(array $data) + private function externalLog(array $data) { if ($this->pubToZmq('audit')) { $this->getPubSubTool()->publish($data, 'audit', 'log');