wp_ajax_wp_remove_post_lock()
- Since
- 3.1.0
- Source
wp-admin/includes/ajax-actions.php:2913
Compatibility
- WordPress
- since 3.1.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Performance profile
How much work a call to wp_ajax_wp_remove_post_lock() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Constant
- Instructions
- 61–73
- Plugin surface
- 1 hook
- Called by
- 0
Reaches the database via get_post().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 73.
Third-party callbacks on 'wp_check_post_lock_window' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- querycontent query
get_post()called directly - hookthird-party callbacks
apply_filters()called directly
Further down the call graph this can also reach serialize, cache, option and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 16 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_ajax_wp_remove_post_lock() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!empty($value) && current_user_can() | 61 | get_post(), check_ajax_referer(), current_user_can(), explode(), array_map(), get_current_user_id(), time(), apply_filters(), update_post_meta(), wp_die() |
empty($value) && current_user_can() | 61–64 | wp_die(), get_post(), check_ajax_referer(), current_user_can(), explode(), array_map(), get_current_user_id(), time(), apply_filters(), update_post_meta(), wp_die() |
!empty($value) && current_user_can() | 64 | get_post(), check_ajax_referer(), current_user_can(), explode(), array_map(), get_current_user_id(), wp_die(), time(), apply_filters(), update_post_meta(), wp_die() |
!empty($value) && !current_user_can() | 64 | get_post(), check_ajax_referer(), current_user_can(), wp_die(), explode(), array_map(), get_current_user_id(), time(), apply_filters(), update_post_meta(), wp_die() |
!empty($value) && current_user_can() | 64 | get_post(), wp_die(), check_ajax_referer(), current_user_can(), explode(), array_map(), get_current_user_id(), time(), apply_filters(), update_post_meta(), wp_die() |
empty($value) && current_user_can() | 64–67 | wp_die(), get_post(), check_ajax_referer(), current_user_can(), explode(), array_map(), get_current_user_id(), wp_die(), time(), apply_filters(), update_post_meta(), wp_die() |
empty($value) && !current_user_can() | 64–67 | wp_die(), get_post(), check_ajax_referer(), current_user_can(), wp_die(), explode(), array_map(), get_current_user_id(), time(), apply_filters(), update_post_meta(), wp_die() |
empty($value) && current_user_can() | 64–67 | wp_die(), get_post(), wp_die(), check_ajax_referer(), current_user_can(), explode(), array_map(), get_current_user_id(), time(), apply_filters(), update_post_meta(), wp_die() |
!empty($value) && !current_user_can() | 67 | get_post(), check_ajax_referer(), current_user_can(), wp_die(), explode(), array_map(), get_current_user_id(), wp_die(), time(), apply_filters(), update_post_meta(), wp_die() |
!empty($value) && current_user_can() | 67 | get_post(), wp_die(), check_ajax_referer(), current_user_can(), explode(), array_map(), get_current_user_id(), wp_die(), time(), apply_filters(), update_post_meta(), wp_die() |
!empty($value) && !current_user_can() | 67 | get_post(), wp_die(), check_ajax_referer(), current_user_can(), wp_die(), explode(), array_map(), get_current_user_id(), time(), apply_filters(), update_post_meta(), wp_die() |
empty($value) && !current_user_can() | 67–70 | wp_die(), get_post(), check_ajax_referer(), current_user_can(), wp_die(), explode(), array_map(), get_current_user_id(), wp_die(), time(), apply_filters(), update_post_meta(), wp_die() |
4 further outcomes, up to 73 instructions
empty($value) && current_user_can() | 67–70 | wp_die(), get_post(), wp_die(), check_ajax_referer(), current_user_can(), explode(), array_map(), get_current_user_id(), wp_die(), time(), apply_filters(), update_post_meta(), wp_die() |
empty($value) && !current_user_can() | 67–70 | wp_die(), get_post(), wp_die(), check_ajax_referer(), current_user_can(), wp_die(), explode(), array_map(), get_current_user_id(), time(), apply_filters(), update_post_meta(), wp_die() |
!empty($value) && !current_user_can() | 70 | get_post(), wp_die(), check_ajax_referer(), current_user_can(), wp_die(), explode(), array_map(), get_current_user_id(), wp_die(), time(), apply_filters(), update_post_meta(), wp_die() |
empty($value) && !current_user_can() | 70–73 | wp_die(), get_post(), wp_die(), check_ajax_referer(), current_user_can(), wp_die(), explode(), array_map(), get_current_user_id(), wp_die(), time(), apply_filters(), update_post_meta(), wp_die() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 73 | 61–73 | 5 | |
| 8.5 | 73 | 61–73 | 5 | |
| 8.4 | 73 | 61–73 | 5 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 76 | 64–76 | 5 | |
| 8.2 | 76 | 64–76 | 5 | |
| 8.1 | 76 | 64–76 | 5 | |
| 7.4 | 76 | 64–76 | 5 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while wp_ajax_wp_remove_post_lock() runs, in this order:
- apply_filters( wp_check_post_lock_window )filterline 2945 (+32 into the body)
Filters the post lock window duration.
Uses · 7
- wp_die()Kills WordPress execution and displays HTML page with an error message.
- get_post()Retrieves post data given a post ID or post object.
- check_ajax_referer()Verifies the Ajax request to prevent processing requests external of the blog.
- current_user_can()Returns whether the current user has the specified capability.
- get_current_user_id()Gets the current user's ID.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- update_post_meta()Updates a post meta field based on the given post ID.
Source code
function wp_ajax_wp_remove_post_lock() { if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) { wp_die( 0 ); } $post_id = (int) $_POST['post_ID']; $post = get_post( $post_id ); if ( ! $post ) { wp_die( 0 ); } check_ajax_referer( 'update-post_' . $post_id ); if ( ! current_user_can( 'edit_post', $post_id ) ) { wp_die( -1 ); } $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) ); if ( get_current_user_id() !== $active_lock[1] ) { wp_die( 0 ); } /** * Filters the post lock window duration. * * @since 3.3.0 * * @param int $interval The interval in seconds the post lock duration * should last, plus 5 seconds. Default 150. */ $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 150 ) + 5 ) . ':' . $active_lock[1]; update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) ); wp_die( 1 );}Changelog
Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-admin/includes/ajax-actions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.