File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 113113 wp_schedule_event ( time (), 'daily ' , 'delete_expired_transients ' );
114114}
115115
116+ // Schedule sync updates cleanup.
117+ if ( ! wp_next_scheduled ( 'wp_delete_old_sync_updates ' ) && ! wp_installing () ) {
118+ wp_schedule_event ( time (), 'daily ' , 'wp_delete_old_sync_updates ' );
119+ }
120+
116121set_screen_options ();
117122
118123$ date_format = __ ( 'F j, Y ' );
Original file line number Diff line number Diff line change @@ -22,3 +22,34 @@ function wp_collaboration_inject_setting() {
2222 );
2323 }
2424}
25+
26+ /**
27+ * Deletes sync updates older than 1 day from the wp_sync_updates table.
28+ *
29+ * Rows left behind by abandoned collaborative editing sessions are cleaned up
30+ * to prevent unbounded table growth.
31+ *
32+ * @since 7.0.0
33+ */
34+ function wp_delete_old_sync_updates () {
35+ global $ wpdb ;
36+
37+ /**
38+ * Filters the lifetime, in seconds, of a sync update row.
39+ *
40+ * By default, the lifetime is 1 day. Once a row reaches that age, it will
41+ * automatically be deleted by a cron job.
42+ *
43+ * @since 7.0.0
44+ *
45+ * @param int $expiration The expiration age of a sync update row, in seconds.
46+ */
47+ $ expiration = apply_filters ( 'wp_sync_updates_expiration ' , DAY_IN_SECONDS );
48+
49+ $ wpdb ->query (
50+ $ wpdb ->prepare (
51+ "DELETE FROM {$ wpdb ->sync_updates } WHERE created_at < %s " ,
52+ gmdate ( 'Y-m-d H:i:s ' , time () - $ expiration )
53+ )
54+ );
55+ }
Original file line number Diff line number Diff line change 454454add_action ( 'importer_scheduled_cleanup ' , 'wp_delete_attachment ' );
455455add_action ( 'upgrader_scheduled_cleanup ' , 'wp_delete_attachment ' );
456456add_action ( 'delete_expired_transients ' , 'delete_expired_transients ' );
457+ add_action ( 'wp_delete_old_sync_updates ' , 'wp_delete_old_sync_updates ' );
457458
458459// Navigation menu actions.
459460add_action ( 'delete_post ' , '_wp_delete_post_menu_item ' );
You can’t perform that action at this time.
0 commit comments