[wp-trac] [WordPress Trac] #28135: wp_insert_post returns error for custom post type in 3.9.0
WordPress Trac
noreply at wordpress.org
Sat May 10 16:52:57 UTC 2014
#28135: wp_insert_post returns error for custom post type in 3.9.0
-------------------------------+--------------------
Reporter: capit0l | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.9.2
Component: Posts, Post Types | Version: 3.9
Severity: major | Resolution:
Keywords: | Focuses:
-------------------------------+--------------------
Comment (by jesin):
As SergeyBiryukov pointed out I was able to get this notice only if the
post type is registered **after** `wp_insert_post()`.
We need a `post_type_exists()` check inside `wp_insert_post()`. I find
that that this function creates a post even if the `$post_type` is
registered nowhere. And this inserted post has the non-registered post
type in the database.
I am interested to submit a patch for this but how is this error handled?
Is a `WP_Error` object returned, fallback to default `post` type or
`_doing_it_wrong()`? I think `WP_Error` is the right option.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28135#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list