mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Posts: Don't modify post_name if it wasn't supplied to wp_insert_post().
Previously when updating a post using wp_insert_post(), post_name was regenerated based on post_title every time if post_name was not passed in explicitly. This irons out the expectation that properties not passed into the function should not be modified. Props jason_the_adams. Fixes #34865. git-svn-id: https://develop.svn.wordpress.org/trunk@35800 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1188,6 +1188,30 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'Updated', $saved_post->post_content );
|
||||
}
|
||||
|
||||
/**
|
||||
* If a post is updated without providing a post_name param,
|
||||
* a new slug should not be generated.
|
||||
*
|
||||
* @ticket 34865
|
||||
*/
|
||||
function test_post_updates_without_slug_provided() {
|
||||
$post_id = self::factory()->post->create( array(
|
||||
'post_title' => 'Stuff',
|
||||
'post_status' => 'publish'
|
||||
) );
|
||||
|
||||
$data = array(
|
||||
'ID' => $post_id,
|
||||
'post_title' => 'Stuff and Things'
|
||||
);
|
||||
|
||||
wp_insert_post( $data );
|
||||
|
||||
$updated_post = get_post( $post_id );
|
||||
// Ensure changing the post_title didn't modify the post_name.
|
||||
$this->assertEquals('stuff', $updated_post->post_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 32585
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user