WordPress.org

Make WordPress Core

Changeset 12298


Ignore:
Timestamp:
11/30/09 21:41:52 (4 years ago)
Author:
ryan
Message:

Save parent temp ID for unattached attachments in postmeta. Props scribu. fixes #9471

Location:
trunk
Files:
2 edited

Legend:

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

    r12284 r12298  
    774774    $old_ID = (int) $old_ID; 
    775775    $new_ID = (int) $new_ID; 
    776     return $wpdb->update($wpdb->posts, array('post_parent' => $new_ID), array('post_parent' => $old_ID) ); 
     776 
     777    $children = $wpdb->get_col( $wpdb->prepare(" 
     778        SELECT post_id 
     779        FROM $wpdb->postmeta 
     780        WHERE meta_key = '_wp_attachment_temp_parent' 
     781        AND meta_value = %d", $old_ID) ); 
     782 
     783    foreach ( $children as $child_id ) { 
     784        $wpdb->update($wpdb->posts, array('post_parent' => $new_ID), array('ID' => $child_id) ); 
     785        delete_post_meta($child_id, '_wp_attachment_temp_parent'); 
     786    } 
    777787} 
    778788 
  • trunk/wp-includes/post.php

    r12284 r12298  
    28042804 
    28052805    clean_post_cache($post_ID); 
     2806 
     2807    if ( isset($post_parent) && $post_parent < 0 ) 
     2808        add_post_meta($post_ID, '_wp_attachment_temp_parent', $post_parent, true); 
    28062809 
    28072810    if ( $update) { 
Note: See TracChangeset for help on using the changeset viewer.