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.".
Description
Details
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Undefined JS variables in no-global-variables mode | mediawiki/extensions/SemanticForms | master | +7 -2 |
Event Timeline
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).
Change 308199 had a related patch set uploaded (by Seb35):
Undefined JS variables in no-global-variables mode
Change 308199 merged by Yaron Koren:
Undefined JS variables in no-global-variables mode