WordPress.org

Make WordPress Core

Ticket #11863: conflict.patch

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

     
    203203        unset($_GET['trashed']);
    204204}
    205205
    206 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
     206if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] && !$_GET['conflict']) {
    207207        printf( _n( 'Item restored from the trash.', '%s items restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
    208208        unset($_GET['undeleted']);
     209}elseif ( (isset($_GET['untrashed']) && (int) $_GET['untrashed']) && (isset($_GET['conflict']) && (int) $_GET['conflict']) ) {
     210        printf( _n( 'Item restored from the trash, but there was a permalink conflict.  The restored post\'s permalink was updated.', '%s items restored from the trash, but there was a permalink conflict.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
     211        unset($_GET['undeleted']);
    209212}
    210213
    211214$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] );
  • wp-admin/post.php

     
    232232        break;
    233233
    234234case 'untrash':
     235        global $permalink_conflict;
     236       
    235237        check_admin_referer('untrash-' . $post_type . '_' . $post_id);
    236238
    237239        if ( !current_user_can($post_type_object->delete_cap, $post_id) )
     
    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($permalink_conflict) {
     246                wp_redirect( add_query_arg(array('untrashed' => 1,'conflict' => 1), $sendback) );
     247        }Else{
     248                wp_redirect( add_query_arg('untrashed', 1, $sendback) );
     249        }
     250       
    244251        exit();
    245252        break;
    246253
  • wp-includes/post.php

     
    17501750 * @return mixed False on failure
    17511751 */
    17521752function wp_untrash_post($post_id = 0) {
     1753        global $permalink_conflict;
     1754       
    17531755        if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
    17541756                return $post;
    17551757
     
    17651767        delete_post_meta($post_id, '_wp_trash_meta_status');
    17661768        delete_post_meta($post_id, '_wp_trash_meta_time');
    17671769
     1770        $orig_permalink = get_permalink($post_id);
     1771
    17681772        wp_insert_post($post);
    17691773
     1774        If($orig_permalink != get_permalink($post_id)) {
     1775                $permalink_conflict = true;
     1776        }
     1777
    17701778        wp_untrash_post_comments($post_id);
    17711779
    17721780        do_action('untrashed_post', $post_id);
     
    24302438        } elseif ( in_array( $post_type, $hierarchical_post_types ) ) {
    24312439                // Page slugs must be unique within their own trees. Pages are in a separate
    24322440                // namespace than posts so page slugs are allowed to overlap post slugs.
    2433                 $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";
     2441                $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";
    24342442                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
    24352443
    24362444                if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( '@^(page)?\d+$@', $slug ) ) {
     
    24442452                }
    24452453        } else {
    24462454                // Post slugs must be unique across all posts.
    2447                 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
     2455                $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";
    24482456                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
    24492457
    24502458                if ( $post_name_check || in_array( $slug, $feeds ) ) {