fixes #1616 handle backticked rank column in conf.order_by setting

This commit is contained in:
plegall
2022-02-25 14:22:39 +01:00
parent 84a7845dbd
commit 78e9d516b1
2 changed files with 14 additions and 1 deletions

View File

@@ -178,7 +178,7 @@ if (isset($_POST['submit']))
$order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2));
// there is no rank outside categories
if ( ($i = array_search('rank ASC', $order_by)) !== false)
if ( ($i = array_search('`rank` ASC', $order_by)) !== false)
{
unset($order_by[$i]);
}

View File

@@ -141,6 +141,19 @@ ImageStdParams::load_from_db();
session_start();
load_plugins();
// 2022-02-25 due to escape on "rank" (becoming a mysql keyword in version 8), the $conf['order_by'] might
// use a "rank", even if admin/configuration.php should have removed it. We must remove it.
// TODO remove this data update as soon as 2025 arrives
if (preg_match('/(, )?`rank` ASC/', $conf['order_by']))
{
$order_by = preg_replace('/(, )?`rank` ASC/', '', $conf['order_by']);
if ('ORDER BY ' == $order_by)
{
$order_by = 'ORDER BY id ASC';
}
conf_update_param('order_by', $order_by, true);
}
// users can have defined a custom order pattern, incompatible with GUI form
if (isset($conf['order_by_custom']))
{