WordPress.org

Make WordPress Core

Ticket #11863: 11863.18.diff

File 11863.18.diff, 1.4 KB (added by ericlewis, 4 years ago)
  • src/wp-includes/post.php

     
    53405340                return;
    53415341        }
    53425342
     5343        // Don't bother if the slug is being changed by untrashing a post.
     5344        if ( '__trashed' === substr( $post_before->post_name, -9 ) ) {
     5345                return;
     5346        }
     5347
    53435348        // We're only concerned with published, non-hierarchical objects.
    53445349        if ( ! ( 'publish' === $post->post_status || ( 'attachment' === get_post_type( $post ) && 'inherit' === $post->post_status ) ) || is_post_type_hierarchical( $post->post_type ) ) {
    53455350                return;
  • tests/phpunit/tests/post/wpCheckForChangedSlugs.php

     
     1<?php
     2
     3/**
     4 * @group post
     5 */
     6class Tests_WPCheckForChangedSlugs extends WP_UnitTestCase {
     7
     8        /**
     9         * @ticket 11863
     10         */
     11        function test_untrashing_a_post_should_not_store_the_temporary_trashed_slug() {
     12                $about_page_id = self::factory()->post->create( array(
     13                        'post_type' => 'page',
     14                        'post_title' => 'About',
     15                        'post_status' => 'publish'
     16                ) );
     17                wp_trash_post( $about_page_id );
     18
     19                wp_untrash_post( $about_page_id );
     20
     21                $this->assertEquals( false, get_post_meta( $about_page_id, '_wp_old_slug', true ) );
     22        }
     23}