Page MenuHomePhabricator

Update the example of (non) legacy code wich uses the array wgRestrictionEdit
Closed, InvalidPublic


At DefaultSettings.php#L3709, there is

if ( window.wgRestrictionEdit ) { ... }


if ( mw.config.exists('wgRestrictionEdit') ) { ... }

However this variable is an array, not a boolean (see T133289), so it should be checking the length of the array instead:

if ( mw.config.exists('wgRestrictionEdit').length ) { ... }

Event Timeline

He7d3r created this task.Jan 2 2018, 11:06 AM
Restricted Application added subscribers: TerraCodes, Aklapper. · View Herald TranscriptJan 2 2018, 11:06 AM
Florian added a subscriber: Florian.Jan 3 2018, 9:51 AM

This will always be undefined in this case. Please see the exact code of the example:
if ( mw.config.exists('wgRestrictionEdit') ) { ... }

it does not use mw.config.get(...) which will return an array for wgRestrictionEdit, however, it uses mw.config.exists, which:
Check if one or more keys exist.
and, per doc, will always return a boolean:
exists( selection ) : boolean

So checking for a boolean here is correct, as we're not checking that there're any entries in the array, but instead checking, if the config variable even exists (~ is defined).

This looks like to be invalid then?

He7d3r closed this task as Invalid.Jan 8 2018, 5:07 PM

Right. My bad.