From 8b1883ac80da006df699c94ffcf56593f64898c1 Mon Sep 17 00:00:00 2001 From: Vara Date: Wed, 4 Dec 2024 15:36:14 +0530 Subject: [PATCH 1/3] Add created_at to the Events --- includes/Event.php | 10 +++++++++- includes/EventQueue/Queues/BatchQueue.php | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/includes/Event.php b/includes/Event.php index 082f492..502c988 100644 --- a/includes/Event.php +++ b/includes/Event.php @@ -49,6 +49,13 @@ class Event { */ public $time; + /** + * DateTime when the event occurred + * + * @var string + */ + public $created_at; + /** * Construct * @@ -60,7 +67,8 @@ public function __construct( $category = 'Admin', $key = '', $data = array() ) { global $title; // Event details - $this->time = time(); + $this->time = time(); // TODO: Remove this if not used anywhere + $this->created_at = current_time( 'mysql' ); $this->category = strtolower( $category ); $this->key = $key; $this->data = $data; diff --git a/includes/EventQueue/Queues/BatchQueue.php b/includes/EventQueue/Queues/BatchQueue.php index f27d690..b86e71e 100644 --- a/includes/EventQueue/Queues/BatchQueue.php +++ b/includes/EventQueue/Queues/BatchQueue.php @@ -74,7 +74,11 @@ public function pull( int $count ) { foreach ( $rawEvents as $rawEvent ) { if ( property_exists( $rawEvent, 'id' ) && property_exists( $rawEvent, 'event' ) ) { - $events[ $rawEvent->id ] = maybe_unserialize( $rawEvent->event ); + $eventData = maybe_unserialize( $rawEvent->event ); + if ( is_array( $eventData ) && property_exists( $rawEvent, 'created_at' ) ) { + $eventData['created_at'] = $rawEvent->created_at; + } + $events[ $rawEvent->id ] = $eventData; } } From ec6e826ae1ed0cb35fe0839830c3ec7f70c6e2ee Mon Sep 17 00:00:00 2001 From: Vara Date: Thu, 5 Dec 2024 14:24:22 +0530 Subject: [PATCH 2/3] Remove time from the events --- includes/Event.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/includes/Event.php b/includes/Event.php index 502c988..5855095 100644 --- a/includes/Event.php +++ b/includes/Event.php @@ -42,13 +42,6 @@ class Event { */ public $user; - /** - * Timestamp when the event occurred - * - * @var integer - */ - public $time; - /** * DateTime when the event occurred * @@ -67,7 +60,6 @@ public function __construct( $category = 'Admin', $key = '', $data = array() ) { global $title; // Event details - $this->time = time(); // TODO: Remove this if not used anywhere $this->created_at = current_time( 'mysql' ); $this->category = strtolower( $category ); $this->key = $key; From 01088a52c2d484dd1d76a590914adf478980b429 Mon Sep 17 00:00:00 2001 From: Vara Date: Thu, 5 Dec 2024 14:46:27 +0530 Subject: [PATCH 3/3] Use date() instead of current_time() as there is a loading issue --- includes/Event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Event.php b/includes/Event.php index 5855095..da0883e 100644 --- a/includes/Event.php +++ b/includes/Event.php @@ -60,7 +60,7 @@ public function __construct( $category = 'Admin', $key = '', $data = array() ) { global $title; // Event details - $this->created_at = current_time( 'mysql' ); + $this->created_at = date( 'Y-m-d H:i:s.u' ); $this->category = strtolower( $category ); $this->key = $key; $this->data = $data;