Make WordPress Core


Ignore:
Timestamp:
03/01/2013 04:28:40 PM (13 years ago)
Author:
ryan
Message:

Revert 23416, 23419, 23445 except for wp_reset_vars() changes. We are going a different direction with the slashing cleanup, so resetting to a clean slate. see #21767

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r23531 r23554  
    16781678 *
    16791679 * @param int $post_id Post ID.
    1680  * @param string $meta_key Metadata name (expected slashed).
    1681  * @param mixed $meta_value Metadata value (expected slashed).
     1680 * @param string $meta_key Metadata name.
     1681 * @param mixed $meta_value Metadata value.
    16821682 * @param bool $unique Optional, default is false. Whether the same key should not be added.
    16831683 * @return bool False for failure. True for success.
    16841684 */
    1685 function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
    1686     //_deprecated_function( __FUNCTION__, '3.6', 'wp_add_post_meta() (expects unslashed data)' );
    1687 
    1688     // expected slashed
    1689     $meta_key = stripslashes( $meta_key );
    1690     $meta_value = stripslashes_deep( $meta_value );
    1691 
    1692     return wp_add_post_meta( $post_id, $meta_key, $meta_value, $unique );
    1693 }
    1694 
    1695 /**
    1696  * Add meta data field to a post.
    1697  *
    1698  * Post meta data is called "Custom Fields" on the Administration Screen.
    1699  *
    1700  * @since 3.6.0
    1701  * @link http://codex.wordpress.org/Function_Reference/wp_add_post_meta
    1702  *
    1703  * @param int $post_id Post ID.
    1704  * @param string $meta_key Metadata name (clean, slashes already stripped).
    1705  * @param mixed $meta_value Metadata value (clean, slashes already stripped).
    1706  * @param bool $unique Optional, default is false. Whether the same key should not be added.
    1707  * @return bool False for failure. True for success.
    1708  */
    1709 function wp_add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
     1685function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) {
    17101686    // make sure meta is added to the post, not a revision
    1711     if ( $the_post = wp_is_post_revision( $post_id ) )
     1687    if ( $the_post = wp_is_post_revision($post_id) )
    17121688        $post_id = $the_post;
    17131689
    1714     return add_metadata( 'post', $post_id, $meta_key, $meta_value, $unique );
     1690    return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
    17151691}
    17161692
     
    17691745 *
    17701746 * @param int $post_id Post ID.
    1771  * @param string $meta_key Metadata key (expected slashed).
    1772  * @param mixed $meta_value Metadata value (expected slashed).
     1747 * @param string $meta_key Metadata key.
     1748 * @param mixed $meta_value Metadata value.
    17731749 * @param mixed $prev_value Optional. Previous value to check before removing.
    17741750 * @return bool False on failure, true if success.
    17751751 */
    1776 function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
    1777     //_deprecated_function( __FUNCTION__, '3.6', 'wp_update_post_meta() (expects unslashed data)' );
    1778 
    1779     // expected slashed
    1780     $meta_key = stripslashes( $meta_key );
    1781     $meta_value = stripslashes_deep( $meta_value );
    1782 
    1783     return wp_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value );
    1784 }
    1785 
    1786 /**
    1787  * Update post meta field based on post ID.
    1788  *
    1789  * Use the $prev_value parameter to differentiate between meta fields with the
    1790  * same key and post ID.
    1791  *
    1792  * If the meta field for the post does not exist, it will be added.
    1793  *
    1794  * @since 3.6.0
    1795  * @uses $wpdb
    1796  * @link http://codex.wordpress.org/Function_Reference/wp_update_post_meta
    1797  *
    1798  * @param int $post_id Post ID.
    1799  * @param string $meta_key Metadata key (clean, slashes already stripped).
    1800  * @param mixed $meta_value Metadata value (clean, slashes already stripped).
    1801  * @param mixed $prev_value Optional. Previous value to check before removing.
    1802  * @return bool False on failure, true if success.
    1803  */
    1804 function wp_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
     1752function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
    18051753    // make sure meta is added to the post, not a revision
    1806     if ( $the_post = wp_is_post_revision( $post_id ) )
     1754    if ( $the_post = wp_is_post_revision($post_id) )
    18071755        $post_id = $the_post;
    18081756
    1809     return update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value );
     1757    return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
    18101758}
    18111759
     
    23942342    do_action('wp_trash_post', $post_id);
    23952343
    2396     wp_add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
    2397     wp_add_post_meta($post_id,'_wp_trash_meta_time', time());
     2344    add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
     2345    add_post_meta($post_id,'_wp_trash_meta_time', time());
    23982346
    23992347    $post['post_status'] = 'trash';
     
    24712419    foreach ( $comments as $comment )
    24722420        $statuses[$comment->comment_ID] = $comment->comment_approved;
    2473     wp_add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
     2421    add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
    24742422
    24752423    // Set status for all comments to post-trashed
     
    28472795    $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
    28482796
     2797    // expected_slashed (everything!)
    28492798    $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) );
    28502799    $data = apply_filters('wp_insert_post_data', $data, $postarr);
     2800    $data = stripslashes_deep( $data );
    28512801    $where = array( 'ID' => $post_ID );
    28522802
     
    28612811    } else {
    28622812        if ( isset($post_mime_type) )
    2863             $data['post_mime_type'] = $post_mime_type; // This isn't in the update
     2813            $data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update
    28642814        // If there is a suggested ID, use it if not already present
    28652815        if ( !empty($import_id) ) {
     
    29222872                return 0;
    29232873        }
    2924         wp_update_post_meta($post_ID, '_wp_page_template',  $page_template);
     2874        update_post_meta($post_ID, '_wp_page_template',  $page_template);
    29252875    }
    29262876
     
    29552905        // non-escaped post was passed
    29562906        $postarr = get_object_vars($postarr);
     2907        $postarr = add_magic_quotes($postarr);
    29572908    }
    29582909
    29592910    // First, get all of the original fields
    29602911    $post = get_post($postarr['ID'], ARRAY_A);
     2912
     2913    // Escape data pulled from DB.
     2914    $post = add_magic_quotes($post);
    29612915
    29622916    // Passed post category list overwrites existing category list if not empty.
     
    33973351        foreach( (array) $trackback_urls as $tb_url) {
    33983352            $tb_url = trim($tb_url);
    3399             trackback($tb_url, $post_title, $excerpt, $post_id);
     3353            trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
    34003354        }
    34013355    }
     
    37403694        $join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";
    37413695
     3696        // meta_key and meta_value might be slashed
     3697        $meta_key = stripslashes($meta_key);
     3698        $meta_value = stripslashes($meta_value);
    37423699        if ( ! empty( $meta_key ) )
    37433700            $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key);
     
    39643921        $post_name = sanitize_title($post_name);
    39653922
     3923    // expected_slashed ($post_name)
    39663924    $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
    39673925
     
    40063964        $pinged = '';
    40073965
     3966    // expected_slashed (everything!)
    40083967    $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' ) );
     3968    $data = stripslashes_deep( $data );
    40093969
    40103970    if ( $update ) {
     
    40514011
    40524012    if ( ! empty( $context ) )
    4053         wp_add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
     4013        add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
    40544014
    40554015    if ( $update) {
     
    44384398    // if we haven't added this old slug before, add it now
    44394399    if ( !empty( $post_before->post_name ) && !in_array($post_before->post_name, $old_slugs) )
    4440         wp_add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
     4400        add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
    44414401
    44424402    // if the new slug was used previously, delete it from the list
     
    48554815
    48564816    if ( get_option('default_pingback_flag') )
    4857         wp_add_post_meta( $post_id, '_pingme', '1' );
    4858     wp_add_post_meta( $post_id, '_encloseme', '1' );
     4817        add_post_meta( $post_id, '_pingme', '1' );
     4818    add_post_meta( $post_id, '_encloseme', '1' );
    48594819
    48604820    wp_schedule_single_event(time(), 'do_pings');
     
    49344894    if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
    49354895        if ( $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
    4936             return wp_update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
     4896            return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
    49374897        else
    49384898            return delete_post_meta( $post->ID, '_thumbnail_id' );
Note: See TracChangeset for help on using the changeset viewer.