WordPress.org

Make WordPress Core

Ticket #10656: 10656.patch

File 10656.patch, 1.5 KB (added by Sewar, 8 years ago)

Fixes the bug

  • wp-admin/includes/post.php

     
    559559
    560560        $metakeyselect = isset($_POST['metakeyselect']) ? stripslashes( trim( $_POST['metakeyselect'] ) ) : '';
    561561        $metakeyinput = isset($_POST['metakeyinput']) ? stripslashes( trim( $_POST['metakeyinput'] ) ) : '';
    562         $metavalue = isset($_POST['metavalue']) ? maybe_serialize( stripslashes( trim( $_POST['metavalue'] ) ) ) : '';
     562        if (isset($_POST['metavalue'])) {
     563                if (is_string($_POST['metavalue']) == true)
     564                        $_POST['metavalue'] = stripslashes( trim( $_POST['metavalue'] ) );
    563565
     566                $metavalue = maybe_serialize( $_POST['metavalue'] );
     567        } else {
     568                $metavalue = '';
     569        }
     570
    564571        if ( ('0' === $metavalue || !empty ( $metavalue ) ) && ((('#NONE#' != $metakeyselect) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput) ) ) {
    565572                // We have a key/value pair. If both the select and the
    566573                // input for the key have data, the input takes precedence:
     
    686693        $post_id = $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = %d", $meta_id) );
    687694        wp_cache_delete($post_id, 'post_meta');
    688695
    689         $meta_value = maybe_serialize( stripslashes( $meta_value ) );
     696        if (is_string($meta_value) == true)
     697                $meta_value = stripslashes( $meta_value );
     698
     699        $meta_value = maybe_serialize( $meta_value );
    690700        $meta_id = (int) $meta_id;
    691701
    692702        $data  = compact( 'meta_key', 'meta_value' );