# "Applying default user options historically" is a one way street

**URL:** https://meta.discourse.org/t/applying-default-user-options-historically-is-a-one-way-street/224039
**Category:** Bug
**Created:** [April 12, 2022, 1:19pm UTC](https://meta.discourse.org/t/applying-default-user-options-historically-is-a-one-way-street/224039 "2022-04-12T13:19:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [April 12, 2022, 1:19pm UTC](https://meta.discourse.org/t/applying-default-user-options-historically-is-a-one-way-street/224039/1 "2022-04-12T13:19:41Z")

</div>

When a default user option is set from false to true, it doesn’t behave like it should.  
It does not ask if the setting should be applied to existing users and even if it did, that wouldn’t work.

Repro:

- Have a setting like for instance “open external links in new tab” enabled
- Set admin - settings - user preferences - `default other external links in new tab` to enabled
- Set admin - settings - user preferences - `default other external links in new tab` to disabled
- Get a popup `Would you like to apply this change historically? This will change preferences for X existing users.` and choose Yes
- For all users the “open external links in new tab” is now disabled

So far so good, but:

- Set admin - settings - user preferences - `default other external links in new tab` to enabled
- Get no popup and it is still disabled for everyone.

Expected last step:

- Get a popup `Would you like to apply this change historically? This will change preferences for X existing users.` where choosing Yes would enable it for everyone

This goes for all `default_` user preferences.

This seems to be related to [here](https://github.com/discourse/discourse/blob/main/app/controllers/admin/site_settings_controller.rb#L37) and [here](https://github.com/discourse/discourse/blob/main/app/controllers/admin/site_settings_controller.rb#L132)

```plaintext
previous_value = SiteSetting.public_send(id) || "" if update_existing_users

```

which sets previous\_value to `""` if the setting is `false`, and then

```plaintext
UserOption.where(user_option => previous_value).update_all(attrs)

```

and

```plaintext
json[:user_count] = UserOption.where(user_option => previous_value).

```

doesn’t do anything.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [May 22, 2022, 9:03pm UTC](https://meta.discourse.org/t/applying-default-user-options-historically-is-a-one-way-street/224039/6 "2022-05-22T21:03:12Z")

</div>

Here’s a PR:

[https://github.com/discourse/discourse/pull/16890](https://github.com/discourse/discourse/pull/16890)

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [May 25, 2022, 9:03pm UTC](https://meta.discourse.org/t/applying-default-user-options-historically-is-a-one-way-street/224039/7 "2022-05-25T21:03:19Z")

</div>

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