Post locks
When you open a post someone else is editing, WordPress warns you that it is locked. Presence API keeps that lock in its own table instead of with the post, so renewing it while you edit does not slow down the rest of the site.
How it works #
update_post_metadata,get_post_metadataanddelete_post_metadatafilters write, read and remove the row, sowp_check_post_lock()and other callers work unchanged.- It applies to every post type, including ones without presence support.
- The row expires after
wp_check_post_lock_window, 150 seconds by default, as the meta lock would. _lockis reserved, so it is written even with recording off, kept at logout, and left out of reads.- With the Post locks switch off, locks stay in post meta, as in core.
Moving locks out of post meta stops each lock refresh from bumping the posts last_changed value. On a synthetic large site with a Redis object cache, #836 measured the post query cache miss rate at about 10% with locks in post meta and about 5% with locks in wp_presence.
Source: post-lock-bridge.php
Check your understanding #
Recording is switched off. Do post locks still work?
Yes. _lock is reserved, and reserved rows are written even with recording off.