Page MenuHomePhabricator

Globals should be explicitly declared in PHP
Open, LowPublic


I've probably chosen the worst possible file as an example, but see this patch:

When MediaWiki source files declare variables in their top-level scope, the implicit assumption is that we are declaring them as global. However, if any part of the MediaWiki initialization code was called from within local (function-level) scope, PHP will no longer globally scope these variables.

The only solution is to explicitly declare the variables with a top-level "global", anywhere we expect to refer to the variable from another file, i.e., for every global.

Version: 1.22.0
Severity: normal