Skip to content

Commit 6885ef7

Browse files
committed
Performance backup garbage collection potentially tries to delete same file multiple times
A cleaning task of backup.inc.php reads the file contents of a domains backup directory. Those get compared against web_backup database table. Backup filenames that should exist are read from web_backup table. If there are duplicates in that table, the temp array of files to delete will have them. The author wanted to remove those duplicates using array_unique. It never effectively was used, as this function does not receive the value by ref but returns a new value. This code will take the return value and use it in the comming loop which does the actual deletion. Rare case, keeping old code does not harm.
1 parent 0c43c06 commit 6885ef7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

server/lib/classes/backup.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,8 +1313,8 @@ protected static function backups_garbage_collection($server_id, $backup_type =
13131313
}
13141314
}
13151315
}
1316-
array_unique( $untracked_backup_files );
1317-
foreach ($untracked_backup_files as $f) {
1316+
$unique_untracked_backup_files = array_unique( $untracked_backup_files );
1317+
foreach ($unique_untracked_backup_files as $f) {
13181318
$backup_file = $backup_dir . '/web' . $domain_id . '/' . $f;
13191319
$app->log('Backup file ' . $backup_file . ' is not contained in database, deleting this file from disk', LOGLEVEL_DEBUG);
13201320
@unlink($backup_file);

0 commit comments

Comments
 (0)