Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/clone/clone-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,34 @@ function copy_site_certs( Site $source, Site $destination ) {

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

$exclude = '--exclude \'/wp-config.php\'';
$source_public_path = str_replace( '/var/www/htdocs', '', $source->site_details['site_container_fs_path'] );
$uploads_path = $source_public_path . '/wp-content/uploads';
$uploads_path_share = '/shared/wp-content/uploads';
$source_public_path = str_replace( '/var/www/htdocs', '', $source->site_details['site_container_fs_path'] );
$destination_public_path = str_replace( '/var/www/htdocs', '', $destination->site_details['site_container_fs_path'] );

$exclude = '--exclude \'/wp-config.php\'';

if ( ! empty( $destination_public_path ) ) {
$exclude .= ' --exclude \'' . $destination_public_path . '/wp-config.php\'';

$parent_dir = dirname( $destination_public_path );
if ( $parent_dir !== '.' && $parent_dir !== '/' ) {
$exclude .= ' --exclude \'' . $parent_dir . '/wp-config.php\'';
}
}
Comment on lines +140 to +147
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wp-config.php exclusion logic is using $destination_public_path but rsync --exclude patterns are relative to the source directory, not the destination. This should use $source_public_path instead to correctly exclude wp-config.php from the source site's custom public directory.

For example, if the source has a custom public path like /current/web, the exclusion should be --exclude '/current/wp-config.php' (based on source), not based on the destination path.

Notice that line 162 correctly uses $source_uploads_path for excluding uploads, following the same pattern.

Copilot uses AI. Check for mistakes.

$source_uploads_path = $source_public_path . '/wp-content/uploads';
$destination_uploads_path = $destination_public_path . '/wp-content/uploads';
$uploads_path_share = '/shared/wp-content/uploads';

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

if ( $sync_type['uploads'] && ! $sync_type['files'] ) {
$source_dir .= $uploads_path;
$destination_dir .= $uploads_path;
$source_dir .= $source_uploads_path;
$destination_dir .= $destination_uploads_path;
}

if ( $sync_type['files'] && ! $sync_type['uploads'] ) {
$exclude .= ' --exclude \'' . $uploads_path . '\'';
$exclude .= ' --exclude \'' . $source_uploads_path . '\'';
$exclude .= ' --exclude \'' . $uploads_path_share . '\'';
}

Expand Down