Changeset 60906
- Timestamp:
- 10/06/2025 08:11:21 PM (5 weeks ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
-
src/wp-includes/post.php (modified) (3 diffs)
-
tests/phpunit/tests/post.php (modified) (1 diff)
-
tests/phpunit/tests/post/wpDeletePost.php (added)
-
tests/phpunit/tests/post/wpInsertPost.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r60792 r60906 3744 3744 * @see wp_trash_post() 3745 3745 * 3746 * @param int $post_id Optional. Post ID. Default 0.3746 * @param int $post_id Post ID. (The default of 0 is for historical reasons; providing it is incorrect.) 3747 3747 * @param bool $force_delete Optional. Whether to bypass Trash and force deletion. 3748 3748 * Default false. … … 3751 3751 function wp_delete_post( $post_id = 0, $force_delete = false ) { 3752 3752 global $wpdb; 3753 3754 $post_id = (int) $post_id; 3755 if ( $post_id <= 0 ) { 3756 _doing_it_wrong( __FUNCTION__, __( 'The post ID must be greater than 0.' ), '6.9.0' ); 3757 return false; 3758 } 3753 3759 3754 3760 $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id ) ); … … 3776 3782 * @since 4.4.0 3777 3783 * 3778 * @param WP_Post|false|null $ delete Whether to go forward withdeletion.3784 * @param WP_Post|false|null $check Whether to go forward with deletion. Anything other than null will short-circuit deletion. 3779 3785 * @param WP_Post $post Post object. 3780 3786 * @param bool $force_delete Whether to bypass the Trash. -
trunk/tests/phpunit/tests/post.php
r60792 r60906 503 503 } 504 504 505 public function test_wp_delete_post_reassign_hierarchical_post_type() {506 $grandparent_page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );507 $parent_page_id = self::factory()->post->create(508 array(509 'post_type' => 'page',510 'post_parent' => $grandparent_page_id,511 )512 );513 $page_id = self::factory()->post->create(514 array(515 'post_type' => 'page',516 'post_parent' => $parent_page_id,517 )518 );519 520 $this->assertSame( $parent_page_id, get_post( $page_id )->post_parent );521 522 wp_delete_post( $parent_page_id, true );523 $this->assertSame( $grandparent_page_id, get_post( $page_id )->post_parent );524 525 wp_delete_post( $grandparent_page_id, true );526 $this->assertSame( 0, get_post( $page_id )->post_parent );527 }528 529 505 /** 530 506 * Test ensuring that the post_slug can be filtered with a custom value short circuiting the built in -
trunk/tests/phpunit/tests/post/wpInsertPost.php
r57680 r60906 567 567 568 568 /** 569 * "When I delete a future post using wp_delete_post( $post->ID ) it does not update the cron correctly."570 *571 * @ticket 5364572 * @covers ::wp_delete_post573 */574 public function test_delete_future_post_cron() {575 $future_date = strtotime( '+1 day' );576 577 $data = array(578 'post_status' => 'publish',579 'post_content' => 'content',580 'post_title' => 'title',581 'post_date' => date_format( date_create( "@{$future_date}" ), 'Y-m-d H:i:s' ),582 );583 584 // Insert a post and make sure the ID is OK.585 $post_id = wp_insert_post( $data );586 587 // Check that there's a publish_future_post job scheduled at the right time.588 $this->assertSame( $future_date, $this->next_schedule_for_post( 'publish_future_post', $post_id ) );589 590 // Now delete the post and make sure the cron entry is removed.591 wp_delete_post( $post_id );592 593 $this->assertFalse( $this->next_schedule_for_post( 'publish_future_post', $post_id ) );594 }595 596 /**597 569 * Bug: permalink doesn't work if post title is empty. 598 570 *
Note: See TracChangeset
for help on using the changeset viewer.