diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 142752dbc8..ec96749f46 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -177,6 +177,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { * @return int Post ID. */ function edit_post( $post_data = null ) { + global $wpdb; if ( empty($post_data) ) $post_data = &$_POST; @@ -317,7 +318,19 @@ function edit_post( $post_data = null ) { update_post_meta( $post_ID, '_edit_last', get_current_user_id() ); - wp_update_post( $post_data ); + $success = wp_update_post( $post_data ); + // If the save failed, see if we can sanity check the main fields and try again + if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) { + $fields = array( 'post_title', 'post_content', 'post_excerpt' ); + + foreach( $fields as $field ) { + if ( isset( $post_data[ $field ] ) ) { + $post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $post_data[ $field ] ); + } + } + + wp_update_post( $post_data ); + } // Now that we have an ID we can fix any attachment anchor hrefs _fix_attachment_links( $post_ID ); diff --git a/wp-includes/version.php b/wp-includes/version.php index d90898c479..3280838ad4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-alpha-30345'; +$wp_version = '4.1-alpha-30346'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.