It was added in 2016 as part of SessionManager (Ic1ffea74f3, later
re-attributed to Ibb3e023e4e) by Anomie. It wasn't used at the time.
Basically, it is used for cases where we expect no logs, and the
presence of logs will then produce a failing test. The point is to do
something that PHPUnit will "complain" about by showing it. Emitting
a notice or warning is one way, another is to simply echo it, since
output is also unexpected and shown. The somewhat arbitrary mapping
from log levels to PHP error codes isn't used.
Later in 2017, he introduced the same class in php-session-serializer
(I2ebf59414ef9a9) where this part was already removed and replaced
by "echo". The version in core still used trigger_error.
== Why now ==
Triggering E_USER_ERROR is deprecated in PHP 8.4+.
Bug: T379445
Change-Id: Id1e1db80bc8fea39cd192716597e5e4a6f4966b0
(cherry picked from commit 5a1a8c14bd418c846498cd4ed99b77e45a0fcca1)
== What ==
This method was "Copied from OOUI\Tag", which no longer does this
since last year (I42c7a7b4d, 6e4e1a1796). Apply the same change here.
== Why now ==
Triggering E_USER_ERROR is deprecated in PHP 8.4+.
Bug: T381341
Bug: T379445
Change-Id: I1bac121caf746c30996dccd7fb95c4c240742951
(cherry picked from commit 751eca89fe473cc4a649e47dd54e9ab38f7c1957)
== Why ==
While psr/log represents our original an first use of Composer,
this is nowadays "just" another dependency among many. It does not
justify or help understand what to do next.
== What ==
Use the same "external libraries" terminology, as on mediawiki.org.
== 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).
* 2025 (I6050ec4ca): Replace deprecated E_USER_ERROR.
Change-Id: I890d1f285997ccbc04cdb378a69815982c2bf64f
(cherry picked from commit b538453cdc6438419d044854cc730706988cb908)
== 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)
For a long time now, since PHP 7.0.0, access to non-public properties
has thrown Error, not emitted E_ERROR.
Example - https://3v4l.org/dHChU
Our simulation of this in DeprecationHelper is meant to do what PHP
does, so, given we no longer support PHP 5.6 and can thus construct
Error ourselves, we should do the same.
This is identical - https://3v4l.org/koUqu
== Why ==
Referencing the E_USER_ERROR constant causes a deprecation warning
in PHP 8.4+.
== Change ==
The source change is straight-forward.
One of the tests (testSet, dataset 4 "fallbackGetterOnly") was
previously passing by accident. The source called trigger_error twice,
first with E_USER_DEPRECATED (via wfDeprecated) and then again with
E_USER_ERROR. Given that these are asserted via set_error_handler,
an event calback, the callback is run after the callback finished
(it does not interrupt), at which point only the last values are
reported to the event handler. Improve on this by explicitly hiding
the deprecation warning, and focus the case on testing the error.
Bug: T379445
Change-Id: Ia0aff9906102023370f3907e01962a5e1e369125
(cherry picked from commit d0920b8fb5be462a7aba5c21e47b02c2c2f5025f)
php8.4 prints more information into the string "{closure}".
The text is now "{closure:DeprecationHelperTest::testSet():124}"
Change-Id: I4c54a089ad981ba03da21f50cbeebb48ea8e1d28
(cherry picked from commit eea57fa92c043a1e0571b24d7a88a8d7f0ed3bf7)
* Update skins/MinervaNeue from branch 'REL1_43'
to e08046c12cb1850b839c8247b0045c18305651bb
- Localisation updates from https://translatewiki.net.
Change-Id: I4c280c50ee53d265fc2a435a67bc14545b265813
* Update skins/Vector from branch 'REL1_43'
to 7bf54eb9c8327f07e030d8a63cd5b9bae2b933e4
- Localisation updates from https://translatewiki.net.
Change-Id: Iebe94acf1c4dc2c0e85ef0441ff3863a64662860
* Update extensions/VisualEditor from branch 'REL1_43'
to 1c8f8c9017d88cbebbfba76d4689b1d97e49e7a3
- Localisation updates from https://translatewiki.net.
Change-Id: Ib0833e010dcbfe1c1e0808247a2694b02591cf37
* Update extensions/WikiEditor from branch 'REL1_43'
to c28f05727b0fad7f8f6a31e77e1f8fdf6a01a395
- Localisation updates from https://translatewiki.net.
Change-Id: I00452d84afe4b5139062c61a8724c9f908072f00
* Update extensions/TemplateData from branch 'REL1_43'
to c5141fccf9761aa8203af282cb13357b2c9ebeed
- Localisation updates from https://translatewiki.net.
Change-Id: Iceb93fb7ddada1d504d3e784ba4b63d133f8b4ad
* Update extensions/ReplaceText from branch 'REL1_43'
to 4a52f69150d3b69cb2ae8a22ed09a7bf22393b0a
- Localisation updates from https://translatewiki.net.
Change-Id: I084b94b11b9aa905d62458d9199f897e283e6de4
* Update extensions/OATHAuth from branch 'REL1_43'
to f357d4b40c5a48250824ee16962fd45d02fb2451
- Localisation updates from https://translatewiki.net.
Change-Id: I72d8ef9b98ec8615926bc1ff8c1cafae2cd59157
* Update extensions/Math from branch 'REL1_43'
to d77d0e44fe218ff4059b032cdfff6af47444e827
- Localisation updates from https://translatewiki.net.
Change-Id: Ide57a8da4fa5d3b6be4f911460fed252dbf32259
* Update extensions/LoginNotify from branch 'REL1_43'
to 5abe4f29cd859a63079e3d9a14e0f5b679c391b8
- Localisation updates from https://translatewiki.net.
Change-Id: Iee6d1df91590f907ee1fbf3a4ef416c01a586903
* Update extensions/Linter from branch 'REL1_43'
to 40e73c507756386ec3d8fd7f18371cfa3d85c93d
- Localisation updates from https://translatewiki.net.
Change-Id: Ib8d4a236fc90098b44a55530f99bb4c796cb4c09
* Update extensions/Gadgets from branch 'REL1_43'
to 1c01a4045b7ba5f254d45a6c14227b1bd20d8e5f
- Localisation updates from https://translatewiki.net.
Change-Id: I95601bdd63e94e66607db45607e28c5bd5ad5764
* Update extensions/Echo from branch 'REL1_43'
to b9fbb90a39ba6b1fa13053ab15062e18920aa47d
- Localisation updates from https://translatewiki.net.
Change-Id: I6e01f46e01f5d33c4e4cb03ea5e5f4a6ed85c0ac
* Update extensions/DiscussionTools from branch 'REL1_43'
to add13015066a2e25e6f27305c4ce9c7e3f2ed6c8
- Localisation updates from https://translatewiki.net.
Change-Id: If4318c642029b1305752fdcb2891869d14405e97
* Update extensions/ConfirmEdit from branch 'REL1_43'
to b113d5699ac46b526d585bcd8aa0c5b4adc61b12
- Localisation updates from https://translatewiki.net.
Change-Id: I84d5f70c73e017af26e49fb984eb0d2e69ab3de4
* Update extensions/Cite from branch 'REL1_43'
to 38cb551ee285c1df2e848406ce74e0d4e0729553
- Localisation updates from https://translatewiki.net.
Change-Id: I2c22eea962de1e0f52a22790fa946b551e1c7692
* Update extensions/CiteThisPage from branch 'REL1_43'
to e796fb8129164509265bb6aa92465ce3dc64a471
- Localisation updates from https://translatewiki.net.
Change-Id: Id95ffef3d2f3d19ced68d9300dba71fdf469225c
* Update extensions/AbuseFilter from branch 'REL1_43'
to 60800c48785657e7a3a2d066136cdca0bca7f137
- Localisation updates from https://translatewiki.net.
Change-Id: If03a602c0fdd168017f2a455fb1e71f3b305981d
File::getShortDesc() is documented to return HTML, but some handlers
return unescaped plain text.
Bug: T395834
Change-Id: I150f0215339b4ac18254fce2be138b1cde2277d5
(cherry picked from commit b2a9cc1564397e27fd80e44e99e1905fcbd10684)
* Update vendor from branch 'REL1_43'
to ff6edc415996157f9f80020d273554e2d211278f
- Bump wikimedia/wikipeg to 4.0.2
This is the same as 4.0.0, released because 4.0.1 was unpublished.
Change-Id: Ic98898b5c5fb62505fdd81cc0a3c37e1f3b5e8e2