Commit graph

757 commits

Author SHA1 Message Date
James D. Forrester
26109fb098 logos: Set default install icon to be an SVG one
Change-Id: I5cd715a0c220667827cde99f0296280110c78631
2022-03-10 12:54:59 -05:00
jenkins-bot
277453fe78 Merge "Define MW_INSTALL_PATH constant and BaseDirectory config." 2022-03-08 17:44:09 +00:00
daniel
cf581bb2ca Define MW_INSTALL_PATH constant and BaseDirectory config.
Application logic should use the BaseDirectory config variable.
Framework code should use MW_INSTALL_PATH to locate files should.

NOTE: Update https://www.mediawiki.org/wiki/Manual:$IP

Bug: T300301
Depends-On: I7142af16d692f26e90673b058029f572c1ea3991
Change-Id: Ib4caa80bb7007c4c7960a2fd370cf5da7d9ba344
2022-03-04 14:18:27 +01:00
daniel
f31bc32a65 Remove deprecated alias $wgStyleSheetPath
$wgStyleSheetPath has been a deprecated alias for $wgStylePath since 1.3 (2004).
Time to get rid of it.

Change-Id: I78a6394003b9aefab7aa8559b8e2b22bc50154fc
2022-03-04 13:36:56 +01:00
jenkins-bot
47cb6a9be1 Merge "Optionally use config-schema in Setup.php" 2022-03-04 12:09:09 +00:00
daniel
3adc408556 Optionally use config-schema in Setup.php
In order to safely transition Setup.php to load config-schema.yaml
rather than DefaultSettings.php, we need to be able to test the new
setup mechanism selectively, on only a few hosts.

This patch makes Setup.php use config-schema.yaml if the
MW_USE_CONFIG_SCHEMA variable is set.

The condition could be patched in production to be based on the host
name or a request parameter for further experimentation in the live
environment.

Bug: T300129
Change-Id: Idc12b8e6ee2a3cc41cf5ab8d1eb755e6fab0213d
2022-03-03 18:05:21 +00:00
Reedy
86934b2fa8 Replace some more usages of Wikimedia\(suppress|restore)Warnings()
Change-Id: I2eb133a9e32116cd155f59086245bc4d15ecbfcc
2022-02-24 20:27:46 +00:00
daniel
cf499e8491 Allow config merge strategies to be bypassed.
Sometimes, we need to force an exact value and bypass the default
behavior of merging config variables.

This also renames setConfigValue to putConfigValue, to avoid confusion
about the behavior of that method.

Change-Id: I82c606632b94f974e655a44a0b63394de7a0804b
2022-02-22 22:59:25 +00:00
daniel
66f0904bc9 Pass SettingsBuilder into config callbacks.
We are already passing SettingsBuilder into callbacks registered with
MW_SETUP_CALLBACK. Do the same for MW_CONFIG_CALLBACK.
This will allow us to avoid messing with global variabls in more places.

Bug: T294739
Change-Id: Ic6296907139912351b53dc80672ef950c0aefeb3
2022-02-21 22:34:23 +00:00
daniel
dcef1674a5 Allow main settings file to be selected via env variable.
This allows a file other than LocalSettings.php to be used as the primary
settings file by setting the MW_CONFIG_FILE environment variable.
This also allows the primary settings file to use YAML or JSON format.

Using static configuration files should be the default in the future.
However, YAML files in the document root could easily be exposed to the
public. Better not to encourage that, and require them to be enabled
explicitly and loaded from a different place.

Bug: T294750
Change-Id: I7747f83481cb05a6d05f819be652259951183819
2022-02-06 21:13:00 +01:00
daniel
f5641f9856 Do not rely on $IP in DefaultSettings.php
In order to allow configuration default to come from JsonSchema,
and dynamic defaults need to be initialized in Setup.php.

This movesd the initialialization of $wgExtensionDirectory and $wgStyleDirectory
to Setup.php

