Current configuration on the wiki
Find a file
Timo Tijhof 8b7f9129c3 Setup: Switch vendor error from echo+E_USER_ERROR to echo+exit
== Background ==

E_USER_ERROR is a deprecated error code for "recoverable fatal error",
a confusing description no longer used upstream and replaced by the
Throwable/Error concept, i.e. something that is meant to be fatal,
but could in theory be caught if you know what you're doing, via a
risky catch for Throwable instead of Exception.

What trigger_error with E_USER_ERROR does:

* (If we haven't sent headers yet)
  Emit header "HTTP/1.1 500 Internal Server Error".
* (If display_errors is enabled)
  Print the message, again, along with a strack trace.
* Notify set_error_handler letting you "catch" a non-Exception error.
* Write it to error_log, e.g. STDERR for composer serve and CLI,
  or an Apache/php-fpm error.log file.
* End with exit(1).

Issues:

* When enabling display_errors, the message is printed twice.
* The HTTP 500 status didn't work because headers are already sent,
  ... by the "echo" statement, right above it.

== Option A: throw Error $message ==

`throw Error($message)` is the natural successor to E_USER_ERROR.
I would recommend this, if
1) we didn't already echo it, and
2) the message didn't contain HTML, and
3) we needed to keep compat with someone catching this, or
4) we wanted a stack trace.

We echo it because display_errors can be off, and the most likely
audience for this is someone new to PHP/MediaWiki, installing in prod
or locally, when debugging is either intentionally off, or before
they're familiar with debugging modes. As such, we want to print it
ourselves either way, and printing it again as part of E_USER_ERROR
isn't needed.

The HTML part is important because one subtle difference between
trigger_error and throw Error is that the former allows raw HTML,
while the latter treats exception messages as plain text. Our message
intentionally uses HTML to link to docs in the browser, so this is
unhelpful.

The catchable-ness of this is not important to us, as no extension or
distro code (e.g. PlatformSettings.php) can run this early. There
are no runtime consumers of this error, only the end-user's browser.

== Option B: echo+exit ==

Given we already print the message, we just need to exit.

== History ==

* 2014 (Ie66794441): Add first ever Composer dependency (psr/log)
* 2015 (Ie47467657): Add LoggerFactory with check for missing Composer
                     dependency, to address a then-common issue.
* 2015 (Ib60261237): Move check earlier, to WebStart.
* 2017 (I633a6ff23): Move check earlier, to Setup.
* 2021 (Ia81903fb2): Remove redundant exit(1).

== Change ==

* Emit HTTP 500 before the echo.
* Keep echo (for browser) and error_log (for discovery via CLI or log
  file).
* Replace trigger_error with just exit(1), avoid duplicate message.

Bug: T379445
Change-Id: I6050ec4ca857d3c92c1c43f6a38e4154cd60e5d5
(cherry picked from commit 98c6d3c4c3511ecf60ffc693ff6c7164964270ca)
2025-06-13 16:57:53 +00:00
.phan Introduce minimal OTEL tracing library 2024-10-09 15:55:31 +02:00
cache In .htaccess deny files, use "Satisfy All" 2025-04-04 13:17:15 +00:00
docs Update Pingback address 2025-04-24 16:18:06 +00:00
extensions Update git submodules 2025-06-13 11:36:54 +00:00
images
includes Setup: Switch vendor error from echo+E_USER_ERROR to echo+exit 2025-06-13 16:57:53 +00:00
languages Localisation updates from https://translatewiki.net. 2025-06-10 07:33:07 +02:00
maintenance Update RfC links to bypass redirect 2025-06-03 16:37:04 -04:00
mw-config installer: Fix class name in example override 2025-01-25 15:07:10 +00:00
resources Link mw.Uri migration guide in docs and log warnings 2025-05-27 06:59:15 +00:00
skins Update git submodules 2025-06-10 06:34:34 +00:00
tests debug: Migrate E_USER_ERROR to throw Error in DeprecationHelper 2025-06-13 07:40:14 +00:00
vendor@e81b93847b Update git submodules 2025-06-04 00:58:33 +00:00
.dockerignore
.editorconfig
.eslintignore REST: validate JSON in tests 2024-09-20 15:42:32 +00:00
.eslintrc.json
.fresnel.yml
.git-blame-ignore-revs
.gitattributes
.gitignore Branch commit for REL1_43 2024-10-22 12:47:33 -04:00
.gitmessage
.gitmodules Branch commit for REL1_43 2024-10-22 12:47:33 -04:00
.gitreview
.mailmap build: De-duplicate two recent CREDITS additions via mailmap 2024-09-11 10:02:02 -07:00
.phpcs.xml build: Use inline ignore for MediaWiki.Usage.DeprecatedGlobalVariables 2024-09-26 18:15:32 +00:00
.stylelintrc.json
.svgo.config.js
.vsls.json
api.php
autoload.php SECURITY: Ensure emitted HTML is safe against Unicode NFC normalization 2025-04-10 15:56:06 +01:00
CODE_OF_CONDUCT.md
composer.json Update wikimedia/parsoid to 0.20.3 2025-06-03 20:40:11 -04:00
composer.local.json-sample
COPYING
CREDITS build: De-duplicate two recent CREDITS additions via mailmap 2024-09-11 10:02:02 -07:00
DEVELOPERS.md
docker-compose.yml dev(docker): Bump mediawiki-web container to dev/bookworm-apache2:1.0.1 2025-01-07 17:02:36 +00:00
FAQ
Gruntfile.js
HISTORY HISTORY: Add point releases 2024-10-01 02:21:50 +01:00
img_auth.php
index.php
INSTALL INSTALL: Document requirement for bcmath/gmp on 32-bit systems 2025-04-18 15:57:48 +00:00
jsdoc.json
load.php
opensearch_desc.php
package-lock.json build: Updating npm dependencies 2025-01-06 08:38:45 -05:00
package.json Merge "Update Codex from v1.13.1 to v1.14.0" 2024-10-16 17:26:41 +00:00
phpunit.xml.dist
README.md
RELEASE-NOTES-1.43 Start 1.43.2 2025-04-10 17:19:01 +00:00
rest.php
SECURITY
thumb.php
thumb_handler.php
UPGRADE

MediaWiki

MediaWiki is a free and open-source wiki software package written in PHP. It serves as the platform for Wikipedia and the other Wikimedia projects, used by hundreds of millions of people each month. MediaWiki is localised in over 350 languages and its reliability and robust feature set have earned it a large and vibrant community of third-party users and developers.

MediaWiki is:

  • feature-rich and extensible, both on-wiki and with hundreds of extensions;
  • scalable and suitable for both small and large sites;
  • simple to install, working on most hardware/software combinations; and
  • available in your language.

For system requirements, installation, and upgrade details, see the files RELEASE-NOTES, INSTALL, and UPGRADE.

MediaWiki is the result of global collaboration and cooperation. The CREDITS file lists technical contributors to the project. The COPYING file explains MediaWiki's copyright and license (GNU General Public License, version 2 or later). Many thanks to the Wikimedia community for testing and suggestions.