Skip to content

Commit 4fc12e9

Browse files
committed
Merge branch 'develop' for v3.7.1
2 parents 420d131 + 7e610e4 commit 4fc12e9

File tree

2 files changed

+261
-32
lines changed

2 files changed

+261
-32
lines changed

src/clone/clone-utils.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,37 @@ function copy_site_certs( Site $source, Site $destination ) {
132132

133133
function copy_site_files( Site $source, Site $destination, array $sync_type ) {
134134

135-
$exclude = '--exclude \'/wp-config.php\'';
136-
$source_public_path = str_replace( '/var/www/htdocs', '', $source->site_details['site_container_fs_path'] );
137-
$uploads_path = $source_public_path . '/wp-content/uploads';
138-
$uploads_path_share = '/shared/wp-content/uploads';
135+
$source_public_path = str_replace( '/var/www/htdocs', '', $source->site_details['site_container_fs_path'] );
136+
$destination_public_path = str_replace( '/var/www/htdocs', '', $destination->site_details['site_container_fs_path'] );
137+
138+
$exclude = '--exclude \'/wp-config.php\'';
139+
140+
// Exclude wp-config.php from source's custom public directory structure.
141+
// rsync --exclude patterns are relative to the source directory being synced.
142+
if ( ! empty( $source_public_path ) ) {
143+
$exclude .= ' --exclude \'' . $source_public_path . '/wp-config.php\'';
144+
145+
// Also exclude wp-config.php one level up from public directory (WordPress convention).
146+
$parent_dir = dirname( $source_public_path );
147+
if ( $parent_dir !== '.' && $parent_dir !== '/' ) {
148+
$exclude .= ' --exclude \'' . $parent_dir . '/wp-config.php\'';
149+
}
150+
}
151+
152+
$source_uploads_path = $source_public_path . '/wp-content/uploads';
153+
$destination_uploads_path = $destination_public_path . '/wp-content/uploads';
154+
$uploads_path_share = '/shared/wp-content/uploads';
139155

140156
$source_dir = remove_trailing_slash( $source->get_site_root_dir() );
141157
$destination_dir = remove_trailing_slash( $destination->get_site_root_dir() );
142158

143159
if ( $sync_type['uploads'] && ! $sync_type['files'] ) {
144-
$source_dir .= $uploads_path;
145-
$destination_dir .= $uploads_path;
160+
$source_dir .= $source_uploads_path;
161+
$destination_dir .= $destination_uploads_path;
146162
}
147163

148164
if ( $sync_type['files'] && ! $sync_type['uploads'] ) {
149-
$exclude .= ' --exclude \'' . $uploads_path . '\'';
165+
$exclude .= ' --exclude \'' . $source_uploads_path . '\'';
150166
$exclude .= ' --exclude \'' . $uploads_path_share . '\'';
151167
}
152168

0 commit comments

Comments
 (0)