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: Check for null before attempting ->getRelations() #3382

Merged
merged 1 commit into from
Apr 7, 2022

Conversation

imorland
Copy link
Member

@imorland imorland commented Apr 7, 2022

Follows up on flarum/mentions#79

With this implementation, when a 3rd party extension uses the renderer for a user mention, and does not pass any context, an error occurs:

Call to a member function getRelations() on null in /opt/flarum/vendor/flarum/mentions/src/Formatter/FormatUserMentions.php:48

This is because isset does not first check that $context is not null, before attempting to evaluate ->getRelations()

This PR looks to address this. Locally tested.

Copy link
Member

@davwheat davwheat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@SychO9 SychO9 added this to the 1.3 milestone Apr 7, 2022
@SychO9 SychO9 merged commit b0fa795 into main Apr 7, 2022
@SychO9 SychO9 deleted the im/null-context-mention branch April 7, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants