Fixes #1837 timestamp funkiness

git-svn-id: https://develop.svn.wordpress.org/trunk@3074 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg
2005-11-14 09:56:41 +00:00
parent 1932ae4455
commit a313d7adfb
2 changed files with 34 additions and 23 deletions

View File

@@ -54,10 +54,17 @@ function wp_insert_post($postarr = array()) {
$post_name = sanitize_title($post_name);
}
if (empty($post_date))
$post_date = current_time('mysql');
if (empty($post_date_gmt))
$post_date_gmt = get_gmt_from_date($post_date);
// If the post date is empty (due to having been new or a draft) and status is not 'draft', set date to now
if (empty($post_date)) {
if ( 'draft' != $post_status )
$post_date = current_time('mysql');
}
if (empty($post_date_gmt)) {
if ( 'draft' != $post_status )
$post_date_gmt = get_gmt_from_date($post_date);
}
if ( empty($comment_status) ) {
if ( $update )
@@ -382,6 +389,21 @@ function wp_update_post($postarr = array()) {
$postarr = array_merge($post, $postarr);
$postarr['post_category'] = $post_cats;
// Drafts shouldn't be assigned a date unless explicitly done so by the user
if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
('0000-00-00 00:00:00' == $post['post_date']) )
$clear_date = true;
else
$clear_date = false;
// Merge old and new fields with new fields overwriting old ones.
$postarr = array_merge($post, $postarr);
$postarr['post_category'] = $post_cats;
if ( $clear_date ) {
$postarr['post_date'] = '';
$postarr['post_date_gmt'] = '';
}
return wp_insert_post($postarr);
}