Merge pull request #36261 from nextcloud/techdebt/noid/warn-devs-about-potential-bugs

fix(querybuilder): Log a warning if where() is called again on a quer…
This commit is contained in:
Joas Schilling 2023-01-23 18:47:25 +01:00 committed by GitHub
commit ecad09b38a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -864,6 +864,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