From 7343389f7bf152651337975b4ab72d056bfd9ef6 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 23 Jan 2023 07:54:06 +0100 Subject: [PATCH] Correct the + symbol processing when sorting results in the API controllers (#1322) --- application/libraries/Api.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/application/libraries/Api.php b/application/libraries/Api.php index eebbb827..cc9484f4 100644 --- a/application/libraries/Api.php +++ b/application/libraries/Api.php @@ -216,15 +216,16 @@ class Api { { $api_field = substr($sort_token, 1); - $db_field = $this->model->db_field($api_field); - $direction_operator = substr($sort_token, 0, 1); if ( ! in_array($direction_operator, ['-', '+'])) { - throw new InvalidArgumentException('Invalid sort direction operator provided (expected "-" or "+"): ' . $direction_operator); + $direction_operator = '+'; + $api_field = $sort_token; } + $db_field = $this->model->db_field($api_field); + $direction = $direction_operator === '-' ? 'DESC' : 'ASC'; $order_by[] = $db_field . ' ' . $direction;