Skip to content

Commit 9d2f835

Browse files
committed
Another code simplification
Exact same effect: this complicated code was for replacing the last occurrence (there is no built-in function for this), and there is an englobing condition to ensure we replace the substring $op only if it is at the very end of $k. As a bonus, previous code was missing a preg_quote(), but we no longer need it.
1 parent 5a485e4 commit 9d2f835

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

system/Database/BaseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type
659659
$op = trim(current($op));
660660

661661
if (substr($k, -1 * strlen($op)) === $op) {
662-
$k = rtrim(strrev(preg_replace(strrev('/' . $op . '/'), strrev(''), strrev($k), 1)));
662+
$k = rtrim(substr($k, 0, -1 * strlen($op)));
663663
}
664664
$op = " {$op}";
665665
} else {

0 commit comments

Comments
 (0)