WordPress.org

Make WordPress Core

Changeset 16901


Ignore:
Timestamp:
12/13/2010 09:23:46 PM (11 years ago)
Author:
ryan
Message:

Add user id to lock. Props duck_. see #15130

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/post.php

    r16761 r16901  
    12021202        return false;
    12031203
    1204     $lock = get_post_meta( $post->ID, '_edit_lock', true );
    1205     $last = get_post_meta( $post->ID, '_edit_last', true );
    1206 
     1204    if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) )
     1205        return false;
     1206
     1207    $lock = explode( ':', $lock );
     1208    $time = $lock[0];
     1209    $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
     1210   
    12071211    $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 );
    12081212
    1209     if ( $lock && $lock > time() - $time_window && $last != get_current_user_id() )
    1210         return $last;
     1213    if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
     1214        return $user;
    12111215    return false;
    12121216}
     
    12231227    if ( !$post = get_post( $post_id ) )
    12241228        return false;
    1225     if ( 0 == get_current_user_id() )
     1229    if ( 0 == ($user_id = get_current_user_id()) )
    12261230        return false;
    12271231
    12281232    $now = time();
    1229 
    1230     update_post_meta( $post->ID, '_edit_lock', $now );
     1233    $lock = "$now:$user_id";
     1234
     1235    update_post_meta( $post->ID, '_edit_lock', $lock );
    12311236}
    12321237
     
    12391244function _admin_notice_post_locked() {
    12401245    global $post;
    1241     $last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) );
     1246
     1247    $lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) );
     1248    $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
     1249    $last_user = get_userdata( $user );
    12421250    $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
    12431251
Note: See TracChangeset for help on using the changeset viewer.