Page MenuHomePhabricator

Make $wgVersion a constant
Closed, DuplicatePublic

Description

Author: theevilipaddress

Description:
Currently, $wgVersion is global variable from DefaultSettings.php, which means that it's easily possible for people to modify the variable in LocalSettings.php. I don't know if anyone ever did it, but if someone did it, this could break quite a lot of things. Version checks with version_compare() might be inaccurate, leading to certain functions/classes not to load or the information on Special:Version or {{VERSION}} give wrong information about the used software. Also, I could imagine people believing they could "update" MediaWiki by modifying $wgVersion.

Since there doesn't appear to be a need to modify $wgVersion, neither by the MediaWiki core, extensions or the site users, it could probably just as easily become a constant, maybe MW_VERSION, and then be used like that. This also has the nice side effect of getting rid of another global, which appear to be unloved within MediaWiki developers (IMO for good reasons).


Version: 1.18.x
Severity: enhancement

Details

Reference
bz27562

Related Objects

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 11:24 PM
bzimport set Reference to bz27562.
bzimport added a subscriber: Unknown Object (MLST).

This is PHP, everything can be screwed up by playing loose with globals. I don't see why $wgVersion is special.

Replacing a global scoped variable with a global scoped define doesn't really change anything other than making it impossible for users to change.

And there is some valid reasons to change it: $wgVersion = '1.17wmf1'; ...etc etc.

In general, I think changing it would break more stuff than it would fix, so I'm gonna go ahead and WONTFIX this.