Make WordPress Core

Ticket #10511: has-patch.txt

File has-patch.txt, 2.3 KB (added by jamiefehr, 13 years ago)
Line 
1Index: wp-includes/functions.php
2===================================================================
3--- wp-includes/functions.php   (revision 12570)
4+++ wp-includes/functions.php   (working copy)
5@@ -1107,8 +1107,7 @@
6 /**
7  * Check content for video and audio links to add as enclosures.
8  *
9- * Will not add enclosures that have already been added and will
10- * remove enclosures that are no longer in the post. This is called as
11+ * Will not add enclosures that have already been added. This is called as
12  * pingbacks and trackbacks.
13  *
14  * @package WordPress
15@@ -1139,15 +1138,6 @@
16        debug_fwrite( $log, 'Post contents:' );
17        debug_fwrite( $log, $content . "\n" );
18 
19-       foreach ( $pung as $link_test ) {
20-               if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post
21-                       $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 . '%') );
22-                       do_action( 'delete_postmeta', $mid );
23-                       $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id IN(%s)", implode( ',', $mid ) ) );
24-                       do_action( 'deleted_postmeta', $mid );
25-               }
26-       }
27-
28        foreach ( (array) $post_links_temp[0] as $link_test ) {
29                if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
30                        $test = parse_url( $link_test );
31@@ -1162,12 +1152,12 @@
32                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 . '%' ) ) ) {
33                        if ( $headers = wp_get_http_headers( $url) ) {
34                                $len = (int) $headers['content-length'];
35-                               $type = $headers['content-type'];
36+                               $type = $wpdb->escape( $headers['content-type'] );
37                                $allowed_types = array( 'video', 'audio' );
38                                if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
39                                        $meta_value = "$url\n$len\n$type\n";
40-                                       $wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) );
41-                                       do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, 'enclosure', $meta_value );
42+                                       $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` )
43+                                       VALUES ( %d, 'enclosure' , %s)", $post_ID, $meta_value ) );
44                                }
45                        }
46                }