Ticket #23074: combined.patch
File combined.patch, 2.6 KB (added by , 11 years ago) |
---|
-
wp-includes/post.php
4520 4520 * @return int Same as $post_id 4521 4521 */ 4522 4522 function wp_check_for_changed_slugs($post_id, $post, $post_before) { 4523 // dont bother if it hasnt changed 4524 if ( $post->post_name == $post_before->post_name ) 4525 return; 4523 $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug'); 4526 4524 4527 4525 // we're only concerned with published, non-hierarchical objects 4528 if ( $post->post_status != 'publish' || is_post_type_hierarchical( $post->post_type ) ) 4526 if ( $post->post_status != 'publish' || is_post_type_hierarchical( $post->post_type ) ) { 4527 // Delete any values in '_wp_old_slug' added when it was published and non-hierarchical. 4528 // Note this means cycling a post from Published to Private to Published will delete old slugs. 4529 if ($old_slugs) 4530 delete_post_meta($post_id, '_wp_old_slug'); 4529 4531 return; 4532 } 4530 4533 4531 $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug'); 4534 // don't bother if it hasn't changed 4535 if ( $post->post_name != $post_before->post_name ) 4536 // if we haven't added this old slug before, add it now 4537 if ( !empty( $post_before->post_name ) && !in_array($post_before->post_name, $old_slugs) ) 4538 add_post_meta($post_id, '_wp_old_slug', $post_before->post_name); 4532 4539 4533 // if we haven't added this old slug before, add it now4534 if ( !empty( $post_before->post_name ) && !in_array($post_before->post_name, $old_slugs) )4535 add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);4536 4537 4540 // if the new slug was used previously, delete it from the list 4538 4541 if ( in_array($post->post_name, $old_slugs) ) 4539 4542 delete_post_meta($post_id, '_wp_old_slug', $post->post_name); -
wp-includes/query.php
3923 3923 3924 3924 $query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, $wp_query->query_vars['name']); 3925 3925 3926 // Prevent a simple redirect loop due to values in '_wp_old_slug' not deleted 3927 // when in an unpublished status (legacy data). 3928 $query .= $wpdb->prepare(" AND post_name != %s", $wp_query->query_vars['name']); 3929 3926 3930 // if year, monthnum, or day have been specified, make our query more precise 3927 3931 // just in case there are multiple identical _wp_old_slug values 3928 3932 if ( '' != $wp_query->query_vars['year'] )