Bug: T294788
Change-Id: I11f5723aa299caa210cf6a1f5b7436f191b1ffc2
2022-02-03 22:05:34 +00:00
jenkins-bot
b18023b48f Merge "filerepo: Simplify and document 'favicon' FileRepo option" 2022-01-28 18:14:28 +00:00
Timo Tijhof
77b7cbc462 filerepo: Simplify and document 'favicon' FileRepo option
This was originally added in changes linked to T77093 without
coordination with maintainers and took various shortcuts and lacked
proper integration.

* Rather than reading a global variable from LocalRepo::getInfo,
  inject this option from Setup.php, the same as for other local
  settings.

* Apply the wfExpandUrl() call in the base class getInfo() method.

  This is done so that $wgForeignFileRepos and $wgLocalFileRepo
  settings via LocalSettings.php or wmf-config get the same treatment
  and benefit (support for paths) as $wgFavicon, which one would
  generally expect.

  Other reasons to do this at run-time are 1) We can't safely call
  wfExpandUrl() during Setup.php as it is too early, and 2) We generally
  avoid doing computational work during Setup.php given it's not
  needed for most web requests to most entry points (T189966, etc.).

* Document the option in DefaultSettings.php.

* Fix bad doc in FileRepo.php, to reflect that it is optional
  and may be null.

* Remove now-redundant hack in ForeignDBRepo::getInfo,
  which had to jump over its parent class previously to avoid
  inheriting the other hack in LocalRepo::getInfo, which is now
  gone as well.

Bug: T77093
Change-Id: I9102b5a246ff81a3435748a3fd1c759a4b884a51
2022-01-26 19:27:35 +00:00
Ppchelko
44edde6295 Reapply "SettingsBuilder: allow maintenance scripts to manipulate config"
This reverts commit 4f7a4a2477.

Reason for revert: This change is good, just need some preparation in extensions.

Depends-On: I24221be2cedfa132fc94d39d72e4a133cc3cdb12
Depends-On: I5e6119b650e581c6aa5a1132aa071b49cff8b8ca
Change-Id: I5a5a9000751fa3914c9d432eb49475091b3bdb80
2022-01-26 19:21:58 +00:00
Ppchelko
4f7a4a2477 Revert "SettingsBuilder: allow maintenance scripts to manipulate config"
This reverts commit a652f306a5.

Reason for revert: need to prepare extensions first

Change-Id: Iccedf38a8dc964db7c49fd51c971912655122081
2022-01-26 17:24:31 +00:00
daniel
a652f306a5 SettingsBuilder: allow maintenance scripts to manipulate config
Maintenance scripts often need to manipulate configuration settings.
This introduces a way to do this cleanly via SettingsBuilder,
removing the need to rely on global variables.

Bug: T294739
Bug: T294742
Bug: T300128
Change-Id: Ibf443fd564bbbf388cce8ab4dabba55ebca0dfa4
2022-01-26 12:02:56 +00:00
Siddharth VP
804dcac8a3 Fix typos in comments (S)
Change-Id: Id86769ca81ff65707edde520585aa9ea117123e1
2022-01-09 23:28:53 +05:30
Derick Alangi
50f1f7fe39 Settings: Add config merge strategies to apply on settings
Change-Id: I4cffc599a9d96d15b773f09c2693b08011697c4e
2021-12-09 20:37:54 +00:00
daniel
ffc247d417 SettingsBuilder: load skins and extensions
This is a minimal baseline implementation that allows skins and
extensions to be loaded from settings files.

This should be improved by closely integrating SettingsBuilder with
ExtensionRegistry. They should probably end up being the same thing
eventually. Loading extension.json is essentially the same as loading
settings files.

Change-Id: I02a1d9b517815463f150b53c0602927609ff9eeb
2021-12-07 17:25:58 +01:00
Derick Alangi
086f4b1c5f Settings: Prevent applying more settings after invoking ->finalize()
When we're done applying settings and we call `finalize()`, any further
attempt to apply settings too late should throw.

This is a defensive mechanism for us to track the state of settings applied
in during setup process and will guide us to bring all settings to be applied
in the appropriate place so unexpected things don't happen.

Bug: T296684
Change-Id: Id58654c8265bc8310e1fe464ff5a480aad8a8666
2021-12-02 11:05:50 +00:00
jenkins-bot
992c592f7d Merge "Introduce setting PHP_INI env configs via a settings source" 2021-11-25 21:47:33 +00:00
Derick Alangi
dce6673430 Introduce setting PHP_INI env configs via a settings source
This feature enables the SettingsBuilder to be able to set php-ini
environment variables at run-time.

We just do so by specifying the various key/value pairs to the `php-ini`
key like below:

```
"php-ini": {
    "key": "value",
    ...
}
```

This will allow us to set things like `display_errors`, `memory_limits` etc.

Bug: T294752
Change-Id: I2ff0e7abc010342537bbaf1e1b71fb84d02a153b
2021-11-25 01:20:35 +01:00
Adam Wight
440633a1e5 Use MW_CONFIG_FILE constant for config path in Setup.php
The config file path can be overridden, so we should use the defined
constant rather than hardcoding a path.  The intention of this logic
is to purge cache with the active config changes, so it's more correct
to check the mtime of the file in use.

Change-Id: Iac5fa2af4021ab8c1a0532b46b3bbc02641c682a
2021-11-24 22:59:17 +00:00
wctaiwan
e3033bb447 Tweak error message for missing composer dependencies
I tried doing this in Id9a6cf9ee2520db9d405e17eaf34b10bd72897f3 but
the error message modified in that patch was specific to the PSR-3
logging library, not for missing composer dependencies. This patch
modifies the error message for the latter as well.

Change-Id: I713a9037b8c5dc71bf03fb2ec791b3ce63e5f1be
2021-11-17 09:53:57 -08:00
Petr Pchelko
92f3f1a944 Introduce MergeStrategies for ConfigSink
Change-Id: Ibb4fdf83d87ad204da5fbc4892c9b7610e979f72
2021-11-16 13:07:03 -08:00
daniel
80fd54ffb0 Allow $wgSettings to be used in LocalSettings.
Bug: T294749
Change-Id: I3f9270c9d3ae8996fe25d3f8821eae0d5c9212e0
2021-11-16 18:25:38 +00:00
wctaiwan
0f4a775659 Tweak error message for missing composer dependencies
It wasn't obvious to me that the mediawiki.org link actually pointed
to specific instructions for resolving the error, as opposed to
just telling the user to search on mediawiki.org. Try to make this
a bit more obvious.

Change-Id: Id9a6cf9ee2520db9d405e17eaf34b10bd72897f3
2021-11-10 06:47:56 +00:00
Tim Starling
65b1b6b56a Remove $wgShellLocale, always use C
$wgShellLocale was a flawed solution to the problem of locale
dependence. MediaWiki has its own concept of locale (the Language
hierarchy) and any kind of dependence on the server's libc locale is
incorrect and harmful, leading to bugs. Developers have an expectation
that functions like strtolower() will work in a certain way, and
respecting the locale set in the environment at install time violates
this expectation.

The problems with using C as a locale, which led to $wgShellLocale, are:

* escapeshellarg() will strip non-ASCII characters. This can be worked
  around by not using it. The security vulnerability it was trying to
  fix can be prevented in another way.
* Shell commands like rsvg will fail to correctly interpret UTF-8
  arguments. This is the reason for the putenv(). On Linux, this can
  be fixed by using C.UTF-8, which we didn't know at the time. On
  Windows, the problem is not relevant (there are unrelated issues
  with UTF-8 arguments).

Bug: T291234
Change-Id: Ib5ac0e7bc720dcc094303a358ee1c7bbdcfc6447
2021-09-24 17:25:01 -07:00
DannyS712
a2b20b63d7 Emit deprecation warnings reading from $wgUser
With this patch deprecation warnings will be emitted
if $wgUser is accessed or written into. The only pattern
of usage still allowed is

$oldUser = $wgUser;
$wgUser = $newUser;
// Do something
$wgUser = $oldUser;

Once there is no deprecation warnings, we know that nothing
legitimately depends on $wgUser being set, so we can safely
remove the code that's still allowed as well.

Bug: T267861
Change-Id: Ia1c42b3a32acd0e2bb9b0e93f1dc3c82640dcb22
2021-09-15 20:17:04 -07:00
Reedy
4dae3b1a06 Rename four config variables to avoid 'blacklist' term
As part of our wider work on modernising and making more welcoming the
language we use within and around MediaWiki, now is a good time for us
to rename these configuration variables:

 - $wgFileBlacklist is now $wgProhibitedFileExtensions
 - $wgMimeTypeBlacklist is now $wgMimeTypeExclusions
 - $wgEnableUserEmailBlacklist is now $wgEnableUserEmailMuteList
 - $wgShortPagesNamespaceBlacklist is now $wgShortPagesNamespaceExclusions

Bug: T277987
Depends-On: I91e065c58fda144a722a41cf532e717f962d7a64
Change-Id: I558a8b20d67d48edccce0d065aec2d22992e9dda
2021-09-08 23:32:29 +01:00
Umherirrender
07b499fbcf build: Update mediawiki/mediawiki-phan-config to 0.11.0
Addition and remove of suppression needs to be done with the version
update.

Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
2021-09-07 17:19:05 +02:00
Umherirrender
a7bb7cc5c5 Remove unreachable code after exception/die/exit
Change-Id: Ia81903fb2a8157625fbe63115097eccc1161b5db
2021-09-03 23:14:28 +00:00
Timo Tijhof
fecf272501 Setup: Move $wgServer check back, update date.timezone explaination
Follows-up 1c9230d9fd.

* Move the $wgServer check back where it was, to after installing
  MWExceptionHandler. This is not strictly required as one can always
  throw, and it'd end up in the logs, and if display_errors is
  on also on-screen. But the use of FatalError page specifically,
  results in a cleaner plain text error page, which only works if
  MWExceptionHandler is installed first. Restore this and document it.

  To test, change the conditional to `if ( true )`.

* Update the outdated explaination around date_default_timezone_get().
  My patch removed the warning suppression, but left behind the comment
  talking all about warning suppression.

Change-Id: I3da96e35d9bc253db2cfc6cc99180e5669320964
2021-07-31 20:05:38 +01:00
Timo Tijhof
b7ccffd287 Setup: Restrict WebRequest::interpolateTitle() to index.php requests
This is as useless on load.php as it already was on api.php, and for
things like thumb.php, rest.php, and opensearch.php it's probably not
helping, either.

Change-Id: I86745ad244ae9d969d4d33bfd5e37f1e7eea39f6
2021-07-27 01:21:52 +01:00
Timo Tijhof
1c9230d9fd Setup: Move more trivial statements to the corresponding earlier section
* Document the divide between trivial and complex expansion.

* Move more trivial statements from below to the trivial section,
  thus making it easier to spot and reduce more of the complex stuff
  such as in T233886, and T189966 etc.

Change-Id: Iad8cfd6b377b9ec706e9212892461c71cea55877
2021-07-27 01:21:52 +01:00
Ariel T. Glenn
8d2654fe53 fix couple typos in the module docstring
Change-Id: I606c50b07942518ef34edf20450878359416b0ad
2021-07-06 18:42:13 +03:00
Tim Starling
9251f3c9e3 Manual and automatic image metadata reserialization
* Add automatic splitting of large metadata on upload or refresh. If
  the reserializeMetadata option is enabled, metadata stored with PHP
  serialization will be automatically reserialized to JSON.
* Inject configuration variable $wgUpdateCompatibleMetadata via
  LocalRepo instead of accessing it directly.
* In refreshImageMetadata.php and rebuildImages.php, construct a new
  LocalRepo with config overrides, instead of overwriting config
  globals. Add a helper to RepoGroup to help with this.
* In refreshImageMetadata.php, add new options --convert-to-json and
  --split which reserialize metadata and optionally split out large
  items to blob storage.

Also, refreshImageMetadata.php was totally broken in the non-force mode
since metadata refresh on page view was disabled in b814245d9f. The
maintenance script was relying on newFileFromRow() magically upgrading
the row, which doesn't happen anymore. So, call maybeUpgradeRow()
directly.

