mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Posts, Post Types: Check if the post type exists in wp_insert_post().
This avoids an `Attempt to read property "cap" on null` PHP warning when checking an unregistered post type's `publish_posts` capability to disallow contributors setting the post slug for pending posts. Follow-up to [9055], [42380]. Props Chouby, mukesh27, rafiahmedd, SergeyBiryukov. Fixes #55877. git-svn-id: https://develop.svn.wordpress.org/trunk@53771 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -501,6 +501,23 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$this->assertStringContainsString( 'wptests_pt=' . $p, $post->guid );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 55877
|
||||
* @covers ::wp_insert_post
|
||||
*/
|
||||
public function test_wp_insert_post_should_not_trigger_warning_for_pending_posts_with_unknown_cpt() {
|
||||
$post_id = wp_insert_post(
|
||||
array(
|
||||
'post_title' => 'title',
|
||||
'post_type' => 'unknown',
|
||||
'post_status' => 'pending',
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertIsNumeric( $post_id );
|
||||
$this->assertGreaterThan( 0, $post_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 20451
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user