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

[5.5] WhereHas method blows up on PHP 7.3 when explicitly specifying an operator #25192

Closed
CyberiaResurrection opened this issue Aug 13, 2018 · 8 comments

Comments

@CyberiaResurrection
Copy link

  • Laravel Version: 5.5.42
  • PHP Version: 7.3.0beta1
  • Database Driver & Version: SQLite 3.24.0-1

Description:

Running a whereHas method off a hasMany relation blows up with:
ErrorException: compact(): Undefined variable: operator in file /var/www/testproject/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php on line 1243

Steps To Reproduce:

  1. Define a hasMany relation on a model. Ensure that the child model on the relation has at least one relation other than to the parent.
  2. Query the parent's hasMany relation - here's how I tripped over it:
$result = $parentModel->manyRelation()->whereHas('childOtherRelation', function ($query) use ($value) {
    $query->where('name', '=', $value);
})->firstOrFail();
  1. Execute that query under PHP 7.3. I tripped over this by running a test case.
  2. Bombs out with above error.

Looking at the chunk of code (addWhereExistsQuery in Query/Builder.php), I'm not seeing where $operator ever got defined.

@staudenmeir
Copy link
Contributor

This will be fixed in the next release.

@CyberiaResurrection
Copy link
Author

Sweet, thank you.

@CyberiaResurrection
Copy link
Author

That's running clean now.

@axdemelas
Copy link

axdemelas commented Jan 17, 2019

Just:

composer update

@dyusip
Copy link

dyusip commented May 24, 2019

Just:

composer update

you ruined my project. @ahlechandre

@rs-sliske
Copy link

Just:

composer update

you ruined my project. @ahlechandre

git checkout composer.lock
composer install

@jairdeon
Copy link

jairdeon commented Jun 1, 2019

@dyusip Thanks, it worked for me.
Can you answer why?

@fahimermo
Copy link

#26936

@jairdeon

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

7 participants