Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Warning \Doctrine\ORM\QueryBuilder::where #11264

Closed
mmross opened this issue Feb 16, 2024 · 1 comment
Closed

PHP Warning \Doctrine\ORM\QueryBuilder::where #11264

mmross opened this issue Feb 16, 2024 · 1 comment

Comments

@mmross
Copy link

mmross commented Feb 16, 2024

Bug Report (PHP Warning)

Q A
BC Break no
Version 3.0.0

Summary

After upgrading to doctrine/orm 3.0.0 we found PHP Warnings.
PHP Warning: Undefined array key 0 in /var/www/html/vendor/doctrine/orm/src/QueryBuilder.php on line 954

Current behavior

$qb = $this->getEntityManager()->createQueryBuilder();
        $qb
            ->delete(delete: Foo::class, alias: 'foo')
            ->where(predicates: $qb->expr()->lt('foo.creationDate', ':creationDate'));

Inside of the where method

if (! (count($predicates) === 1 && $predicates[0] instanceof Expr\Composite)) {
            $predicates = new Expr\Andx($predicates);
        }

the value of $predicates is in this example an array like this

array(1) {
  ["predicates"]=>
  object(Doctrine\ORM\Query\Expr\Comparison)#921 (3) {
    ["leftExpr":protected]=>
    string(14) "ael.occurredAt"
    ["operator":protected]=>
    string(1) "<"
    ["rightExpr":protected]=>
    string(11) ":occurredAt"
  }
}

And this logic will throw the php warning.

Expected behavior

No PHP Warnings
It would be better to check that this value is an array and that key exists with the php method array_key_exists.

I can prepare a solution for this if I don't overlook anything about using the where method.

@derrabus
Copy link
Member

Duplicate of #11253

@derrabus derrabus marked this as a duplicate of #11253 Feb 16, 2024
@derrabus derrabus closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants