From 72573aa94160317c3ee34c3b779f37878fc1b966 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 12 Jun 2016 17:03:24 +0000 Subject: [PATCH] Not doing optimiziation when there is nothing to optimize. --- cron_db_cleanup.php | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/cron_db_cleanup.php b/cron_db_cleanup.php index 5e1f259c..268c2fe2 100644 --- a/cron_db_cleanup.php +++ b/cron_db_cleanup.php @@ -43,24 +43,26 @@ for ($i = 0; $i < $count; $i++) { $res = ttTeamHelper::delete($inactive_teams[$i]); } -$mdb2 = getConnection(); -$mdb2->exec("OPTIMIZE TABLE tt_client_project_binds"); -$mdb2->exec("OPTIMIZE TABLE tt_client_project_binds"); -$mdb2->exec("OPTIMIZE TABLE tt_clients"); -$mdb2->exec("OPTIMIZE TABLE tt_config"); -$mdb2->exec("OPTIMIZE TABLE tt_custom_field_log"); -$mdb2->exec("OPTIMIZE TABLE tt_custom_field_options"); -$mdb2->exec("OPTIMIZE TABLE tt_custom_fields"); -$mdb2->exec("OPTIMIZE TABLE tt_expense_items"); -$mdb2->exec("OPTIMIZE TABLE tt_fav_reports"); -$mdb2->exec("OPTIMIZE TABLE tt_invoices"); -$mdb2->exec("OPTIMIZE TABLE tt_log"); -$mdb2->exec("OPTIMIZE TABLE tt_project_task_binds"); -$mdb2->exec("OPTIMIZE TABLE tt_projects"); -$mdb2->exec("OPTIMIZE TABLE tt_tasks"); -$mdb2->exec("OPTIMIZE TABLE tt_teams"); -$mdb2->exec("OPTIMIZE TABLE tt_tmp_refs"); -$mdb2->exec("OPTIMIZE TABLE tt_user_project_binds"); -$mdb2->exec("OPTIMIZE TABLE tt_users"); +if ($count > 0) { + $mdb2 = getConnection(); + $mdb2->exec("OPTIMIZE TABLE tt_client_project_binds"); + $mdb2->exec("OPTIMIZE TABLE tt_client_project_binds"); + $mdb2->exec("OPTIMIZE TABLE tt_clients"); + $mdb2->exec("OPTIMIZE TABLE tt_config"); + $mdb2->exec("OPTIMIZE TABLE tt_custom_field_log"); + $mdb2->exec("OPTIMIZE TABLE tt_custom_field_options"); + $mdb2->exec("OPTIMIZE TABLE tt_custom_fields"); + $mdb2->exec("OPTIMIZE TABLE tt_expense_items"); + $mdb2->exec("OPTIMIZE TABLE tt_fav_reports"); + $mdb2->exec("OPTIMIZE TABLE tt_invoices"); + $mdb2->exec("OPTIMIZE TABLE tt_log"); + $mdb2->exec("OPTIMIZE TABLE tt_project_task_binds"); + $mdb2->exec("OPTIMIZE TABLE tt_projects"); + $mdb2->exec("OPTIMIZE TABLE tt_tasks"); + $mdb2->exec("OPTIMIZE TABLE tt_teams"); + $mdb2->exec("OPTIMIZE TABLE tt_tmp_refs"); + $mdb2->exec("OPTIMIZE TABLE tt_user_project_binds"); + $mdb2->exec("OPTIMIZE TABLE tt_users"); +} print "Done!
\n"; -- 2.20.1