Ticket #23074: combined.2.patch
File combined.2.patch, 2.2 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 4523 if ( empty( $post_before->post_name ) ) 4524 return; 4525 4526 $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug'); 4527 4528 // if the new slug was used previously, delete it from the list 4529 if ( in_array($post->post_name, $old_slugs) ) 4530 delete_post_meta($post_id, '_wp_old_slug', $post->post_name); 4531 4532 // don't bother if it hasn't changed 4524 4533 if ( $post->post_name == $post_before->post_name ) 4525 4534 return; 4526 4535 … … 4528 4537 if ( $post->post_status != 'publish' || is_post_type_hierarchical( $post->post_type ) ) 4529 4538 return; 4530 4539 4531 $old_slugs = (array) get_post_meta($post_id, '_wp_old_slug');4532 4533 4540 // if we haven't added this old slug before, add it now 4534 if ( ! empty( $post_before->post_name ) && !in_array($post_before->post_name, $old_slugs) )4541 if ( !in_array($post_before->post_name, $old_slugs) ) 4535 4542 add_post_meta($post_id, '_wp_old_slug', $post_before->post_name); 4536 4537 // if the new slug was used previously, delete it from the list4538 if ( in_array($post->post_name, $old_slugs) )4539 delete_post_meta($post_id, '_wp_old_slug', $post->post_name);4540 4543 } 4541 4544 4542 4545 /** -
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 (only in 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'] )