Skip to content

Commit ca59c75

Browse files
committed
Ensure time is well formed.
1 parent 5b64704 commit ca59c75

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/wp-includes/collaboration/class-wp-collaboration-table-storage.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,14 @@ public function get_awareness_state( string $room, int $timeout = 30 ): array {
144144

145145
$entries = array();
146146
foreach ( $rows as $row ) {
147-
$decoded = json_decode( $row->data, true );
148-
if ( is_array( $decoded ) ) {
147+
$date_time = date_create_from_format( 'Y-m-d H:i:s', $row->date_gmt, new DateTimeZone( 'UTC' ) );
148+
$decoded_state = json_decode( $row->data, true );
149+
if ( is_array( $decoded_state ) && false !== $date_time ) {
149150
$entries[] = array(
150151
'client_id' => $row->client_id,
151-
'state' => $decoded,
152+
'state' => $decoded_state,
152153
'user_id' => (int) $row->user_id,
153-
'timestamp' => date_create_from_format( 'Y-m-d H:i:s', $row->date_gmt, new DateTimeZone( 'UTC' ) )->getTimestamp(),
154+
'timestamp' => $date_time->getTimestamp(),
154155
);
155156
}
156157
}

0 commit comments

Comments
 (0)