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: Determine if a post has a user before setting mention details #41

Merged
merged 2 commits into from
Mar 6, 2020

Conversation

oddjob79
Copy link
Contributor

@oddjob79 oddjob79 commented Feb 11, 2020

Fixes flarum/framework#1956 - ErrorException: Trying to get property 'display_name' of
non-object. ConfigureMentions::addPostId method set mention details
based on if there was an existing post. This caused an error if there
was an existing post, but the user who posted had been deleted. The
mention details are now only set if there is a user associated with the
post being mentioned.

Fixes #1956 - ErrorException: Trying to get property 'display_name' of 
non-object. ConfigureMentions::addPostId method set mention details 
based on if there was an existing post. This caused an error if there 
was an existing post, but the user who posted had been deleted. The 
mention details are now only set if there is a user associated with the 
post being mentioned.
@oddjob79
Copy link
Contributor Author

When mentioning a post written by a deleted user, the post->user property was null. This prompted an error when it attempted to set the displayname attribute to the post->user->displayname property.
Now, the logic will only attempt to set the mention properties if the post has an associated user, rather than if the post simply exists (which it does, even if the posting user has subsequently been deleted). Please feel free to message me if any questions.

@oddjob79 oddjob79 closed this Feb 11, 2020
@franzliedke
Copy link
Contributor

@oddjob79 Did you close this on purpose? 🤔

@oddjob79
Copy link
Contributor Author

@franzliedke No, sorry about that. I thought it didn't go quite right.

@oddjob79 oddjob79 reopened this Feb 12, 2020
src/ConfigureMentions.php Outdated Show resolved Hide resolved
@oddjob79
Copy link
Contributor Author

oddjob79 commented Feb 15, 2020

FYI - log showing error mentioned in the change log

When changing the display_name attribute, there was an error produced when attempting to restore a deleted post which mentioned a deleted user.

flarum-2020-02-15.log

@franzliedke franzliedke merged commit b2c55e2 into flarum:master Mar 6, 2020
@franzliedke
Copy link
Contributor

@oddjob79 Congrats on getting your first PR merged, thanks for sending it in the first place and sorry for taking so long! 😍

@franzliedke
Copy link
Contributor

franzliedke commented Mar 6, 2020

P.S.: Feel free to submit an issue about that other problem you encountered.

askvortsov1 pushed a commit that referenced this pull request Mar 11, 2022
Fixes #1956 - ErrorException: Trying to get property 'display_name' of 
non-object. ConfigureMentions::addPostId method set mention details 
based on if there was an existing post. This caused an error if there 
was an existing post, but the user who posted had been deleted. The 
mention details are now only set if there is a user associated with the 
post being mentioned.
askvortsov1 pushed a commit that referenced this pull request May 10, 2022
Fixes #1956 - ErrorException: Trying to get property 'display_name' of 
non-object. ConfigureMentions::addPostId method set mention details 
based on if there was an existing post. This caused an error if there 
was an existing post, but the user who posted had been deleted. The 
mention details are now only set if there is a user associated with the 
post being mentioned.
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.

[Mentions] ErrorException: Trying to get property 'display_name' of non-object
2 participants