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

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 and here

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

which sets previous_value to "" if the setting is false, and then

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

and

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

doesn’t do anything.

9 Likes

Here’s a PR:

4 Likes

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