You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"SELECT client_id, user_id, date_gmt, data FROM {$wpdb->collaboration} WHERE room = %s AND type = 'awareness' AND date_gmt >= %s ORDER BY collaboration_id ASC",
@@ -151,12 +153,6 @@ public function get_awareness_state( string $room, int $timeout = 30 ): array {
@@ -228,38 +224,33 @@ public function get_updates_after_cursor( string $room, int $cursor ): array {
228
224
* separately via get_awareness_state().
229
225
*/
230
226
231
-
/* Snapshot the current max ID and total row count in a single query. */
227
+
// Snapshot the current max ID and total row count in a single query.
228
+
/** @var object{ max_id: int, total: int } $snapshot */
232
229
$snapshot = $wpdb->get_row(
233
230
$wpdb->prepare(
234
231
"SELECT COALESCE( MAX( collaboration_id ), 0 ) AS max_id, COUNT(*) AS total FROM {$wpdb->collaboration} WHERE room = %s AND type != 'awareness'",
235
232
$room
236
233
)
237
234
);
238
235
239
-
if ( ! $snapshot ) {
240
-
$this->room_cursors[ $room ] = 0;
241
-
$this->room_update_counts[ $room ] = 0;
242
-
returnarray();
243
-
}
244
-
245
236
$max_id = (int) $snapshot->max_id;
246
237
$total = (int) $snapshot->total;
247
238
248
239
$this->room_cursors[ $room ] = $max_id;
249
240
241
+
$this->room_update_counts[ $room ] = $total;
242
+
250
243
if ( 0 === $max_id || $max_id <= $cursor ) {
251
244
/*
252
245
* Preserve the real row count so the server can still
253
246
* trigger compaction when updates have accumulated but
254
247
* no new ones arrived since the client's last poll.
255
248
*/
256
-
$this->room_update_counts[ $room ] = $total;
257
249
returnarray();
258
250
}
259
251
260
-
$this->room_update_counts[ $room ] = $total;
261
-
262
-
/* Fetch updates after the cursor up to the snapshot boundary. */
252
+
// Fetch updates after the cursor up to the snapshot boundary.
253
+
/** @var array<object{ data: string }> $rows */
263
254
$rows = $wpdb->get_results(
264
255
$wpdb->prepare(
265
256
"SELECT data FROM {$wpdb->collaboration} WHERE room = %s AND type != 'awareness' AND collaboration_id > %d AND collaboration_id <= %d ORDER BY collaboration_id ASC",
@@ -269,10 +260,6 @@ public function get_updates_after_cursor( string $room, int $cursor ): array {
0 commit comments