Make WordPress Core

Ticket #23074: post.php.2.patch

File post.php.2.patch, 1.7 KB (added by kitchin, 11 years ago)

typo fix to previous patch for wp_check_for_changed_slugs

  • wp-includes/post.php

     
    45204520 * @return int Same as $post_id
    45214521 */
    45224522function 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');
    45264524
    45274525        // 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');
    45294531                return;
     4532        }
    45304533
    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);
    45324539
    4533         // 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) )
    4535                 add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
    4536 
    45374540        // if the new slug was used previously, delete it from the list
    45384541        if ( in_array($post->post_name, $old_slugs) )
    45394542                delete_post_meta($post_id, '_wp_old_slug', $post->post_name);