Page MenuHomePhabricator

SelectQueryBuilder::where() should not overwrite previous conditions
Closed, ResolvedPublic

Description

$builder->where( [ 'x' => [ 1, 2 ] ] );
$builder->andWhere( [ 'x' => [ 2, 3 ] ] );

The expected outcome is that WHERE x IN (1, 2) AND x IN (2, 3) but the actual outcome is WHERE x IN (2, 3) as array_merge overwrites the previous condition for the same field name. This is especially problematic when a query builder is passed into a hook or other extension-defined callback.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
daniel triaged this task as Medium priority.Aug 19 2021, 10:48 AM
daniel added a subscriber: tstarling.

Change 715633 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] SelectQueryBuilder: conflicting conditions should be passed through

https://gerrit.wikimedia.org/r/715633

Change 715633 merged by jenkins-bot:

[mediawiki/core@master] SelectQueryBuilder: conflicting conditions should be passed through

https://gerrit.wikimedia.org/r/715633

tstarling claimed this task.