From 8513fbef0148fd959b39f56c91944a3161ee788e Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 13 Jul 2010 21:30:09 +0000 Subject: [PATCH] Sanity check properties in wp_get_single_post(). Props filosofo. fixes #13904 for 3.1 git-svn-id: http://svn.automattic.com/wordpress/trunk@15405 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index cfbd21f12f..b086e531d3 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2077,6 +2077,12 @@ function wp_get_single_post($postid = 0, $mode = OBJECT) { $post = get_post($postid, $mode); + if ( + ( OBJECT == $mode && empty( $post->ID ) ) || + ( OBJECT != $mode && empty( $post['ID'] ) ) + ) + return ( OBJECT == $mode ? null : array() ); + // Set categories and tags if ( $mode == OBJECT ) { $post->post_category = array(); @@ -2418,7 +2424,7 @@ function wp_update_post($postarr = array()) { $post_cats = $post['post_category']; // Drafts shouldn't be assigned a date unless explicitly done so by the user - if ( in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) && + if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) && ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) $clear_date = true; else