WordPress.org

Make WordPress Core

Ticket #5459: autosave-array.diff

File autosave-array.diff, 1.3 KB (added by nbachiyski, 8 years ago)
  • wp-admin/includes/post.php

     
    106106        wp_update_post( $_POST ); 
    107107 
    108108        // Reunite any orphaned attachments with their parent 
    109         if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 
     109        if ( !is_array( $draft_ids = get_user_option( 'autosave_draft_ids' ) ) ) 
    110110                $draft_ids = array(); 
    111111        if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) ) 
    112112                _relocate_children( $draft_temp_id, $post_ID ); 
     
    200200        $temp_id = false; 
    201201        if ( isset($_POST['temp_ID']) ) { 
    202202                $temp_id = (int) $_POST['temp_ID']; 
    203                 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 
     203                if ( !is_array( $draft_ids = get_user_option( 'autosave_draft_ids' ) ) ) 
    204204                        $draft_ids = array(); 
    205205                foreach ( $draft_ids as $temp => $real ) 
    206206                        if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then ) 
     
    292292        add_meta( $post_ID ); 
    293293 
    294294        // Reunite any orphaned attachments with their parent 
    295         if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 
     295        if ( !is_array( $draft_ids = get_user_option( 'autosave_draft_ids' ) ) ) 
    296296                $draft_ids = array(); 
    297297        if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) ) 
    298298                _relocate_children( $draft_temp_id, $post_ID );