From ad73270aa4aa5cb8e2baf709db627be1f4464532 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 13 Apr 2017 23:08:03 +0000 Subject: [PATCH] Posts, Post Types: In `wp_check_post_lock()`, check if the user with lock exists and return false otherwise. Props arshidkv12, 1naveengiri. Fixes #39888. git-svn-id: https://develop.svn.wordpress.org/trunk@40424 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/post.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index c9ac04244d..8055a7b7dc 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -1450,7 +1450,7 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { * * @param int $post_id ID of the post to check for editing. * @return int|false ID of the user with lock. False if the post does not exist, post is not locked, - * or post is locked by current user. + * the user with lock does not exist, or the post is locked by current user. */ function wp_check_post_lock( $post_id ) { if ( ! $post = get_post( $post_id ) ) { @@ -1465,6 +1465,10 @@ function wp_check_post_lock( $post_id ) { $time = $lock[0]; $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); + if ( ! get_userdata( $user ) ) { + return false; + } + /** This filter is documented in wp-admin/includes/ajax-actions.php */ $time_window = apply_filters( 'wp_check_post_lock_window', 150 ); @@ -1481,8 +1485,8 @@ function wp_check_post_lock( $post_id ) { * @since 2.5.0 * * @param int $post_id ID of the post being edited. - * @return array|false Array of the lock time and user ID. False if the post does not exist or there - * is no current user. + * @return array|false Array of the lock time and user ID. False if the post does not exist, or + * there is no current user. */ function wp_set_post_lock( $post_id ) { if ( ! $post = get_post( $post_id ) ) {