Last modified: 2011-03-13 18:06:41 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T29562, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 27562 - Make $wgVersion a constant
Make $wgVersion a constant
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
All All
: Lowest enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
Blocks: code_quality global-vars
  Show dependency treegraph
Reported: 2011-02-19 15:38 UTC by The Evil IP address
Modified: 2011-03-13 18:06 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description The Evil IP address 2011-02-19 15:38:34 UTC
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).
Comment 1 Max Semenik 2011-02-19 15:41:53 UTC
This is PHP, everything can be screwed up by playing loose with globals. I don't see why $wgVersion is special.
Comment 2 Chad H. 2011-02-19 18:08:56 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.