WordPress.org

Make WordPress Core

Ticket #11863: conflict.2.patch

File conflict.2.patch, 2.9 KB (added by williamsba1, 8 years ago)
  • wp-admin/edit.php

     
    205205
    206206if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
    207207        printf( _n( 'Item restored from the trash.', '%s items restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
     208        if ( isset($_GET['conflict']) && (int) $_GET['conflict']) {
     209                _e( ' There was a permalink conflict with the restored post.  The restored post\'s permalink was updated.' );
     210        }
    208211        unset($_GET['undeleted']);
    209212}
    210213
  • wp-admin/post.php

     
    237237        if ( !current_user_can($post_type_object->delete_cap, $post_id) )
    238238                wp_die( __('You are not allowed to move this item out of the trash.') );
    239239
     240        $orig_permalink = get_permalink($post_id);
     241
    240242        if ( ! wp_untrash_post($post_id) )
    241243                wp_die( __('Error in restoring from trash...') );
    242244
    243         wp_redirect( add_query_arg('untrashed', 1, $sendback) );
     245        if( $orig_permalink != get_permalink($post_id) ) {
     246                 $permalink_conflict=1;
     247        }
     248
     249        wp_redirect( add_query_arg(array('untrashed' => 1,'conflict' => $permalink_conflict), $sendback) );
    244250        exit();
    245251        break;
    246252
  • wp-includes/post.php

     
    24662466        } elseif ( in_array( $post_type, $hierarchical_post_types ) ) {
    24672467                // Page slugs must be unique within their own trees. Pages are in a separate
    24682468                // namespace than posts so page slugs are allowed to overlap post slugs.
    2469                 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";
     2469                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' ) AND ID != %d AND post_parent = %d AND post_status <> 'trash' LIMIT 1";
    24702470                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
    24712471
    24722472                if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( '@^(page)?\d+$@', $slug ) ) {
     
    24802480                }
    24812481        } else {
    24822482                // Post slugs must be unique across all posts.
    2483                 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
     2483                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_status <> 'trash' LIMIT 1";
    24842484                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
    24852485
    24862486                if ( $post_name_check || in_array( $slug, $feeds ) ) {