aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/QueryBuilder
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-01-20 07:41:19 +0100
committerJoas Schilling <coding@schilljs.com>2023-01-20 07:41:19 +0100
commit7f0a54c5581b3bde0f271d6e6a549076f14354dc (patch)
treecb1904d42039a2db231382e45b56a6228ded79d9 /lib/private/DB/QueryBuilder
parent5e3a3c0c8faa45489aa6ac610728b4177501c198 (diff)
downloadnextcloud-server-7f0a54c5581b3bde0f271d6e6a549076f14354dc.tar.gz
nextcloud-server-7f0a54c5581b3bde0f271d6e6a549076f14354dc.zip
fix(querybuilder): Log a warning if where() is called again on a query builder object
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/DB/QueryBuilder')
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index e81ba61b3a7..9713410806e 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -865,6 +865,12 @@ class QueryBuilder implements IQueryBuilder {
* @return $this This QueryBuilder instance.
*/
public function where(...$predicates) {
+ if ($this->getQueryPart('where') !== null && $this->systemConfig->getValue('debug', false)) {
+ // Only logging a warning, not throwing for now.
+ $e = new QueryException('Using where() on non-empty WHERE part, please verify it is intentional to not call whereAnd() or whereOr() instead. Otherwise consider creating a new query builder object or call resetQueryPart(\'where\') first.');
+ $this->logger->warning($e->getMessage(), ['exception' => $e]);
+ }
+
call_user_func_array(
[$this->queryBuilder, 'where'],
$predicates