-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Replace post meta sync storage with dedicated sync_updates table
#11068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
317a26e
1bbfc48
bd80f59
5fbf56e
a78fcea
9535e36
547bc5a
df7b21e
8ed3dd2
42ddcf8
fea5739
f7d5118
4ba33c4
ad6d6ac
c67550b
fc1a56c
255cde9
51cd57d
3296d5d
c920b97
8d780c2
ceccbb4
8b71153
d1f8026
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,21 @@ | |
| * @since 7.0.0 | ||
| */ | ||
|
|
||
| /** | ||
| * Checks whether real-time collaboration is enabled. | ||
| * | ||
| * The feature requires both the site option and the database schema | ||
| * introduced in db_version 61698. | ||
| * | ||
| * @since 7.0.0 | ||
| * | ||
| * @return bool True if collaboration is enabled, false otherwise. | ||
| */ | ||
| function wp_is_collaboration_enabled() { | ||
| return get_option( 'wp_enable_real_time_collaboration' ) | ||
| && get_option( 'db_version' ) >= 61698; | ||
| } | ||
|
|
||
| /** | ||
| * Injects the real-time collaboration setting into a global variable. | ||
| * | ||
|
|
@@ -14,11 +29,34 @@ | |
| * @access private | ||
| */ | ||
| function wp_collaboration_inject_setting() { | ||
| if ( get_option( 'wp_enable_real_time_collaboration' ) ) { | ||
| if ( wp_is_collaboration_enabled() ) { | ||
| wp_add_inline_script( | ||
| 'wp-core-data', | ||
| 'window._wpCollaborationEnabled = true;', | ||
| 'after' | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Deletes sync updates older than 7 days from the wp_sync_updates table. | ||
| * | ||
| * Rows left behind by abandoned collaborative editing sessions are cleaned up | ||
| * to prevent unbounded table growth. | ||
| * | ||
| * @since 7.0.0 | ||
| */ | ||
| function wp_delete_old_sync_updates() { | ||
| if ( ! wp_is_collaboration_enabled() ) { | ||
| return; | ||
| } | ||
|
|
||
| global $wpdb; | ||
|
|
||
| $wpdb->query( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that this cleanup routine is running via cron, I wonder if it should be more resilient to large amounts of data removal - imagine in a scenario of 1,000 updates being removed in one query, we should perhaps batch process this in reasonable amounts or grab the correct data from a select query first.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would definitely be a concern in the case of deleting 1,000 posts or postmeta, given that actions are expected to run for each deletion. But a SQL There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we assume updates that are a week+ old are safe to delete? I asked Gemini this question and it said:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pkevan @westonruter Agreed - a single DELETE on the indexed @mindctrl The Gemini analysis assumes a client could hold a stale cursor across the 7-day window, but the cursor is in-memory and resets to 0 on every editor load - a returning user always starts fresh. The behavior here was modeled after |
||
| $wpdb->prepare( | ||
| "DELETE FROM {$wpdb->sync_updates} WHERE created_at < %s", | ||
josephfusco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| gmdate( 'Y-m-d H:i:s', time() - WEEK_IN_SECONDS ) | ||
| ) | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.