Index: wp-includes/functions.php =================================================================== --- wp-includes/functions.php (revision 12570) +++ wp-includes/functions.php (working copy) @@ -1107,8 +1107,7 @@ /** * Check content for video and audio links to add as enclosures. * - * Will not add enclosures that have already been added and will - * remove enclosures that are no longer in the post. This is called as + * Will not add enclosures that have already been added. This is called as * pingbacks and trackbacks. * * @package WordPress @@ -1139,15 +1138,6 @@ debug_fwrite( $log, 'Post contents:' ); debug_fwrite( $log, $content . "\n" ); - foreach ( $pung as $link_test ) { - if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post - $mid = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $link_test . '%') ); - do_action( 'delete_postmeta', $mid ); - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id IN(%s)", implode( ',', $mid ) ) ); - do_action( 'deleted_postmeta', $mid ); - } - } - foreach ( (array) $post_links_temp[0] as $link_test ) { if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already $test = parse_url( $link_test ); @@ -1162,12 +1152,12 @@ if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%' ) ) ) { if ( $headers = wp_get_http_headers( $url) ) { $len = (int) $headers['content-length']; - $type = $headers['content-type']; + $type = $wpdb->escape( $headers['content-type'] ); $allowed_types = array( 'video', 'audio' ); if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { $meta_value = "$url\n$len\n$type\n"; - $wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) ); - do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, 'enclosure', $meta_value ); + $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` ) + VALUES ( %d, 'enclosure' , %s)", $post_ID, $meta_value ) ); } } }