Browse Source

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…
tags/v26.0.0beta1
Joas Schilling 1 year ago
parent
commit
ecad09b38a
No account linked to committer's email address
1 changed files with 6 additions and 0 deletions
  1. 6
    0
      lib/private/DB/QueryBuilder/QueryBuilder.php

+ 6
- 0
lib/private/DB/QueryBuilder/QueryBuilder.php 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

Loading…
Cancel
Save