Skip to content

Commit e4f34f8

Browse files
committed
Relocate deterministic ordering of transient.
1 parent 52e2414 commit e4f34f8

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/wp-includes/collaboration/class-wp-http-polling-sync-server.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,8 @@ private function process_awareness_update( string $room, int $client_id, ?array
365365
);
366366
}
367367

368-
wp_list_sort( $updated_awareness, 'client_id' );
369-
370-
// Compare old and new here to avoid function calls to set_transient/update_option.
371-
if ( wp_json_encode( $updated_awareness ) !== wp_json_encode( $existing_awareness ) ) {
372-
// Awareness has updated, trigger database/object cache update.
373-
$this->storage->set_awareness_state( $room, $updated_awareness );
374-
}
368+
// This action can fail, but it shouldn't fail the entire request.
369+
$this->storage->set_awareness_state( $room, $updated_awareness );
375370

376371
// Convert to client_id => state map for response.
377372
$response = array();

src/wp-includes/collaboration/class-wp-sync-post-meta-storage.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public function get_awareness_state( string $room ): array {
100100
return array();
101101
}
102102

103+
// Deterministic ordering of transient data.
104+
$awareness = wp_list_sort( $awareness, 'client_id' );
103105
return array_values( $awareness );
104106
}
105107

@@ -114,6 +116,8 @@ public function get_awareness_state( string $room ): array {
114116
*/
115117
public function set_awareness_state( string $room, array $awareness ): bool {
116118
$room_hash = md5( $room ); // Not used for cryptographic purposes.
119+
// Deterministic ordering of transient data.
120+
$awareness = wp_list_sort( $awareness, 'client_id' );
117121

118122
/*
119123
* Maintain transient for longer than awareness.

0 commit comments

Comments
 (0)