From 1f3b3fada6f662c4a8f43519dac7b1683c350da4 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sun, 10 Jun 2012 01:26:12 +0000 Subject: [PATCH] Make sure the path exists before copying. see #20657 git-svn-id: https://develop.svn.wordpress.org/trunk@21039 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/image.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 0a5cf1817f..8048387677 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -448,6 +448,11 @@ function _copy_image_file( $attachment_id ) { if ( $src_file ) { $dst_file = str_replace( basename( $dst_file ), 'copy-' . basename( $dst_file ), $dst_file ); $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) ); + + // The directory containing the original file may no longer exist when + // using a replication plugin. + wp_mkdir_p( dirname( $dst_file ) ); + if ( ! @copy( $src_file, $dst_file ) ) $dst_file = false; } else {