From 8a616886b0889b6c5273b1a069507d8f17f1dadb Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 18 Jun 2024 09:58:20 +0900 Subject: [PATCH 1/2] refactor: remove unneeded initialization --- system/Database/BaseBuilder.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index f9ca1efd4144..a4088c6c1eda 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -1448,11 +1448,12 @@ public function orHaving($key, $value = null, ?bool $escape = null) */ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = null) { - $qbOrderBy = []; if ($orderBy === '') { return $this; } + $qbOrderBy = []; + $direction = strtoupper(trim($direction)); if ($direction === 'RANDOM') { @@ -1474,8 +1475,6 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = 'escape' => false, ]; } else { - $qbOrderBy = []; - foreach (explode(',', $orderBy) as $field) { $qbOrderBy[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim($field), $match, PREG_OFFSET_CAPTURE)) ? [ From 4c0149939f8f12fa6778b4aea91b42c009c06297 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 18 Jun 2024 10:00:26 +0900 Subject: [PATCH 2/2] refactor: simplify if condition --- system/Database/BaseBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index a4088c6c1eda..4e6e422b2a6f 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -1464,7 +1464,7 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = $direction = in_array($direction, ['ASC', 'DESC'], true) ? ' ' . $direction : ''; } - if (! is_bool($escape)) { + if ($escape === null) { $escape = $this->db->protectIdentifiers; }