From f60db45f44b63d5aa04121f711f6c1626b21b3fd Mon Sep 17 00:00:00 2001 From: ralf Date: Mon, 1 Jul 2024 10:26:53 +0200 Subject: [PATCH] do NOT fail with TypeError, if order_by is NULL, it's harmless ;) --- api/src/Storage/Base.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/Storage/Base.php b/api/src/Storage/Base.php index cbd2a490f3..32536e3720 100644 --- a/api/src/Storage/Base.php +++ b/api/src/Storage/Base.php @@ -1079,18 +1079,18 @@ class Base /** * Sanitize (currently just remove) not understood ORDER BY clause * - * @param string $fragment SQL fragment containing ORDER BY clause, could also contain GROUP BY etc + * @param ?string $fragment SQL fragment containing ORDER BY clause, could also contain GROUP BY etc * @return string sanitized version of $_order_by */ - static function sanitizeOrderBy(string $fragment) + static function sanitizeOrderBy(?string $fragment) { // check fragment contains ORDER BY --> just operate on what's behind - if (stripos($fragment,'ORDER BY') !== false) + if ($fragment && stripos($fragment,'ORDER BY') !== false) { [$group_by, $order_by] = preg_split('/order +by +/i', $fragment); } // check fragment not just contain GROUP BY or HAVING --> nothing to do - elseif ($fragment === '' || stripos($fragment,'GROUP BY')!==false || stripos($fragment,'HAVING')!==false) + elseif (empty($fragment) || stripos($fragment,'GROUP BY')!==false || stripos($fragment,'HAVING')!==false) { return $fragment; }