Ticket #11863: conflict.patch
File conflict.patch, 4.0 KB (added by , 15 years ago) |
---|
-
wp-admin/edit.php
203 203 unset($_GET['trashed']); 204 204 } 205 205 206 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {206 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] && !$_GET['conflict']) { 207 207 printf( _n( 'Item restored from the trash.', '%s items restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); 208 208 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']); 209 212 } 210 213 211 214 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] ); -
wp-admin/post.php
232 232 break; 233 233 234 234 case 'untrash': 235 global $permalink_conflict; 236 235 237 check_admin_referer('untrash-' . $post_type . '_' . $post_id); 236 238 237 239 if ( !current_user_can($post_type_object->delete_cap, $post_id) ) … … 240 242 if ( ! wp_untrash_post($post_id) ) 241 243 wp_die( __('Error in restoring from trash...') ); 242 244 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 244 251 exit(); 245 252 break; 246 253 -
wp-includes/post.php
1750 1750 * @return mixed False on failure 1751 1751 */ 1752 1752 function wp_untrash_post($post_id = 0) { 1753 global $permalink_conflict; 1754 1753 1755 if ( !$post = wp_get_single_post($post_id, ARRAY_A) ) 1754 1756 return $post; 1755 1757 … … 1765 1767 delete_post_meta($post_id, '_wp_trash_meta_status'); 1766 1768 delete_post_meta($post_id, '_wp_trash_meta_time'); 1767 1769 1770 $orig_permalink = get_permalink($post_id); 1771 1768 1772 wp_insert_post($post); 1769 1773 1774 If($orig_permalink != get_permalink($post_id)) { 1775 $permalink_conflict = true; 1776 } 1777 1770 1778 wp_untrash_post_comments($post_id); 1771 1779 1772 1780 do_action('untrashed_post', $post_id); … … 2430 2438 } elseif ( in_array( $post_type, $hierarchical_post_types ) ) { 2431 2439 // Page slugs must be unique within their own trees. Pages are in a separate 2432 2440 // 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"; 2434 2442 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) ); 2435 2443 2436 2444 if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( '@^(page)?\d+$@', $slug ) ) { … … 2444 2452 } 2445 2453 } else { 2446 2454 // 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"; 2448 2456 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 2449 2457 2450 2458 if ( $post_name_check || in_array( $slug, $feeds ) ) {