Page MenuHomePhabricator

Undefined JS variable
Closed, ResolvedPublic

Description

I run MediaWiki master (currently 1.28alpha) with $wgLegacyJavaScriptGlobals = true and I get the error "sfgShowOnSelect is not defined" in Firefox console in a form with a {{{for template}}}. With $wgLegacyJavaScriptGlobals = false I get the warning "Use of "sfgShowOnSelect" is deprecated. Use mw.config instead.".

Event Timeline

Seb35 created this task.Sep 2 2016, 5:01 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 2 2016, 5:01 PM
Seb35 added a comment.Sep 2 2016, 5:05 PM

I fixed the bug by declaring var sfgShowOnSelect = mw.config.get( 'sfgShowOnSelect' ); in libs/SF_SemanticForms.js in function $.fn.setDependentAutocompletion. Then I checked if there were other such undefined variables in non-global-variables mode; see the patch.

If other extensions want to quickly check their compatibility, I used the two following regexes in command line (GNU/Linux):

grep -R sfg extension.json|perl -pe 's/^\s*"(.*)":\s*\{\n/\1|/g'

to get the global variables from extension.json, here with the prefix "sfg"

find -name '*.js' -exec grep -P -H '/\(sfgMaxAutocompleteValues|sfgMaxLocalAutocompleteValues\)/' \{\} \; > globalParametersJS

to find JavaScript files with global variables (I cut off the regex here for the example, there are about 20 global variables).

Seb35 triaged this task as Lowest priority.Sep 2 2016, 5:06 PM
Seb35 added projects: JavaScript, Technical-Debt.

Change 308199 had a related patch set uploaded (by Seb35):
Undefined JS variables in no-global-variables mode

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

Change 308199 merged by Yaron Koren:
Undefined JS variables in no-global-variables mode

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

Yaron_Koren closed this task as Resolved.Sep 6 2016, 5:05 PM

Resolved, I assume.