Page MenuHomePhabricator

CodeMirror does not set a default for "usecodemirror" preference, causing user_properties bloat
Closed, ResolvedPublic1 Estimated Story Points

Description

The CodeMirror extension does not set a default for the usecodemirror preference, causing bloat to the user_properties table.

wikiadmin@10.192.48.133(enwiki)> select count(*), up_value from user_properties where up_property="usecodemirror" group by up_value;
+----------+----------+
| count(*) | up_value |
+----------+----------+
|    54902 | 0        |
|    63037 | 1        |
+----------+----------+
2 rows in set (25.48 sec)

The user_properties table is only supposed to store preference overrides, those that don't match the default. However since there's no default, any time a user changes their preferences, a row has to be saved for usecodemirror. Also, this adds just a bit more to the logged-in user HTML payload because we ship non-default prefs in each request.

A default should be set via extension.json in "DefaultUserOptions". I would suggest that the extension default is set to true (so it works out of the box), but disable it on Wikimedia wikis to maintain the status quo.

This was noticed by @Proc.

Event Timeline

Legoktm triaged this task as High priority.Jul 7 2021, 12:22 AM
Legoktm created this task.
Restricted Application added a subscriber: Aklapper. ยท View Herald Transcript

Change 703632 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CodeMirror@master] Set default for 'usecodemirror' preference

https://gerrit.wikimedia.org/r/703632

Change 703633 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[operations/mediawiki-config@master] Disable code mirror by default

https://gerrit.wikimedia.org/r/703633

MusikAnimal set the point value for this task to 1.
MusikAnimal added subscribers: Daimona, MusikAnimal.

Due to T286623 and the need to change Core selenium tests to work with CodeMirror, as well as the fact the CodeMIrror API will change in near future (T259059), I've gone with the easy route of having the extension default be false. This matches the status quo, anyway.

Thanks to @Daimona for the help in debugging the tests!

Change 703632 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] Set default for 'usecodemirror' preference

https://gerrit.wikimedia.org/r/703632

dom_walden added a subscriber: dom_walden.

In the source editor, if I click the "syntax highlighting" button a row gets written to the user_properties table in the database to reflect the CodeMirror feature being enabled for my user. When I click it again, the row is removed.

I have tested this on beta.

I tried to test on production (testwiki), but turns out I cannot. I only have access to replica databases, and these won't show the codemirror property (because it is considered private).

Test Environment: https://en.wikipedia.beta.wmflabs.org CodeMirror 4.0.0 (0332e21) 19:30, 23 July 2021.