Bug in changing post ownership

AI-generated summary

The discussion highlights a bug in the post ownership change feature. When a user changes the ownership of a reply, the original topic owner is unexpectedly updated to the same user, which is incorrect. Additionally, there is a JavaScript issue where the selectedPosts array is not cleared when the ‘Change Ownership’ dialog is dismissed. This causes the number of selected posts to continuously increase, even when the dialog is closed repeatedly. The issue persists across different topics, and the only workaround is to reload the site. schungx identified the problem in the code and suggested clearing the selectedPosts array. zogstrip has since pushed a fix for the issue. schungx provided a link to the relevant code section where the bug occurs. schungx described the initial scenario that triggers the bug.

  1. New topic created by staged user via email in
  2. Somebody (A) replied
  3. Admin goes in and change ownership of that reply to somebody else (B)
  4. The first post (i.e. the topic) owner got changed to (B) as well

Also some change ownership strangeness:

This cannot be right…

3 Likes

Actually, the number of posts in the text Please choose the new owner of the [n] posts by... keeps increasing. From one to two to three and so on…

All you need is keep clicking on the Change Ownership button, bringing up the modal dialog, then dismissing it. It will keep adding posts to the list, even when you dismiss the dialog every time.

And worse, go out and click on another topic, and do the same. The numbers KEEP ADDING. The only way out of this is to reload the site.

Someone has forgotten to clear some array in JavaScript when the dialog is dismissed…

1 Like

I wonder whether selectedPosts should get cleared if the Change Ownership dialog is dismissed?

As it stands right now, it keeps adding into the list.

SelectedPostsCount assumes that all the selectedPosts all have the same user; if not, it chokes and show the above error for missing old_user.

1 Like

Just pushed a fix :hamburger:

https://github.com/discourse/discourse/commit/c63ecd87f20feb50146633fde3a3e51c277dfba0

3 Likes

This topic was automatically closed after 3 days. New replies are no longer allowed.