Contents

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 #

A post lock stored as a presence rowWhen core writes _edit_lock with update_post_meta, a filter writes the post room's _lock row and skips the meta write. When core reads the lock with get_post_meta, a filter rebuilds the time and user string from the row.wp_presenceMeta filtersCorewp_presenceMeta filtersCoreupdate_post_meta( _edit_lock, "time:user" )Write _lock in postType/{type}:{id}Meta write skippedget_post_meta( _edit_lock )Read _lock"time:user"

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.

Edit this page on GitHub