laravel/framework

Inconsistent orWhere behavior after upgrade from Laravel 10.x to 13.x

Ouverte

#59 516 ouverte le 3 avr. 2026

 (4 commentaires) (0 réaction) (0 personne assignée)PHP (11 951 forks)batch import
help wanted

Métriques du dépôt

Stars
 (34 872 étoiles)
Métriques de merge PR
 (Merge moyen 1j 22h) (129 PRs mergées en 30 j)

Description

Laravel Version

v13.2.0

PHP Version

8.3.30

Database Driver & Version

mariadb Ver 15.1 on arm64 (Homebrew)

Description

When doing something along the lines of:

$query
                        ->where([
                            ['source_type', '=', Role::class],
                            ['source_id', '=', $obj->guestRole->id],
                        ])
                        ->orWhere([
                            ['source_type', '=', Group::class],
                            ['source_id', '=', $obj->loggedOutGroup->id],
                        ]);

previously, it would generate a conditional with:

(source_type=? AND source_id=?) OR (source_type=? AND source_id=?)

After the upgrade to Laravel 13 it's now generating the following conditional (note the OR in the second block):

(source_type=? AND source_id=?) OR (source_type=? OR source_id=?)

While looking into this I discovered #53184 from 11.28 causing this issue. However, it says it was fixed in #53197 but I'm still seeing this behavior in 13.x

Steps To Reproduce

$query
                        ->where([
                            ['source_type', '=', Role::class],
                            ['source_id', '=', $obj->guestRole->id],
                        ])
                        ->orWhere([
                            ['source_type', '=', Group::class],
                            ['source_id', '=', $obj->loggedOutGroup->id],
                        ]);

Use this as a conditional

Guide contributeur