⚓ T201340 Local notification settings stuck at latest global preference


Article Images

I ran an investigation to try and understand the impact of this, and what exactly happened. Here's the results (findings and recommendations at the end)

The situation before

To make the distinction between local and global better, I first enabled all of my CheckMatrix (Echo notifications) so that all checkboxes are true.

The database query reflects that:

19:00) vagrant@localhost:[wiki]> SELECT * FROM user_properties WHERE up_user=1 AND up_property LIKE 'echo-subscriptions%';
+---------+------------------------------------------+----------+
| up_user | up_property                              | up_value |
+---------+------------------------------------------+----------+
|       1 | echo-subscriptions-email-article-linked  | 1        |
|       1 | echo-subscriptions-email-edit-thank      | 1        |
|       1 | echo-subscriptions-email-flow-discussion | 1        |
|       1 | echo-subscriptions-email-mention         | 1        |
|       1 | echo-subscriptions-email-page-review     | 1        |
|       1 | echo-subscriptions-email-reverted        | 1        |
|       1 | echo-subscriptions-web-article-linked    | 1        |
+---------+------------------------------------------+----------+
7 rows in set (0.00 sec)

Then, I went to GlobalPreferences, and enabled the CheckMatrix (Echo notifications) but made sure to uncheck all of the 'web' notifications, so we can see if it overrides any data.

GlobalPreferences table

(19:05) vagrant@localhost:[centralauth]> SELECT * FROM global_preferences WHERE gp_user=1 AND gp_property LIKE 'echo-subscriptions%';
+---------+------------------------------------------+----------+
| gp_user | gp_property                              | gp_value |
+---------+------------------------------------------+----------+
|       1 | echo-subscriptions                       | 1        |
|       1 | echo-subscriptions-email-article-linked  | 0        |
|       1 | echo-subscriptions-email-edit-thank      | 0        |
|       1 | echo-subscriptions-email-edit-user-talk  | 0        |
|       1 | echo-subscriptions-email-emailuser       | 0        |
|       1 | echo-subscriptions-email-flow-discussion | 0        |
|       1 | echo-subscriptions-email-mention         | 0        |
|       1 | echo-subscriptions-email-page-review     | 0        |
|       1 | echo-subscriptions-email-reverted        | 0        |
|       1 | echo-subscriptions-email-user-rights     | 0        |
|       1 | echo-subscriptions-web-article-linked    | 1        |
|       1 | echo-subscriptions-web-edit-thank        | 1        |
|       1 | echo-subscriptions-web-edit-user-talk    | 1        |
|       1 | echo-subscriptions-web-emailuser         | 1        |
|       1 | echo-subscriptions-web-flow-discussion   | 1        |
|       1 | echo-subscriptions-web-mention           | 1        |
|       1 | echo-subscriptions-web-page-review       | 1        |
|       1 | echo-subscriptions-web-reverted          | 1        |
|       1 | echo-subscriptions-web-user-rights       | 1        |
+---------+------------------------------------------+----------+
19 rows in set (0.00 sec)
  • Local preferences table **
(19:00) vagrant@localhost:[wiki]> SELECT * FROM user_properties WHERE up_user=1 AND up_property LIKE 'echo-subscriptions%';
+---------+------------------------------------------+----------+
| up_user | up_property                              | up_value |
+---------+------------------------------------------+----------+
|       1 | echo-subscriptions-email-article-linked  | 1        |
|       1 | echo-subscriptions-email-edit-thank      | 1        |
|       1 | echo-subscriptions-email-flow-discussion | 1        |
|       1 | echo-subscriptions-email-mention         | 1        |
|       1 | echo-subscriptions-email-page-review     | 1        |
|       1 | echo-subscriptions-email-reverted        | 1        |
|       1 | echo-subscriptions-web-article-linked    | 1        |
+---------+------------------------------------------+----------+
7 rows in set (0.00 sec)

Now I disable the global preference. Here's the database result:

GlobalPreferences table:

