Database error when adding new posts
-
Seemingly out of nowhere, I can’t publish new posts or set featured images. When I go to the admin panel -> add new, I have a “submit for review” button instead of publish, and when I click set featured image, there is no “use this as featured image” link. I’ve been debugging the crap out of this, checked my debug.log, and noticed the following error:
[14-May-2012 14:54:02] WordPress database error Unknown column ” in ‘field list’ for query INSERT INTO
ums_wp_posts
() VALUES (”) made by wp_create_post_autosave, _wp_put_post_revision, wp_insert_post
Debugged some more, and found that in wp-admin/post-new.php if I pass get_default_post_to_edit($post_type, false) instead of true (with the second parameter being $create_in_db via wp-admin/includes/post.php), I get the appropriate buttons. Meaning somewhere in this block of code (wp-admin/includes/post.php lines 418-427):
if ( $create_in_db ) { // Cleanup old auto-drafts more than 7 days old $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); foreach ( (array) $old_posts as $delete ) wp_delete_post( $delete, true ); // Force delete $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); // THE LINE OF CODE ABOVE IS WHATS CAUSING THE ERROR $post = get_post( $post_id ); if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) set_post_format( $post, get_option( 'default_post_format' ) );
I’m getting an error, because I’m trying to insert blank data into a column with no name, which obviously makes no sense. Has anyone run into this? Any idea how to fix this? The site has been working fine for months, I haven’t installed any new plugins, and all of a sudden this is happening.
- The topic ‘Database error when adding new posts’ is closed to new replies.