From 71933aed6d7b9b131f906cbb5bb1452b7ab4acd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 24 Sep 2020 21:07:19 +0300 Subject: [PATCH 1/2] Cleanup getLastProfilingId from MongoSaver This no longer makes sense as profile savers from applications are in standalone library, so the value reuse here is impossible. --- src/Xhgui/Saver/MongoSaver.php | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/Xhgui/Saver/MongoSaver.php b/src/Xhgui/Saver/MongoSaver.php index 09d12791d..a1f9e62dd 100644 --- a/src/Xhgui/Saver/MongoSaver.php +++ b/src/Xhgui/Saver/MongoSaver.php @@ -42,24 +42,11 @@ public function save(array $data) ]; $a = [ - '_id' => $data['_id'] ?? self::getLastProfilingId(), + '_id' => $data['_id'] ?? new MongoId(), 'meta' => $meta, 'profile' => $data['profile'], ]; return $this->_collection->insert($a, ['w' => 0]); } - - /** - * Return profiling ID - * @return MongoId lastProfilingId - */ - public static function getLastProfilingId() - { - if (!self::$lastProfilingId) { - self::$lastProfilingId = new MongoId(); - } - - return self::$lastProfilingId; - } } From 94d0e02a210abe3af3f51e743da8d72f393eb62b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 24 Sep 2020 21:08:23 +0300 Subject: [PATCH 2/2] PdoSaver: Allow _id override for unit testing --- src/Xhgui/Saver/PdoSaver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xhgui/Saver/PdoSaver.php b/src/Xhgui/Saver/PdoSaver.php index afff29e89..bc32fe976 100644 --- a/src/Xhgui/Saver/PdoSaver.php +++ b/src/Xhgui/Saver/PdoSaver.php @@ -94,7 +94,7 @@ public function save(array $data) $usec = $ts['usec']; $this->stmt->execute([ - 'id' => Util::generateId(), + 'id' => $data['_id'] ?? Util::generateId(), 'profile' => json_encode($data['profile']), 'url' => $data['meta']['url'], 'SERVER' => json_encode($data['meta']['SERVER']),