Nowadays files transferred to browser via text/* MIME are also getting
automatic dark mode by the browsers so this makes these simple pages
compatible with those features of the browsers.
Change-Id: Id8360ff3ca6dbe7b78e30194fde292763479cb21
Follows-up Ib70e4e67e4cb1.
* This removed index.php from the "entrypoint"
group, but did not add MediaWikiEntryPoint in its stead.
* Fix broken `@see` reference, leading slash is not part of the
identifier for the `@file` block index.php, only works without it.
* Move the defgroup to a more natural place in the parent class' file.
Bug: T354216
Change-Id: I1281e0934368884f4d1ffbbd3f5588b9a211356f
It's not a class, so it doesn't need alias and only in one place
directly called (WebStart) which the path got fixed.
Bug: T321882
Change-Id: I415eed06d228f10a87b4900534cbc676b7d615b5
The global variable $IP has been replaced by the MW_INSTALL_PATH
constant. Clarify the continued use of $IP on Setup.php.
Change-Id: I157abfd9049fb8382da53005a084ab86f47e8d8a
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
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
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
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
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
This helps phan to detect unreachable code and also impossible types
after the functions.
It helps phan to avoid false positives for array keys
when the keys are checked before
Bug: T240141
Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
Defining functions conditionally seems to break preloading
functionality, as the function is tried to be redeclared.
Bug: T240775
Change-Id: I7d1df9f13927f0a7af33f9ee955b0ed8dc47a359
It was suggested this header be renamed to be consistent with the
infrastructure header added in T91820. We have to explicitly
allow the REST API to use this header in the WebStart sanity check.
Bug: T91820
Bug: T259685
Followup-To: b75ac3953e
Change-Id: I0c4ec63bb26641b237c92dbd3bc5367811ca0675
I've moved the simple config expansions that don't depend on anything
else in Setup.php together, more compactly.
Change-Id: Iefb7f8ffdca70bcfbf7cbf49f7939747c5ab0d76
Turn this into a doc group, and let the descriptions come
directly from the files in question. This makes the list easier
to maintain, and alsom means that the overview page becomes
discoverable whenever one is looking at the entry point file
as well. Previously the doc page pointed to the entry points,
but not the other way around. This is also fixed.
Bug: T244294
Change-Id: I891c5a37e17592edc1136d7367949927121c8bc8
Make the code easier to reason about by not involving global state from
LBFactory, RequestContext, SessionManager, and User.
Bug: T189966
Change-Id: I88d2bf58ebd481009ce295335d730a34dbb277fb
Follows-up 26c2d03c17, 41d1fa1c3a and r11547 (c7f363f886).
Also add references to the relevant tasks about why the check
exists.
Bug: T189966
Change-Id: Ic1f0c79a1b5638bb30351a0cab55699931d1fded
This seems redundant given it is unconditionally being set
two statements later. Probably a left-over from r36353 (c6b902f180),
which did an unset() because there was another variable called
$preIP, and the original would no longer be needed.
However, we currently only use one variable ($IP) and there's no
need to unset() it before setting.
Bug: T189966
Change-Id: I17d516709beabeb80bd72b37f70ac9b666a501d4
* Convert OutputHandler.php from global functions to a class.
- wfOutputHandler → OutputHandler::handle
(no alias, no usage outside core)
- wfGzipHandler → OutputHandler::handleGzip
(private, no usage outside class)
- wfRequestExtension → OutputHandler::findUriExtension
(private, no usage outside class)
- wfMangleFlashPolicy → OutputHandler::mangleFlashPolicy
(private, no usage outside class)
- wfDoContentLength → OutputHandler::emitContentLength
(private, no usage outside class)
- wfHtmlValidationHandler → OutputHandler::validateAllHtml
(private, no usage outside class)
* Add the class to autoload.php for exposure outside WebStart.
Specifically, for use in ApiFormatPhpTest. This also removes the
need to manually load the class because this code runs after
Setup.php loads AutoLoader.php.
Bug: T189966
Change-Id: I27a41ec0ae0ee30aeb313a616323b967605c4055
When installing MediaWiki in a sub directory of document root,
and including it from an /index.php file in the document root,
MediaWiki succesfully includes WebStart from index.php, but
WebStart.php fails to include Setup.php.
For example, MediaWiki installation at /var/www/mediawiki with the
following file at /var/www/index.php.
```
<?php
require __DIR__ . '/mediawiki/index.php';
```
Failure:
> Fatal error:
> require_once(): Failed opening required '/var/www/includes/Setup.php'
> (include_path='.:/usr/local/lib/php') in
> /var/www/mediawiki/includes/WebStart.php on line 97
>
> Stack trace:
> 1. {main}() /var/www/index.php:0
> 2. require() /var/www/index.php:3
> 3. require() /var/www/mediawiki/index.php:40
Bug: T153882
Change-Id: Icd8cfa580ce1c22bc3bf177570a9f4a940d2427c
Follows-up 41ea7e2fef.
The following previously happened between PreConfigSetup and Setup
and must now happen either before it, after it, or moved inside it.
* WebStart: Detect missing composer.
This must be after Autoloader/Vendor but before the first call to
wfDebugLog (or other loggers) so that we can output a more descriptive
error instead of a generic "Unknown class" fatal error.
Moving it to before Setup is too early, and after is too late.
Move it to within Setup.php and make it work in CLI mode.
* WebStart: Install header callback
Moving it to before Setup is too early, and after is too late.
Move it to within Setup.php (no-op in CLI mode).
* WebStart/Maintenance: Load LocalSetings.
Must be between PreConfigSetup and Setup.
Move to Setup.php to maintain execution order.
Utilise MW_CONFIG_File for custom handling in Maintenance.php.
* WebStart: Initialise output buffering
Utilise (new) MW_SETUP_CALLBACK hook.
* WebStart: Display NoLocalSettings.php
Utilise MW_CONFIG_CALLBACK hook.
* Maintenance: Setting $wgLocalisationCacheConf, calling Maintenance::finalSetup.
Utilise (new) MW_SETUP_CALLBACK hook.
Change-Id: I633a6ff235b4275391c48034c0525d2fbfa3fecd
Introduce PreConfigSetup.php, which is common file-scope code run before
LocalSettings.php.
I'm not maintaining autoload.ide.php since it supports closed source
software which I don't have, and it apparently needs significant work to
make it not be weird and hacky.
Change-Id: I44ac69b6b00a51d015546b9766d89d1c59749334
The doc comment did not reflect the removal of MW_NO_SETUP in
edc9edbc76, or the fact that Setup.php no longer loads
AutoLoader.php or GlobalFunctions.php.
Change-Id: I19a12fd83e369828b9e08176ddf3bfca16aae465
Install the backtrace collector very early, so that we can get the
backtrace even if headers were sent from LocalSettings.php.
Bug: T157392
Change-Id: I9bc732b34481c95afb5362e135a87bd4302498e2
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.
Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
This protection is in place for a single extension, Maintenance.
Said extension is probably broken anyway and has been for quite
some time.
Plus, it doesn't even really work like it would intend, the extension
uses special pages and this is a require_once, so a subsequent
request to WebStart.php (which isn't even called by extensions)
wouldn't re-require it.
tldr: This is pointless
Change-Id: I22e7418d2b46c00d4009c370c24ac4b8bc43190a
The installer already checks for this, let's also catch the case when
someone enables this after installation.
Bug: T122807
Change-Id: Ieddbc932f482d52da1688d472f494074c81124b2
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
* Fix errors spotted by new release
* Introduce "composer fix", which uses phpcbf to automatically fix some
errors spotted by phpcs.
* Drop $PHPCS_ARGS variable that didn't work on Windows, and add -s flag
* Remove rules from phpcs.xml that are now in MW-CS ruleset.
Change-Id: I13e2155695918c918b67497ac65b85a03897095e
This ensures that, in case "composer install" has not been run,
the user will see the error message about setting up dependencies
(as opposed a plain "Class not found" error because some other
dependency was used first).
Change-Id: Ib6026123770d21cc9f8960a1de361c8178b1b044
This performs sanity check that request *is* for a non-write module.
By handling the validation, the CDN layer can simply use the presence
of this header to route POST requests to the local datacenter.
Without validation, users could cause strange traffic patterns and slow
cross-DC database writes (which can involve many RTTs).
This is useful for AJAX widgets that need to post a payload to get a
response, but that don't actually change anything in the process. They
should be able to use the local datacenter.
Bug: T91820
Change-Id: I34248ddee33033e3d1d86c3391236259d917d4a7
* WMF has has ignore_user_abort() for *all* request in configuration
for many years. This brings this to default MediaWiki for all POST
requests, which are likely to do writes. Of course, some do not,
notably parse requests and previews, since GET cannot carry the
payload. Avoiding data corruption is more important though.
Bug: T102890
Change-Id: I11c8b0d99583a682f756cef9747ec5ba9751c5e3