If a saving a post fails, remove any invalid characters (such as emoji) from the primary text fields, then try to save it again.

See #21212.


Built from https://develop.svn.wordpress.org/trunk@30346


git-svn-id: http://core.svn.wordpress.org/trunk@30345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2014-11-14 21:34:22 +00:00
parent ecc27d0b27
commit e61bebdbfc
2 changed files with 15 additions and 2 deletions

View File

@ -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 );

View File

@ -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.