From 7f0a54c5581b3bde0f271d6e6a549076f14354dc Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 20 Jan 2023 07:41:19 +0100 Subject: fix(querybuilder): Log a warning if where() is called again on a query builder object Signed-off-by: Joas Schilling --- lib/private/DB/QueryBuilder/QueryBuilder.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/private/DB/QueryBuilder') 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 -- cgit v1.2.3