WordPress.org

Make WordPress Core

Ticket #10511: 10511.2.diff

File 10511.2.diff, 2.3 KB (added by technosailor, 5 years ago)

I don't understand the issue, but here's the patch as a diff

  • wp-includes/functions.php

     
    11071107/** 
    11081108 * Check content for video and audio links to add as enclosures. 
    11091109 * 
    1110  * Will not add enclosures that have already been added and will 
    1111  * remove enclosures that are no longer in the post. This is called as 
     1110 * Will not add enclosures that have already been added. This is called as 
    11121111 * pingbacks and trackbacks. 
    11131112 * 
    11141113 * @package WordPress 
     
    11391138        debug_fwrite( $log, 'Post contents:' ); 
    11401139        debug_fwrite( $log, $content . "\n" ); 
    11411140 
    1142         foreach ( $pung as $link_test ) { 
    1143                 if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post 
    1144                         $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 . '%') ); 
    1145                         do_action( 'delete_postmeta', $mid ); 
    1146                         $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id IN(%s)", implode( ',', $mid ) ) ); 
    1147                         do_action( 'deleted_postmeta', $mid ); 
    1148                 } 
    1149         } 
    1150  
    11511141        foreach ( (array) $post_links_temp[0] as $link_test ) { 
    11521142                if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already 
    11531143                        $test = parse_url( $link_test ); 
     
    11621152                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 . '%' ) ) ) { 
    11631153                        if ( $headers = wp_get_http_headers( $url) ) { 
    11641154                                $len = (int) $headers['content-length']; 
    1165                                 $type = $headers['content-type']; 
     1155                                $type = $wpdb->escape( $headers['content-type'] ); 
    11661156                                $allowed_types = array( 'video', 'audio' ); 
    11671157                                if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { 
    11681158                                        $meta_value = "$url\n$len\n$type\n"; 
    1169                                         $wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) ); 
    1170                                         do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, 'enclosure', $meta_value ); 
     1159                                        $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` ) 
     1160                                        VALUES ( %d, 'enclosure' , %s)", $post_ID, $meta_value ) ); 
    11711161                                } 
    11721162                        } 
    11731163                }