WordPress.org

Make WordPress Core

Ticket #18235: 18235.2.patch

File 18235.2.patch, 4.0 KB (added by ethitter, 7 years ago)

Removed old code as indicated by azaozz, tested editor and QuickPress (JS and non-JS), fixed internal references to wp_write_post.

  • wp-includes/post.php

     
    37253725
    37263726        clean_post_cache($post_ID);
    37273727
    3728         if ( isset($post_parent) && $post_parent < 0 )
    3729                 add_post_meta($post_ID, '_wp_attachment_temp_parent', $post_parent, true);
    3730 
    37313728        if ( ! empty( $context ) )
    37323729                add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
    37333730
  • wp-admin/includes/post.php

     
    234234
    235235        wp_update_post( $post_data );
    236236
    237         // Reunite any orphaned attachments with their parent
    238         if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
    239                 $draft_ids = array();
    240         if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
    241                 _relocate_children( $draft_temp_id, $post_ID );
    242 
    243237        // Now that we have an ID we can fix any attachment anchor hrefs
    244238        _fix_attachment_links( $post_ID );
    245239
     
    533527function wp_write_post() {
    534528        global $user_ID;
    535529
    536 
    537530        if ( isset($_POST['post_type']) )
    538531                $ptype = get_post_type_object($_POST['post_type']);
    539532        else
     
    551544        // Clear out any data in internal vars.
    552545        unset( $_POST['filter'] );
    553546
    554         // Check for autosave collisions
    555         // Does this need to be updated? ~ Mark
    556         $temp_id = false;
    557         if ( isset($_POST['temp_ID']) ) {
    558                 $temp_id = (int) $_POST['temp_ID'];
    559                 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
    560                         $draft_ids = array();
    561                 foreach ( $draft_ids as $temp => $real )
    562                         if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then )
    563                                 unset($draft_ids[$temp]);
    564 
    565                 if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write
    566                         $_POST['post_ID'] = $draft_ids[$temp_id];
    567                         unset($_POST['temp_ID']);
    568                         update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
    569                         return edit_post();
    570                 }
    571         }
    572 
    573547        // Edit don't write if we have a post id.
    574         if ( isset( $_POST['ID'] ) ) {
    575                 $_POST['post_ID'] = $_POST['ID'];
    576                 unset ( $_POST['ID'] );
    577         }
    578         if ( isset( $_POST['post_ID'] ) ) {
     548        if ( isset( $_POST['post_ID'] ) )
    579549                return edit_post();
    580         }
    581550
    582551        $translated = _wp_translate_postdata( false );
    583552        if ( is_wp_error($translated) )
     
    611580
    612581        add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
    613582
    614         // Reunite any orphaned attachments with their parent
    615         // Does this need to be udpated? ~ Mark
    616         if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
    617                 $draft_ids = array();
    618         if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
    619                 _relocate_children( $draft_temp_id, $post_ID );
    620         if ( $temp_id && $temp_id != $draft_temp_id )
    621                 _relocate_children( $temp_id, $post_ID );
    622 
    623         // Update autosave collision detection
    624         if ( $temp_id ) {
    625                 $draft_ids[$temp_id] = $post_ID;
    626                 update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
    627         }
    628 
    629583        // Now that we have an ID we can fix any attachment anchor hrefs
    630584        _fix_attachment_links( $post_ID );
    631585
     
    638592 * Calls wp_write_post() and handles the errors.
    639593 *
    640594 * @since 2.0.0
    641  *
     595 
     596 * @uses wp_write_post()
     597 * @uses is_wp_error()
     598 * @uses wp_die()
    642599 * @return unknown
    643600 */
    644601function write_post() {
     
    13151272 * @package WordPress
    13161273 * @since 2.7.0
    13171274 *
    1318  * @uses wp_write_post()
     1275 * @uses get_post_status()
    13191276 * @uses edit_post()
    13201277 * @uses get_post()
    13211278 * @uses current_user_can()
     1279 * @uses wp_die()
    13221280 * @uses wp_create_post_autosave()
     1281 * @uses add_query_arg()
     1282 * @uses wp_create_nonce()
    13231283 *
    13241284 * @return str URL to redirect to show the preview
    13251285 */
  • wp-admin/edit-form-advanced.php

     
    2323 * @var int
    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 : '';
    2928