Make WordPress Core

Ticket #15130: 15130.add-id-to-lock.2.diff

File 15130.add-id-to-lock.2.diff, 1.6 KB (added by duck_, 16 years ago)
  • wp-admin/includes/post.php

     
    11451145        if ( !$post = get_post( $post_id ) )
    11461146                return false;
    11471147
    1148         $lock = get_post_meta( $post->ID, '_edit_lock', true );
    1149         $last = get_post_meta( $post->ID, '_edit_last', true );
     1148        if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) )
     1149                return false;
    11501150
     1151        list( $user, $time ) = explode( ':', $lock );
    11511152        $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 );
    11521153
    1153         if ( $lock && $lock > time() - $time_window && $last != get_current_user_id() )
    1154                 return $last;
     1154        if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
     1155                return $user;
    11551156        return false;
    11561157}
    11571158
    … …  
    11661167function wp_set_post_lock( $post_id ) {
    11671168        if ( !$post = get_post( $post_id ) )
    11681169                return false;
    1169         if ( 0 == get_current_user_id() )
     1170        if ( 0 == ($user_id = get_current_user_id()) )
    11701171                return false;
    11711172
    11721173        $now = time();
     1174        $lock = "$user_id:$now";
    11731175
    1174         update_post_meta( $post->ID, '_edit_lock', $now );
     1176        update_post_meta( $post->ID, '_edit_lock', $lock );
    11751177}
    11761178
    11771179/**
    … …  
    11821184 */
    11831185function _admin_notice_post_locked() {
    11841186        global $post;
    1185         $last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) );
     1187        list( $user, $time ) = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) );
     1188        $last_user = get_userdata( $user );
    11861189        $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
    11871190
    11881191        switch ($post->post_type) {