diff --git src/wp-includes/post.php src/wp-includes/post.php
index 288704c66d..94006f7b38 100644
--- src/wp-includes/post.php
+++ src/wp-includes/post.php
@@ -4155,7 +4155,7 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
 	 */
 	$post_type_object = get_post_type_object( $post_type );
 
-	if ( ! $update && 'pending' === $post_status && ! current_user_can( $post_type_object->cap->publish_posts ) ) {
+	if ( ! $update && 'pending' === $post_status && ! empty( $post_type_object ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) {
 		$post_name = '';
 	} elseif ( $update && 'pending' === $post_status && ! current_user_can( 'publish_post', $post_ID ) ) {
 		$post_name = '';
