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

update a user's comment count after deleting a discussion #2472

Merged

Conversation

slkrx
Copy link
Contributor

@slkrx slkrx commented Nov 29, 2020

Fixes #2227

Changes proposed in this pull request:
Remove type hinting from the updateCommentsCount() function in order to allow it to accept a Post or a Discussion as an argument. This allows you to call updateCommentsCount() from the whenDiscussionWasDeleted() listener.

The Post class is no longer used in this file, so I removed the use directive at the top of this file.

Reviewers should focus on:
Without union types, there aren't many options for allowing a function to accept two different types of arguments. However, the only other option I could think of other than the one I proposed here is having two arguments with two different types that both default to null. Let me know if there is a better option!

Confirmed

  • Backend changes: tests are green (run composer test).

Also, I noticed that if you delete the last post in the discussion, it deletes the discussion, but it does not update the user's discussion count. Should I create a separate issue for that?

@slkrx slkrx marked this pull request as ready for review November 29, 2020 02:07
src/User/UserMetadataUpdater.php Outdated Show resolved Hide resolved
@askvortsov1 askvortsov1 self-requested a review November 29, 2020 03:01
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.

comment_count doesn't get updated when deleting a discussion
3 participants