Page MenuHomePhabricator

WikiEditor toolbar shows up unexpectedly
Closed, ResolvedPublic

Description

MW seems to be writing rows with up_value='' to the DB for certain toggle prefs. Empty values for these prefs are interpreted very strangely, where certain prefs (notably usebetatoolbar, probably because the default is 1) are considered to be set to 1 for the purposes of deciding to use the feature (i.e. User::getOption()) but 0 for the purposes of the preference form. This means the relevant feature is enabled but can't be disabled in Special:Preferences.

I discovered these values before the Feb 16 deployment, and wrote a script to fix them. But they're now back in larger numbers, so it must be 1.17, not 1.16, corrupting the DB here.

Sample from dewiki:

mysql> SELECT up_property, COUNT(DISTINCT up_user) FROM user_properties WHERE up_value = '' GROUP BY up_property;
+-----------------------+-------------------------+

up_propertyCOUNT(DISTINCT up_user)

+-----------------------+-------------------------+

ajaxsearch21902
contextchars32
contextlines32
date22457
editsection299
enotifusertalkpages1023
flaggedrevseditdiffs48
flaggedrevsstable4
forceeditsummary130
highlightbroken179
imagesize5
language4
math34
nickname159014
previewontop691
quickbar43
rclimit53
searchNs0277
searchlimit34
showjumplinks506
showtoc188
showtoolbar382
skin430086
timecorrection108414
usebetatoolbar72
usebetatoolbar-cgd1332
useeditwarning306
variant134463
vector-collapsiblenav176
vector-simplesearch20
watchcreations9732
watchlistdays5
watchlisttoken25067
wllimit4377

+-----------------------+-------------------------+
34 rows in set (18.73 sec)


Version: unspecified
Severity: enhancement
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=52542

Details

Reference
bz27471

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:21 PM
bzimport added a project: WikiEditor.
bzimport set Reference to bz27471.
Catrope created this task.Feb 16 2011, 8:27 PM

My testing indicates that even in 1.16, an empty string was used for false for toggles where the default is true. User::getBoolOption() will return an appropriately typed value, but all it does is (bool)$value.

SpecialPrefSwitch::isSwitchedOn() and WikiEditorHooks::isEnabled() both make use of PHP's double-equals operator to perform implicit conversion from string to integer or boolean, and surprisingly, this appears to work correctly.

Perhaps the issue is actually the usebetatoolbar-cgd option. WikiEditor is disabled by omitting its module from the output. When usebetatoolbar-cgd is enabled, the ext.wikiEditor.dialogs is added to $wgOut, which depends on ext.wikiEditor.toolbar. So both are loaded and the toolbar is automatically shown. When I tested it on Wikipedia, the old toolbar was shown only when both preferences were disabled.

Thanks for debugging this, Tim. I tried to fix this in r82359 and deployed it.

GOIII moved this task from Backlog to Closed on the WikiEditor board.Apr 3 2016, 9:31 AM