Commit graph

123 commits

Author SHA1 Message Date
Ebrahim Byagowi
ede4d6ec12 Add dark mode support to plain html outputs
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
2024-06-09 15:03:14 +03:30
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
Timo Tijhof
d1c85b2f5d entrypoint: Restore doc grouping for MediaWikiEntryPoint
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
2024-01-05 20:15:46 +00:00
Umherirrender
f4ef430d28 Use ::class for class name resolution
Change-Id: Ic74a3d317c9d36509a50c658e52fad65026e7ac7
2023-09-21 23:27:28 +02:00
Amir Sarabadani
b1390cdef7 Reorg: Move NoLocalSettings to Output/
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
2023-09-06 14:39:59 +02:00
Amir Sarabadani
d8e542abf9 Reorg: Move three output related classes to includes/Output/
And namesapce them:
 - StreamFile
 - OutputHandler
 - OutputPage

Bug: T321882
Change-Id: Iedf8d88c595e580f2d8f0734c92aa5c45618ba33
2023-09-05 19:36:42 +01:00
Aaron Schulz
94484a020f WebStart: Document output buffering in wfWebStartSetup()
Change-Id: I012a14642ef024de698d318520710b410011c9ef
2023-03-10 05:03:29 +00:00
Timo Tijhof
4f4f283d1d Setup.php: Remove internal use of $IP
Follows-up bedd996fe6 (I157abfd9049fb838).

Change-Id: Ib7a7e26f564ca996f1de3edd37b2359c5abec9d2
2022-05-13 16:32:09 +00:00
daniel
bedd996fe6 Setup.php: clarify the use of $IP.
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
2022-05-03 11:53:05 +02: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
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
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
Umherirrender
44fd53fee3 Using @return never documentation on always-throw-function
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
2021-09-07 17:29:03 +02:00
jenkins-bot
9c688e1ce3 Merge "WebStart: Avoid conditionally declared functions in this file" 2021-03-12 03:00:18 +00:00
Florian
e9d9bc48d4 WebStart: Avoid conditionally declared functions in this file
Defining functions conditionally seems to break preloading
functionality, as the function is tried to be redeclared.

Bug: T240775
Change-Id: I7d1df9f13927f0a7af33f9ee955b0ed8dc47a359
2021-03-12 02:39:27 +00:00
C. Scott Ananian
f4301f8a64 MWLBFactory: rename magic HTTP header for opting out of sqlite write lock
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
2021-02-04 13:24:25 -05:00
Timo Tijhof
9463b0105b Setup: Move simple shortcuts together in Setup.php and improve docs
I've moved the simple config expansions that don't depend on anything
else in Setup.php together, more compactly.

Change-Id: Iefb7f8ffdca70bcfbf7cbf49f7939747c5ab0d76
2020-03-14 23:10:07 +00:00
Timo Tijhof
bc1f601382 docs: Improve "Entry points" documentation page
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
2020-02-04 21:44:38 +00:00
Timo Tijhof
a8d5c4c88a WebStart: Avoid DB or uselang for nonwrite-api-promise-error message
Make the code easier to reason about by not involving global state from
LBFactory, RequestContext, SessionManager, and User.

Bug: T189966
Change-Id: I88d2bf58ebd481009ce295335d730a34dbb277fb
2019-08-25 19:15:34 +01:00
Reedy
9f2ffdfbd4 Remove "Squiz.WhiteSpace.FunctionSpacing" from phpcs exclusions
Change-Id: I78b3315f26ab91b6b443f5b028a635552f82f5a3
2019-05-11 02:44:26 +01:00
jenkins-bot
37d9285d78 Merge "Setup: Move mbstring.func_overload from WebStart to Setup" 2018-04-18 16:22:16 +00:00
Timo Tijhof
6fe856c4bd WebStart: Remove deprecated $wgRequestTime
This variable is not read anywhere in Wikimedia Git.

Follows-up 06ba5ca383.

Bug: T189966
Change-Id: Ib86ebc44b12fee3a986838c5a302540b97066e5a
2018-04-17 23:00:32 +00:00
Timo Tijhof
5c94aed0c3 Setup: Move mbstring.func_overload from WebStart to Setup
Follows-up 26c2d03c17, 41d1fa1c3a and r11547 (c7f363f886).

