MySQL Error in v3.53 (Build 2265) for MySQL Version 8.0.19

3 posts by 3 authors in: Forums > CMS Builder
Last Post: April 22, 2020   (RSS)

By runriot - April 16, 2020 - edited: April 16, 2020

Hey

I'm running MySQL Version 8.0.19 and the background tasks menu was throwing a fatal MySQL error:

admin.php?menu=admin&action=bgtasks

Notice: MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'function = "{functionName}" ORDER BY num DESC LIMIT 1' at line 1 - in mysql_functions.php on line 210 by mysql_get_query() in /{path}/admin/lib/common.php on line 278

This is caused by 'function' being a MySQL Reserved Word

Fix:

admin/lib/menus/admin/backgroundTasks.php

line 293

Was:

$latestLog = mysql_get('_cron_log', null, ' function = "' .mysql_escape($record['function']). '" ORDER BY num DESC');

Now:

$latestLog = mysql_get('_cron_log', null, ' `function` = "' .mysql_escape($record['function']). '" ORDER BY num DESC');

i.e. addition of backticks around function

So effectively going from:

SELECT * FROM `cmsb__cron_log` WHERE function = "{functionName}" ORDER BY num DESC LIMIT 1;

to

SELECT * FROM `cmsb__cron_log` WHERE 'function' = "{functionName}" ORDER BY num DESC LIMIT 1;

Also need to apply the same fix to:

admin/cron.php

Line 108:

Was:

  $jobLastLogRecord = mysql_get('_cron_log', null, ' function = "' .mysql_escape($cron['function']). '" ORDER BY num DESC');

Now:

$jobLastLogRecord = mysql_get('_cron_log', null, ' `function` = "' .mysql_escape($cron['function']). '" ORDER BY num DESC');


I've manually updated my file, but I thought I'd share here in case anyone else has the same issue, and it would be great if this could be patched in the next version.

Cheers

Rob

By daniel - April 22, 2020

Hi runriot,

Thanks for reporting this fix! I've added the changes in to be included in the next official release.

Daniel
Technical Lead
interactivetools.com