#13246 closed defect (bug) (fixed)
wp_set_post_categories assumes $post_categories has a value in [0], but wp_insert_post doesn't assign the default category there
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Taxonomy | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
right now wp_insert post assigns the default category to a post just as an array item which should be in the 0 ofset. However this isn't guaranteed. If we cast it as the 0 offset in wp_insert_post, this solves the problem
To reproduce:
on a vanilla install with wp_debug enabled, add a post modifying the categories. This causes the following error: Notice: Undefined offset: 0 in /opt/lampp/htdocs/amun/wp/trunk/wp-includes/post.php on line 2561
Attachments (3)
Change History (10)
#3
follow-up:
↓ 4
@
15 years ago
- Keywords needs-testing added
I wasn't able to reproduce the notice. Could you provide more detailed steps to reproduce?
Anyway, 14438.diff:
- removes duplicated validation code from wp_insert_post()
- uses reset($post_category) instead of $post_category[0]
#4
in reply to:
↑ 3
@
15 years ago
Replying to scribu:
I wasn't able to reproduce the notice. Could you provide more detailed steps to reproduce?
I get the error when only one category is checked before clicking Update
Undefined offset: 0 in \wp-dev\wp-includes\post.php on line 2574
My first patch didn't solve it. For the second I added a check to make sure we have a category assigned in [0] if there is only one category.