-
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
fd15f6e
6ec2d84
c13f1cd
c993c0f
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 |
|---|---|---|
|
|
@@ -186,6 +186,14 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) { | |
| KEY post_parent (post_parent), | ||
| KEY post_author (post_author), | ||
| KEY type_status_author (post_type,post_status,post_author) | ||
| ) $charset_collate; | ||
| CREATE TABLE $wpdb->sync_updates ( | ||
| id bigint(20) unsigned NOT NULL auto_increment, | ||
| room_hash char(32) NOT NULL, | ||
| update_value longtext NOT NULL, | ||
| created_at datetime NOT NULL default '0000-00-00 00:00:00', | ||
|
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. Do you think
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. This is for cleanup but the code wasn't in the PR at the time of this comment. Here we go! c993c0f |
||
| PRIMARY KEY (id), | ||
| KEY room_hash (room_hash,id) | ||
| ) $charset_collate;\n"; | ||
|
|
||
| // Single site users table. The multisite flavor of the users table is handled below. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,3 +22,34 @@ function wp_collaboration_inject_setting() { | |
| ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Deletes sync updates older than 1 day 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() { | ||
| global $wpdb; | ||
|
|
||
| /** | ||
| * Filters the lifetime, in seconds, of a sync update row. | ||
| * | ||
| * By default, the lifetime is 1 day. Once a row reaches that age, it will | ||
| * automatically be deleted by a cron job. | ||
| * | ||
| * @since 7.0.0 | ||
| * | ||
| * @param int $expiration The expiration age of a sync update row, in seconds. | ||
| */ | ||
| $expiration = apply_filters( 'wp_sync_updates_expiration', DAY_IN_SECONDS ); | ||
|
|
||
| $wpdb->query( | ||
| $wpdb->prepare( | ||
| "DELETE FROM {$wpdb->sync_updates} WHERE created_at < %s", | ||
|
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. What if a post is being edited continuously for 2 days? Would this result in the row being deleted prematurely? What would happen in that case? (TBH, I'm not clear on all the specifics of how this works.) |
||
| gmdate( 'Y-m-d H:i:s', time() - $expiration ) | ||
| ) | ||
| ); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could come up with an understandable name for a room and not hash it. Or maybe we could reference the post ID and avoid a name/hash entirely?