WordPress.org

Make WordPress Core

Ticket #8309: 8309.1.diff

File 8309.1.diff, 1.6 KB (added by jacobsantos, 12 years ago)

Use path_join() function for fix.

  • post.php

     
    2121 * @since 2.0.0
    2222 * @uses apply_filters() Calls 'get_attached_file' on file path and attachment ID.
    2323 *
    24  * @param int $attachment_id Attachment ID
    25  * @param bool $unfiltered Whether to apply filters or not
     24 * @param int $attachment_id Attachment ID.
     25 * @param bool $unfiltered Whether to apply filters or not.
    2626 * @return string The file path to the attached file.
    2727 */
    2828function get_attached_file( $attachment_id, $unfiltered = false ) {
     
    24182418
    24192419        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
    24202420
     2421        $uploadPath = wp_upload_dir();
     2422
    24212423        if ( ! empty($meta['thumb']) ) {
    24222424                // Don't delete the thumb if another attachment uses it
    24232425                if (! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%'.$meta['thumb'].'%', $postid)) ) {
    24242426                        $thumbfile = str_replace(basename($file), $meta['thumb'], $file);
    24252427                        $thumbfile = apply_filters('wp_delete_file', $thumbfile);
    2426                         @ unlink($thumbfile);
     2428                        @ unlink( path_join($uploadPath['basedir'], $thumbfile) );
    24272429                }
    24282430        }
    24292431
     
    24322434        foreach ( $sizes as $size ) {
    24332435                if ( $intermediate = image_get_intermediate_size($postid, $size) ) {
    24342436                        $intermediate_file = apply_filters('wp_delete_file', $intermediate['path']);
    2435                         @ unlink($intermediate_file);
     2437                        @ unlink( path_join($uploadPath['basedir'], $intermediate_file) );
    24362438                }
    24372439        }
    24382440