Bug: T275268
Change-Id: I7bf7d9cef71641e287ca4346b568b381f4ada50e
2021-06-26 22:50:17 +00:00
jenkins-bot
29827d736a Merge "Setup: Move LBFactory::setRequestInfo() to service wiring" 2021-04-27 05:02:13 +00:00
Timo Tijhof
d295614b38 Setup: Move LBFactory::setRequestInfo() to service wiring
Avoid costly and unconditional set up of LBFactory early on in
Setup.php. Instead, inject this information lazily if and when the
service is contructed by something that actually needs a database
connection.

This removes the cost of LBFactory service + dependencies for requests
to load.php, api.php, and rest.php requests that involve no (other)
calls to the database service.

Bug: T228895
Change-Id: I3140922cec130cad84eb89b2b34520c0988027dc
2021-04-26 22:53:56 +00:00
jenkins-bot
fe269a6d63 Merge "authevents: strval() variables passed to status when logging" 2021-04-20 00:34:55 +00:00
mainframe98
20fc80577b Rename $wgSlaveLagWarning and $wgSlaveLagCritical to match DB_REPLICA
These are now named $wgDatabaseReplicaLagWarning and
$wgDatabaseReplicaLagCritical, respectively.

Bug: T277987
Change-Id: I62d8c2028fdfee00904f1058f8387499f2b2e977
2021-03-21 17:58:15 +00:00
Cole White
894af957fd authevents: strval() variables passed to status when logging
Bug: T269676
Change-Id: Ief1a5e00d933ee5fa6880da60257163e55391eb6
2021-03-19 12:35:04 -06:00
DannyS712
35bd84e9ee Comments: use only // instead of more
No need for three or more slashes

Except in some places where a bunch more are
used for drawing attention to something

Change-Id: Ic90358eb89a14a04d2b66c48e52e8fb20de0eb04
2021-03-10 15:05:57 +00:00
James D. Forrester
bdddfb92ba Drop wgContLang, deprecated in 1.32
Bug: T245940
Depends-On: Ib7fe7318100c0aadc3aa759416bf787913a9b788
Change-Id: I75c3b6715abd5eaf3619337cab8b1844e9a8349a
2021-03-08 13:27:28 -06:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Tim Starling
2697837fd8 RequestTimeout library integration
* Add $wgRequestTimeLimit. If it is non-null, it starts a time limit,
  using Excimer with a fallback to set_time_limit().
* Add pretty formatting of timeout exceptions thrown by the library.
  Related refactoring.
* Expose the library's critical section feature in MediaWikiServices
* In Setup.php, call warnIfHeadersSent() before sending session headers.
  This helped to debug a related issue I had.
* In wfTransactionalTimeLimit() use the new library, and respect the
  existing library time limit if it is larger than
  $wgTransactionalTimeLimit.

Bug: T269326
Depends-On: I6409ad8a5cba775c27b0d5a79d3300c4dac4c91a
Change-Id: I2e6f6351c451407c06cc7e20932548f7b62e36b6
2021-02-08 11:58:45 +11:00
daniel
47bb958f03 Deprecate premature instantiation of services.
This deprecates access to the global service container before
initialization is complete. For now, such premature access will
trigger a deprecation warning. In 1.37 we can prevent it entirely.

Bug: T153256
Change-Id: Ibd3ab32d92c9c3d3783082ab574739467c1c2ff9
2021-01-19 22:33:13 +01:00
Umherirrender
f46ca9a63c build: Updating mediawiki/mediawiki-phan-config to 0.10.5
Change-Id: I343d2bae626a3903eb1e67c05bf5caef4314b7dd
2020-12-12 14:42:25 +01:00
Umherirrender
6a2c2548a4 Document HttpError to help taint-check
This does not help to avoid the suppression inside the class,
but it avoids the suppression for all callers

Remove unneeded local vars while looking at the code

Bug: T269895
Bug: T216348
Change-Id: I5ce9a2dddca2b3bb556eb7adb5305178db09a71a
2020-12-12 00:06:00 +01:00
Umherirrender
1bc05f5242 Use UserNameUtils in Setup
Change-Id: Id374aa1d460ee2b1ecb362bd3cce50fb8ed11149
2020-11-29 08:43:52 +00:00