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

Fix error when user()->first() is null in DiscussionBestAnswerPage.php #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexisrazok
Copy link

Fix to avoid error message when $discussion->user()->first() is null.

Fix to avoid error message when $discussion->user()->first() is null.
@jaspervriends
Copy link
Member

Hey @alexisrazok , thanks for the PR! I see Clark just replied with a different kind of solution as well in #101 (he doesn't have a PR), would you be able to check if that works and change your PR? Then I'll go ahead and merge the PR for you 😄

#101

@alexisrazok
Copy link
Author

yes @jaspervriends it works, I made a mistake in the other patch but this patch is right. Thank you.

@rafaucau
Copy link

rafaucau commented Nov 17, 2024

Since this hasn't been merged yet, I have opened a new pull request that includes several fixes, including this one:
#102


By the way, this can be simplified (PHP 8.0+) and optimized to avoid unnecessary database queries, because user is already loaded:

'author' => [
    "@type" => "Person",
    "name" => $discussion->user?->getDisplayNameAttribute()
],

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.

3 participants