diff --git a/admin/configuration.php b/admin/configuration.php index 2e6fc0885..70ab9f215 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -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]); } diff --git a/include/common.inc.php b/include/common.inc.php index b67516e4c..e0081529b 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -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'])) {