# Bug in changing post ownership

**URL:** https://meta.discourse.org/t/bug-in-changing-post-ownership/70873
**Category:** Bug
**Created:** [27 september 2017 om 14:31 UTC](https://meta.discourse.org/t/bug-in-changing-post-ownership/70873 "2017-09-27T14:31:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [27 september 2017 om 14:31 UTC](https://meta.discourse.org/t/bug-in-changing-post-ownership/70873/1 "2017-09-27T14:31:54Z")

</div>

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:

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/4/74c553c8fe566fa77c25ecf8d4d311b04cbbcdce.png)

This cannot be right…

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [27 september 2017 om 14:46 UTC](https://meta.discourse.org/t/bug-in-changing-post-ownership/70873/2 "2017-09-27T14:46:10Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)
#### Post date: [27 september 2017 om 14:57 UTC](https://meta.discourse.org/t/bug-in-changing-post-ownership/70873/3 "2017-09-27T14:57:12Z")

</div>

> <https://github.com/discourse/discourse/blob/0fca5ed533a123d75c45c84375199ac2079c9ca3/app/assets/javascripts/discourse/controllers/topic.js.es6#L682-L685>

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`.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [13 december 2017 om 21:45 UTC](https://meta.discourse.org/t/bug-in-changing-post-ownership/70873/5 "2017-12-13T21:45:49Z")

</div>

Just pushed a fix 🍔

[https://github.com/discourse/discourse/commit/c63ecd87f20feb50146633fde3a3e51c277dfba0](https://github.com/discourse/discourse/commit/c63ecd87f20feb50146633fde3a3e51c277dfba0)

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [16 december 2017 om 23:00 UTC](https://meta.discourse.org/t/bug-in-changing-post-ownership/70873/6 "2017-12-16T23:00:01Z")

</div>

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