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

[11.x] Use getQualifiedOwnerKeyName in relations #53573

Merged
merged 8 commits into from
Nov 19, 2024

Conversation

willtj
Copy link
Contributor

@willtj willtj commented Nov 19, 2024

This is another attempt at my change in #53559, to use the existing getQualifiedOwnerKeyName() method rather than assuming the format of table.column. As @crynobone noticed, that change revealed that the current code can end up passing a null value to str_contains(), which is deprecated.

I've added a null check to getQualifiedOwnerKeyName() so we don't attempt to qualify a null column. In the example of one of the tests that was throwing the deprecation notice (DatabaseEloquentIntegrationTest::testEmptyMorphToRelationship) this means that in practice the where query being added changes from $this->query->where('photos.', ...) to $this->query->where('', ...). The 'add constraints' methods could be updated to handle null values differently, but I'm hoping the change I have here should be the minimum required to fix the issue properly with the lowest risk to other areas.

@taylorotwell taylorotwell merged commit 8528d04 into laravel:11.x Nov 19, 2024
33 checks passed
crynobone added a commit that referenced this pull request Nov 20, 2024
…relationship will always return a `string`

Improvements based on #53573 PR

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
taylorotwell added a commit that referenced this pull request Nov 20, 2024
…relationship will always return a `string` (#53592)

* [11.x] Move `$ownerKey` check for `null` to `MorphTo` as `BelongsTo` relationship will always return a `string`

Improvements based on #53573 PR

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* formatting

---------

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
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

Successfully merging this pull request may close these issues.

2 participants