From 2c8729d16d230e4ca6b7c0b0c1a08b298741e332 Mon Sep 17 00:00:00 2001 From: JediKev <kevin@enhancesoft.com> Date: Tue, 5 Sep 2017 12:17:59 -0500 Subject: [PATCH] cron: Optimize Lock Table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This addresses the MySQL syntax error regarding the lock table. On older osTicket databases we didn’t enforce having a prefix on the db tables. This means the lock table name would be 'lock' instead of 'ost_lock'. Cron runs an `OPTIMIZE TABLE` query on the lock table and if it has no prefix the query reads `OPTIMIZE TABLE lock;`. This is an issue because 'lock' is a MySQL Reserved Word and will throw an error. All you have to do is escape the table name with back ticks and MySQL won’t throw an error. --- include/class.cron.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/class.cron.php b/include/class.cron.php index e545c5afb..1db5a9f37 100644 --- a/include/class.cron.php +++ b/include/class.cron.php @@ -56,7 +56,7 @@ class Cron { $chance = rand(1,2000); switch ($chance) { case 42: - @db_query('OPTIMIZE TABLE '.LOCK_TABLE); + @db_query('OPTIMIZE TABLE `'.LOCK_TABLE.'`'); break; case 242: @db_query('OPTIMIZE TABLE '.SYSLOG_TABLE); -- GitLab