From 3768d131ce7d34a8bca3876334d8cc158d46bc36 Mon Sep 17 00:00:00 2001 From: Dave Welch Date: Sun, 31 May 2020 10:12:08 +0100 Subject: [PATCH] add check to verify if remote uploads directory path is relative and convert it to absolute (fixes failed media files on relative paths) --- class/wpsdb-media-files.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/class/wpsdb-media-files.php b/class/wpsdb-media-files.php index e113671..23a9ee4 100644 --- a/class/wpsdb-media-files.php +++ b/class/wpsdb-media-files.php @@ -170,7 +170,13 @@ function ajax_migrate_media() { function process_pull_request() { $files_to_download = $_POST['file_chunk']; $remote_uploads_url = trailingslashit( $_POST['remote_uploads_url'] ); - $parsed = parse_url( $_POST['url'] ); + $parsed = parse_url( $_POST['url'] ); + + $relative_path_check = '/wp-content/'; + if ( substr($remote_uploads_url, 0, strlen($relative_path_check)) === $relative_path_check ){ + $remote_uploads_url = $parsed['scheme'] . '://' . $parsed['host'] . $remote_uploads_url; + } + if( ! empty( $parsed['user'] ) ) { $credentials = sprintf( '%s:%s@', $parsed['user'], $parsed['pass'] ); $remote_uploads_url = str_replace( '://', '://' . $credentials, $remote_uploads_url );