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; } }