Skip to content

Commit

Permalink
cdn push-type for wp subdir
Browse files Browse the repository at this point in the history
in WPMU subdir and common masterconfig usage path was containing blog
subdir which was not correct and caused 404 for assets other than
primary blog
  • Loading branch information
maxicus committed May 4, 2019
1 parent bb52ba6 commit 709030f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Cdn_Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ function get_files_for_upload( $file ) {
$file = $this->normalize_attachment_file( $file );

$local_file = $upload_info['basedir'] . '/' . $file;
$remote_file = ltrim( $upload_info['baseurlpath'] . $file, '/' );

$parsed = parse_url( rtrim( $upload_info['baseurl'], '/' ) .
'/' . $file );
$local_uri = $parsed['path'];
$remote_uri = $this->uri_to_cdn_uri( $local_uri );
$remote_file = ltrim( $remote_uri, '/' );

$files[] = $this->build_file_descriptor( $local_file, $remote_file );
}
Expand Down Expand Up @@ -713,8 +718,11 @@ function uri_to_cdn_uri( $local_uri ) {
!Util_Environment::is_wpmu_subdomain() &&
Util_Environment::is_using_master_config() &&
Cdn_Util::is_engine_push( $engine ) ) {
// in common config files are uploaded for network home url
// in common config mode files are uploaded for network home url
// so mirror will not contain /subblog/ path in uri
//
// since upload process is not blog-specific and
// wp-content/plugins/../*.jpg files are common
$home = trim( home_url( '', 'relative' ), '/' ) . '/';
$network_home = trim( network_home_url( '', 'relative' ), '/' ) . '/';

Expand Down

0 comments on commit 709030f

Please sign in to comment.