Also add references to the relevant tasks about why the check
exists.

Bug: T189966
Change-Id: Ic1f0c79a1b5638bb30351a0cab55699931d1fded
2018-04-17 23:09:58 +01:00
Timo Tijhof
3aa0b0567f WebStart: Remove redundant unset() for $IP
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
2018-04-17 21:44:31 +00:00
Timo Tijhof
665e9b7bf2 Convert OutputHandler functions to a class
* 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
2018-03-20 21:11:32 -07:00
Timo Tijhof
0d5f8f6bee WebStart: Remove use of realpath() for $IP
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
2017-11-29 21:51:44 +00:00
Timo Tijhof
8b7bafec21 Setup: Merge PreConfigSetup into Setup.php
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
2017-10-24 23:50:54 +00:00
Tim Starling
41ea7e2fef Split common pre-setup code out of WebStart/doMaintenance
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
2017-08-23 14:00:34 +10:00
Kevin Israel
e2ac8a7306 WebStart.php: Update the file's doc comment
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
2017-05-26 14:25:04 +00:00
jenkins-bot
17eda64357 Merge "includes: Replace implicit Bugzilla bug numbers with Phab ones" 2017-02-28 00:51:57 +00:00
Tim Starling
f193271cff Log a backtrace from the culprit location if headers were already sent
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
2017-02-23 14:10:12 +11:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
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
2017-02-21 18:13:24 +00:00
Chad Horohoe
edc9edbc76 Remove check for MW_NO_SETUP
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
2017-01-12 17:05:06 -08:00
umherirrender
72632115d6 Fix various phpcs error from last security patches
Found by tests:
https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs-trusty/1069/console

Breaking merges

Change-Id: If01b94705cd7b939ac380053730b1b602c838a8e
2016-05-20 20:20:36 +02:00
Brad Jorsch
26c2d03c17 SECURITY: Check for mbstring.func_overload at runtime
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>
2016-05-20 09:47:54 -07:00
Kunal Mehta
b9668d6d80 build: Update mediawiki-codesniffer to 0.6.0, add "composer fix"
* 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
2016-02-17 02:54:42 -08:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Max Semenik
93faec7fe0 Remove REQUEST_TIME_FLOAT hack for old PHP
Change-Id: Id11f4f479d5225d92e38b2ae83b25315591b73d6
2016-02-11 22:43:23 +00:00
Max Semenik
231d152d63 Remove register_globals and magic_quotes_* checks
Yay, this crap is finally gone as of PHP 5.4!

Change-Id: I2cb01b5bf0fdde4c8cf5286ef6aff93ac45e99fd
2016-02-11 11:11:49 -08:00
umherirrender
54c1e18eec Remove various double empty newlines
The double empty newline is not needed between functions, variable or at
end of file

Change-Id: Ib866a95084c4601ac150a2b402cfa184ebc18afa
2015-12-27 18:55:12 +00:00
Reedy
493db97bfa Fix HHVM RepoAuthorative mode again
Change-Id: I0fe75797ebe1c8c22be603a62102bd25bce29f49
2015-12-14 15:46:37 +00:00
Gergő Tisza
c3ea1b85b4 Move PSR-3 support check right after autoloader setup
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
2015-12-13 22:18:07 -08:00
Aaron Schulz
cbdb16da1d Add header to flag API POST requests with no write intentions
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
2015-11-06 22:21:31 +00:00
Amir E. Aharoni
94508ab5b2 WebStart.php: Make lines shorter to make phpcs happier
Change-Id: Ifbcf572a08837e9572cc4ed9bd274d4e5ad676ab
2015-09-26 12:45:52 +03:00
Ricordisamoa
df9ebe6f99 Fix some space-related phpcs warnings in includes/
Change-Id: I7cf7206696a5e77bc02e3630d1d88d4c176ea844
2015-08-15 08:56:03 +00:00
Aaron Schulz
66e723e6be Try to make POSTs as transactional as possible
* 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
2015-08-12 23:56:59 +00:00
Chad Horohoe
4b619eb7bd Remove $wgRUstart, unused
Change-Id: Ia57f8fb2da4eed6b185ea0592d521e3119411f0e
2015-04-16 15:28:37 -07:00