19:05) vagrant@localhost:[centralauth]> SELECT * FROM global_preferences WHERE gp_user=1 AND gp_property LIKE 'echo-subscriptions%';
+---------+------------------------------------------+----------+
| gp_user | gp_property                              | gp_value |
+---------+------------------------------------------+----------+
|       1 | echo-subscriptions-email-article-linked  | 0        |
|       1 | echo-subscriptions-email-edit-thank      | 0        |
|       1 | echo-subscriptions-email-edit-user-talk  | 0        |
|       1 | echo-subscriptions-email-emailuser       | 0        |
|       1 | echo-subscriptions-email-flow-discussion | 0        |
|       1 | echo-subscriptions-email-mention         | 0        |
|       1 | echo-subscriptions-email-page-review     | 0        |
|       1 | echo-subscriptions-email-reverted        | 0        |
|       1 | echo-subscriptions-email-user-rights     | 0        |
|       1 | echo-subscriptions-web-article-linked    | 1        |
|       1 | echo-subscriptions-web-edit-thank        | 1        |
|       1 | echo-subscriptions-web-edit-user-talk    | 1        |
|       1 | echo-subscriptions-web-emailuser         | 1        |
|       1 | echo-subscriptions-web-flow-discussion   | 1        |
|       1 | echo-subscriptions-web-mention           | 1        |
|       1 | echo-subscriptions-web-page-review       | 1        |
|       1 | echo-subscriptions-web-reverted          | 1        |
|       1 | echo-subscriptions-web-user-rights       | 1        |
+---------+------------------------------------------+----------+
18 rows in set (0.00 sec)

Local preferences table:

(19:07) vagrant@localhost:[wiki]> SELECT * FROM user_properties WHERE up_user=1 AND up_property LIKE 'echo-subscriptions%';
+---------+------------------------------------------+----------+
| up_user | up_property                              | up_value |
+---------+------------------------------------------+----------+
|       1 | echo-subscriptions-email-article-linked  | 1        |
|       1 | echo-subscriptions-email-edit-thank      | 1        |
|       1 | echo-subscriptions-email-flow-discussion | 1        |
|       1 | echo-subscriptions-email-mention         | 1        |
|       1 | echo-subscriptions-email-page-review     | 1        |
|       1 | echo-subscriptions-email-reverted        | 1        |
|       1 | echo-subscriptions-web-article-linked    | 1        |
+---------+------------------------------------------+----------+
7 rows in set (0.00 sec)

Conclusion #1: Rows were not overridden in the local database, with a caveat

We can see that disabling GlobalPreferences, our global table removed the echo-subscriptions row (which enables the global override) but retained the internal values of the checkboxes for global values. The local table was untouched.

However, this created a mismatch in the UI (which is the reason for this bug)

In this state, if a user opened their local preferences page, the CheckMatrix would display the values of the global setting even though the general check matrix global row was not there. This means that if a user changed anything in their preferences and hit "Save" the global values (that are now in the UI, wrongly) overrode the previous local settings.

If the user did not save their local preferences, their previous local preferences are still there.

With the fix

With the fix, the situation is corrected to only load into the UI the state of the global preferences only if the global preference check is there, and if it's not, we clean up the individual value rows.
The local preferences remains untouched, so I skip it in the outputs; we're looking at GlobalPreferences table through the changes:

GlobalPreferences table for users affected (global is disabled, but rows still appear)

