Skip to content

[12.x] Fixed an issue when calling hasNested with a first relationship of type morphTo. #56512

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

Open
wants to merge 3 commits into
base: 12.x
Choose a base branch
from

Conversation

nicDamours
Copy link

@nicDamours nicDamours commented Aug 1, 2025

When calling the hasNested function with a string of relationship of which the first one was a morphTo, we had a Error: Call to a member function getRelationExistenceQuery() on null.

This is because the $relations array, in the hasNested function is passed by reference, but not reset between morph types.

The proposed solution is not perfect, but it works fine. I'm open to suggestion as I'm sure it can be a little bit more elegant.

Fixes #56490

Fixed an issue with hasNested fn when the first relation is a morphTo relationship. The `$relation` array was not reset, so we were calling the `has` with a null relation.
@nicDamours nicDamours changed the title Fixed Fixed the issue when calling hasNested with a first relationship of type morphTo. Aug 1, 2025
Nicolas D'Amours added 2 commits August 1, 2025 11:14
Fixed formatting issue from style-ci.
Fixed formatting issue from style-ci.
@nicDamours nicDamours changed the title Fixed the issue when calling hasNested with a first relationship of type morphTo. [12.x] Fixed the issue when calling hasNested with a first relationship of type morphTo. Aug 1, 2025
@nicDamours nicDamours changed the title [12.x] Fixed the issue when calling hasNested with a first relationship of type morphTo. [12.x] Fixed an issue when calling hasNested with a first relationship of type morphTo. Aug 1, 2025
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.

Unable to use hasNested with morphTo relationship
1 participant