WordPress.org

Make WordPress Core

Changeset 18823


Ignore:
Timestamp:
09/29/11 21:47:52 (3 years ago)
Author:
azaozz
Message:

Clean up remnants from having negative Post_IDs, props markjaquith, fixes #18235

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r18796 r18823  
    2424 */ 
    2525$post_ID = isset($post_ID) ? (int) $post_ID : 0; 
    26 $temp_ID = isset($temp_ID) ? (int) $temp_ID : 0; 
    2726$user_ID = isset($user_ID) ? (int) $user_ID : 0; 
    2827$action = isset($action) ? $action : ''; 
  • trunk/wp-admin/includes/media.php

    r18802 r18823  
    402402 
    403403function get_upload_iframe_src($type) { 
    404     global $post_ID, $temp_ID; 
    405     $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); 
     404    global $post_ID; 
     405 
     406    $uploading_iframe_ID = (int) $post_ID; 
    406407    $upload_iframe_src = add_query_arg( 'post_id', $uploading_iframe_ID, admin_url('media-upload.php') ); 
    407408 
    408409    if ( 'media' != $type ) 
    409410        $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src); 
     411 
    410412    $upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src); 
    411413 
  • trunk/wp-admin/includes/post.php

    r18796 r18823  
    229229 
    230230    wp_update_post( $post_data ); 
    231  
    232     // Reunite any orphaned attachments with their parent 
    233     if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 
    234         $draft_ids = array(); 
    235     if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) ) 
    236         _relocate_children( $draft_temp_id, $post_ID ); 
    237231 
    238232    // Now that we have an ID we can fix any attachment anchor hrefs 
     
    539533    global $user_ID; 
    540534 
    541  
    542535    if ( isset($_POST['post_type']) ) 
    543536        $ptype = get_post_type_object($_POST['post_type']); 
     
    557550    unset( $_POST['filter'] ); 
    558551 
    559     // Check for autosave collisions 
    560     // Does this need to be updated? ~ Mark 
    561     $temp_id = false; 
    562     if ( isset($_POST['temp_ID']) ) { 
    563         $temp_id = (int) $_POST['temp_ID']; 
    564         if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 
    565             $draft_ids = array(); 
    566         foreach ( $draft_ids as $temp => $real ) 
    567             if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then ) 
    568                 unset($draft_ids[$temp]); 
    569  
    570         if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write 
    571             $_POST['post_ID'] = $draft_ids[$temp_id]; 
    572             unset($_POST['temp_ID']); 
    573             update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); 
    574             return edit_post(); 
    575         } 
    576     } 
    577  
    578552    // Edit don't write if we have a post id. 
    579     if ( isset( $_POST['ID'] ) ) { 
    580         $_POST['post_ID'] = $_POST['ID']; 
    581         unset ( $_POST['ID'] ); 
    582     } 
    583     if ( isset( $_POST['post_ID'] ) ) { 
     553    if ( isset( $_POST['post_ID'] ) ) 
    584554        return edit_post(); 
    585     } 
    586555 
    587556    $translated = _wp_translate_postdata( false ); 
     
    617586    add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); 
    618587 
    619     // Reunite any orphaned attachments with their parent 
    620     // Does this need to be updated? ~ Mark 
    621     if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 
    622         $draft_ids = array(); 
    623     if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) ) 
    624         _relocate_children( $draft_temp_id, $post_ID ); 
    625     if ( $temp_id && $temp_id != $draft_temp_id ) 
    626         _relocate_children( $temp_id, $post_ID ); 
    627  
    628     // Update autosave collision detection 
    629     if ( $temp_id ) { 
    630         $draft_ids[$temp_id] = $post_ID; 
    631         update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); 
    632     } 
    633  
    634588    // Now that we have an ID we can fix any attachment anchor hrefs 
    635589    _fix_attachment_links( $post_ID ); 
     
    644598 * 
    645599 * @since 2.0.0 
    646  * 
     600  
     601 * @uses wp_write_post() 
     602 * @uses is_wp_error() 
     603 * @uses wp_die() 
    647604 * @return unknown 
    648605 */ 
     
    13231280 * @since 2.7.0 
    13241281 * 
    1325  * @uses wp_write_post() 
     1282 * @uses get_post_status() 
    13261283 * @uses edit_post() 
    13271284 * @uses get_post() 
    13281285 * @uses current_user_can() 
     1286 * @uses wp_die() 
    13291287 * @uses wp_create_post_autosave() 
     1288 * @uses add_query_arg() 
     1289 * @uses wp_create_nonce() 
    13301290 * 
    13311291 * @return str URL to redirect to show the preview 
  • trunk/wp-includes/post.php

    r18809 r18823  
    37293729    clean_post_cache($post_ID); 
    37303730 
    3731     if ( isset($post_parent) && $post_parent < 0 ) 
    3732         add_post_meta($post_ID, '_wp_attachment_temp_parent', $post_parent, true); 
    3733  
    37343731    if ( ! empty( $context ) ) 
    37353732        add_post_meta( $post_ID, '_wp_attachment_context', $context, true ); 
Note: See TracChangeset for help on using the changeset viewer.