(19:08) vagrant@localhost:[centralauth]> SELECT * FROM global_preferences WHERE gp_user=1 AND gp_property LIKE 'echo-subscriptions%';
+---------+------------------------------------------+----------+
| gp_user | gp_property                              | gp_value |
+---------+------------------------------------------+----------+
|       1 | echo-subscriptions-email-article-linked  | 0        |
|       1 | echo-subscriptions-email-edit-thank      | 0        |
|       1 | echo-subscriptions-email-edit-user-talk  | 0        |
|       1 | echo-subscriptions-email-emailuser       | 0        |
|       1 | echo-subscriptions-email-flow-discussion | 0        |
|       1 | echo-subscriptions-email-mention         | 0        |
|       1 | echo-subscriptions-email-page-review     | 0        |
|       1 | echo-subscriptions-email-reverted        | 0        |
|       1 | echo-subscriptions-email-user-rights     | 0        |
|       1 | echo-subscriptions-web-article-linked    | 1        |
|       1 | echo-subscriptions-web-edit-thank        | 1        |
|       1 | echo-subscriptions-web-edit-user-talk    | 1        |
|       1 | echo-subscriptions-web-emailuser         | 1        |
|       1 | echo-subscriptions-web-flow-discussion   | 1        |
|       1 | echo-subscriptions-web-mention           | 1        |
|       1 | echo-subscriptions-web-page-review       | 1        |
|       1 | echo-subscriptions-web-reverted          | 1        |
|       1 | echo-subscriptions-web-user-rights       | 1        |
+---------+------------------------------------------+----------+

GlobalPreferences table after enabling the option in the UI

(19:09) vagrant@localhost:[centralauth]> SELECT * FROM global_preferences WHERE gp_user=1 AND gp_property LIKE 'echo-subscriptions%';
+---------+------------------------------------------+----------+
| gp_user | gp_property                              | gp_value |
+---------+------------------------------------------+----------+
|       1 | echo-subscriptions                       | 1        |
|       1 | echo-subscriptions-email-article-linked  | 0        |
|       1 | echo-subscriptions-email-edit-thank      | 0        |
|       1 | echo-subscriptions-email-edit-user-talk  | 0        |
|       1 | echo-subscriptions-email-emailuser       | 0        |
|       1 | echo-subscriptions-email-flow-discussion | 0        |
|       1 | echo-subscriptions-email-mention         | 0        |
|       1 | echo-subscriptions-email-page-review     | 0        |
|       1 | echo-subscriptions-email-reverted        | 0        |
|       1 | echo-subscriptions-email-user-rights     | 0        |
|       1 | echo-subscriptions-web-article-linked    | 1        |
|       1 | echo-subscriptions-web-edit-thank        | 1        |
|       1 | echo-subscriptions-web-edit-user-talk    | 1        |
|       1 | echo-subscriptions-web-emailuser         | 1        |
|       1 | echo-subscriptions-web-flow-discussion   | 1        |
|       1 | echo-subscriptions-web-mention           | 1        |
|       1 | echo-subscriptions-web-page-review       | 1        |
|       1 | echo-subscriptions-web-reverted          | 1        |
|       1 | echo-subscriptions-web-user-rights       | 1        |
+---------+------------------------------------------+----------+
19 rows in set (0.00 sec)

GlobalPreferences table after disabling the option in the UI

(19:36) vagrant@localhost:[centralauth]> SELECT * FROM global_preferences WHERE gp_user=1 AND gp_property LIKE 'echo-subscriptions%';
Empty set (0.00 sec)

which is exactly what we want to see.

Conclusion #2: The fix corrects the issue, with a caveat

With the fix, we're correctly removing the redundant rows and correctly loading the right information into local and global settings.

However while the loading of the UI is fixed and while the unnecessary rows will be removed when the user does anything to the global prefrences (like saves a setting) -- it won't be cleaned up on its own. We will still have redundant rows left-over from the bug.

The effect of this isn't huge, but it does have a subtle one:
Even after this fix, if the user had GlobalPreferences for CheckMatrix set up in the past (even if they're disabled) and the user now goes to Global Preferences and enables CheckMatrix, the values that the user will see is not the 'base' values from the current local wiki (Which is what usually happens to all other preferences) but rather whatever was previously saved (the redundant rows) .

This isn't horrendous, but it's worth noting.
(After retesting, the above seems to not be true; this means that the redundant lines should be fixed as part of good tech-debt maintenance, but should have no effect on user experience)

Recommendation: We might want to run an SQL query to clean up redundant rows for users that have 'echo-subscriptions-xxx' without 'echo-subscriptions'=1