Make WordPress Core


Ignore:
Timestamp:
04/20/2015 11:51:13 AM (11 years ago)
Author:
pento
Message:

Merge the query sanity checks from #21212 to the 3.7 branch.

Props pento, nacin, mdawaffe, DrewAPicture.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7/src/wp-admin/includes/post.php

    r28115 r32188  
    167167 */
    168168function edit_post( $post_data = null ) {
     169    global $wpdb;
    169170
    170171    if ( empty($post_data) )
     
    296297    update_post_meta( $post_ID, '_edit_last', get_current_user_id() );
    297298
    298     wp_update_post( $post_data );
     299    $success = wp_update_post( $post_data );
     300    // If the save failed, see if we can sanity check the main fields and try again
     301    if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) {
     302        $fields = array( 'post_title', 'post_content', 'post_excerpt' );
     303
     304        foreach( $fields as $field ) {
     305            if ( isset( $post_data[ $field ] ) ) {
     306                $post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $post_data[ $field ] );
     307            }
     308        }
     309
     310        wp_update_post( $post_data );
     311    }
    299312
    300313    // Now that we have an ID we can fix any attachment anchor hrefs
Note: See TracChangeset for help on using the changeset viewer.