Skip to content

Commit 3a0383c

Browse files
committed
nicer calling syntax for queryAllRecords
1 parent d296003 commit 3a0383c

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

server/lib/classes/backup.inc.php

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -734,41 +734,38 @@ protected static function backups_garbage_collection($server_id, $backup_type =
734734
global $app;
735735

736736
//First check that all records in database have related files and delete records without files on disk
737-
$args = array();
738-
$args_domains = array();
739-
$args_domains_with_backups = array();
737+
$args_sql = array();
738+
$args_sql_domains = array();
739+
$args_sql_domains_with_backups = array();
740740
$server_config = $app->getconf->get_server_config($server_id, 'server');
741741
$backup_dir = trim($server_config['backup_dir']);
742742
$sql = "SELECT * FROM web_backup WHERE server_id = ?";
743743
$sql_domains = "SELECT domain_id,document_root,system_user,system_group,backup_interval FROM web_domain WHERE server_id = ? AND (type = 'vhost' OR type = 'vhostsubdomain' OR type = 'vhostalias')";
744744
$sql_domains_with_backups = "SELECT domain_id,document_root,system_user,system_group,backup_interval FROM web_domain WHERE domain_id in (SELECT parent_domain_id FROM web_backup WHERE server_id = ?" . ((!empty($backup_type)) ? " AND backup_type = ?" : "") . ") AND (type = 'vhost' OR type = 'vhostsubdomain' OR type = 'vhostalias')";
745-
array_push($args, $server_id);
746-
array_push($args_domains, $server_id);
747-
array_push($args_domains_with_backups, $server_id);
745+
array_push($args_sql, $server_id);
746+
array_push($args_sql_domains, $server_id);
747+
array_push($args_sql_domains_with_backups, $server_id);
748748
if (!empty($backup_type)) {
749749
$sql .= " AND backup_type = ?";
750-
array_push($args, $backup_type);
751-
array_push($args_domains_with_backups, $backup_type);
750+
array_push($args_sql, $backup_type);
751+
array_push($args_sql_domains_with_backups, $backup_type);
752752
}
753753
if (!empty($domain_id)) {
754754
$sql .= " AND parent_domain_id = ?";
755755
$sql_domains .= " AND domain_id = ?";
756756
$sql_domains_with_backups .= " AND domain_id = ?";
757-
array_push($args, $domain_id);
758-
array_push($args_domains, $domain_id);
759-
array_push($args_domains_with_backups, $domain_id);
757+
array_push($args_sql, $domain_id);
758+
array_push($args_sql_domains, $domain_id);
759+
array_push($args_sql_domains_with_backups, $domain_id);
760760
}
761-
array_unshift($args, $sql);
762-
array_unshift($args_domains, $sql_domains);
763-
array_unshift($args_domains_with_backups, $sql_domains_with_backups);
764761

765762
$db_list = array($app->db);
766763
if ($app->db->dbHost != $app->dbmaster->dbHost)
767764
array_push($db_list, $app->dbmaster);
768765

769766
// Cleanup web_backup entries for non-existent backup files
770767
foreach ($db_list as $db) {
771-
$backups = call_user_func_array(array($db, "queryAllRecords"), $args);
768+
$backups = $app->db->queryAllRecords($sql, true, $args_sql);
772769
foreach ($backups as $backup) {
773770
$backup_file = $backup_dir . '/web' . $backup['parent_domain_id'] . '/' . $backup['filename'];
774771
if (!is_file($backup_file)) {
@@ -780,7 +777,7 @@ protected static function backups_garbage_collection($server_id, $backup_type =
780777
}
781778

782779
// Cleanup backup files with missing web_backup entries (runs on all servers)
783-
$domains = call_user_func_array(array($app->dbmaster, "queryAllRecords"), $args_domains_with_backups);
780+
$domains = $app->dbmaster->queryAllRecords($sql_domains_with_backups, true, $args_sql_domains_with_backups);
784781
foreach ($domains as $rec) {
785782
$domain_id = $rec['domain_id'];
786783
$domain_backup_dir = $backup_dir . '/web' . $domain_id;
@@ -808,7 +805,7 @@ protected static function backups_garbage_collection($server_id, $backup_type =
808805
}
809806

810807
// This cleanup only runs on web servers
811-
$domains = call_user_func_array(array($app->db, "queryAllRecords"), $args_domains);
808+
$domains = $app->db->queryAllRecords($sql_domains, true, $args_sql_domains);
812809
foreach ($domains as $rec) {
813810
$domain_id = $rec['domain_id'];
814811
$domain_backup_dir = $backup_dir . '/web' . $domain_id;

0 commit comments

Comments
 (0)