]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(querybuilder): Log a warning if where() is called again on a query builder object 36261/head
authorJoas Schilling <coding@schilljs.com>
Fri, 20 Jan 2023 06:41:19 +0000 (07:41 +0100)
committerJoas Schilling <coding@schilljs.com>
Fri, 20 Jan 2023 06:41:19 +0000 (07:41 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/DB/QueryBuilder/QueryBuilder.php

index e81ba61b3a76a631cb86bd9e2b38fe3898673a7d..9713410806e68a51e4871b5834e872a6053ed4fe 100644 (file)
@@ -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