Page MenuHomePhabricator

Define MW_INSTALL_PATH constant as a replacement of $IP
Closed, ResolvedPublic

Description

The global variable $IP should be replaced by a global constant MW_INSTALL_PATH. The advantages of the constant over the variable are not huge, but I think still compelling:

  • The constant cannot be changed (while the variable shouldn't be changed, but could)
  • The constant has a better name ($IP is obscure and may easily conflict)
  • The global keyword should be avoided (eventually we'll want a linter rule to flag usages of global)
  • Using MW_INSTALL_PATH is analogous to using __DIR__ to locate files.

Event Timeline

Change 757744 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Define MW_INSTALL_PATH constant.

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

Change 759233 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Remove usage of $IP from Language and friends.

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

Change 759238 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Remove usage of $IP in some simple cases

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

Change 763217 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/quibble@master] release: Quibble 1.4.1

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

Change 763217 merged by jenkins-bot:

[integration/quibble@master] release: Quibble 1.4.1

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

Since Quibble 1.4.1 we define MW_INSTALL_PATH as a PHP constant and all Jenkins jobs have been switched :)

Change 757744 merged by jenkins-bot:

[mediawiki/core@master] Define MW_INSTALL_PATH constant and BaseDirectory config.

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

@daniel Making this a constant looks great. I don't understand the purpose of $wgBaseDirectory in addition to MW_INSTALL_PATH.

I think we'd need to set a pretty high bar of purpose and value to justify keepin it, as it is imho inevitable that this will result in confusion, plus its added value will likely be deminished by people not use them correctly.

I would like to replace its use with MW_INSTALL_PATH and remove it as a config variable.

@daniel Making this a constant looks great. I don't understand the purpose of $wgBaseDirectory in addition to MW_INSTALL_PATH.

The BaseDirectory config variable can be changed to a different values in phpunit tests. That's the only reason to have it, but I think it's a good reason.

Setup.php forces them to be the same initially. But I agree that it's a bit confusing.