In theory PHP should use coerce objects with a __toString method
to string when passing them to a method which has a string-typed
argument, but with the native Exception class this doesn't seem
to be working, so cast explicitly.
Bug: T388171
Change-Id: I310b97164877445837babed2a4c47795f1c2c277
(cherry picked from commit a14ef848f758612ac9d4e8c881ecdbbccf3e1158)
E_STRICT is deprecated in PHP 8.4.0.
MediaWiki (and almost all extensions) no longer produces errors at this
level.
To not break the compatibility, let's converts all E_STRICT level errors
to E_USER_NOTICE, which is also mapped to warning severity.
Using '@' operator to avoid generating the deprecation warning of
E_STRICT.
This should addresses the deprecation warning of E_STRICT when another
warning or error is raised.
Bug: T375707
Change-Id: I5937cacdf5b01614042a06d4deb5112ffff51727
If an exception is thrown or an error is raised during HookContainer
construction, don't be surprised when you can't get a HookContainer.
When checking if we need to roll back transactions, use peekService()
instead of isDisabled(). According to the disableService()
documentation, peekService() will always return null for a disabled
service. If the service hasn't been created, there can be no
transactions open and so there is no point in rolling back.
It's not necessary to catch DBError exceptions from peekService(),
since it never calls the instantiator.
Fix phan error by broadening the onLogException() parameter type. Phan
is correct, the parameter is not guaranteed to be
Exception|ErrorException and so the previous documentation was wrong.
Bug: T379125
Change-Id: Ie5ec2bd1ecfb0114f3d00fc28b2c5e3db9bd87c0
(cherry picked from commit 5cf3cd03dfd3f7acca4d78bf12054f3c315fee28)
Implicitly marking parameter $... as nullable is deprecated in php8.4,
the explicit nullable type must be used instead
Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a
Break one long line in SpecialPage.php
Bug: T376276
Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
Why:
* When code throws a UserNotLoggedIn error for a temporary account,
this takes them to Special:UserLogin and asks them to log in to
an account
* Users using temporary accounts are less likely to have a named
account, so should instead be sent to Special:CreateAccount
(as described in T358586)
* When doing this, the warning message should be customised to
talk about the user needing to create an account (and not
log in)
What:
* Update UserNotLoggedIn to redirect to Special:CreateAccount
when the user is logged in to a temporary account
** The code which constructs the exception object can override
this and force the redirect to always be to Special:UserLogin.
* When the redirect is to Special:CreateAccount, allow customising
the message shown by adding a '-for-temp-user' suffix to the
message key in UserNotLoggedIn.
** This suffix is only added if the resulting message exists,
so that code can choose whether they need a message that is
different to the one on Special:UserLogin.
* Update SpecialPage::requiredNamedUser to allow special pages to
force the redirect to always be to Special:UserLogin
** This is made use of in Special:ChangeEmail and
Special:ConfirmEmail, as these special pages only make sense
for use with an existing account.
* Update and add message keys to allow a different message for
Special:CreateAccount.
* Update and add tests for these changes.
Bug: T358586
Change-Id: Ie0dd06f51b1e2b85eef6be377f673a02732ce604
Callers should not catch an unchecked exception, so it doesn't belong
in a function signature. Unchecked exceptions indicate a coding error,
which by definition the code will not be able to handle correctly.
If any of these exceptions were supposed to be in response to an edge
case, user input, or initial conditions, then they should be changed
to a runtime error. If the exception class cannot be changed, then
the annotation should include a comment explaining its purpose and
prognosis.
Bug: T240672
Change-Id: I2e640b9737cb68090a8e1cb70067d1b74037d647
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.
Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.
Change-Id: I1da4b272a6b28c419cc8e860d142dae19ca0bbcf
Also remove @var from const, the type is given by the value of the const
and does not need documentation.
Change-Id: I65636f2b97b44387c4320ebfb4be6c81d6f771b9
Follow-up to 298ec8382b, which replaced
`public $errors` with `public $status`, causing T372181.
* Add a deprecated fallback getter/setter for $errors
* Make $permission private and add a deprecated getter/setter
* Make $status private
Bug: T372181
Change-Id: If44b2256289d6bde9e9abb901d9dc145555c971f
If the error back-trace is wide enough, it will make the table
to overflow behind it's first column in an unexpected way that
backtrace's left side which is the most important part will be
hidden in an overflow so let's apply the directionality from
outside of the table.
Change-Id: I862ffc835c5a4a627546ef69d19056adfc285442
This apparently supposed to happen via mw-content-ltr but it actually
isn't and supposed to also use LTR when exceptions details isn't enabled
which both don't work and actually the latter isn't needed as there is
a translated RTL message there make it unnecessary to be in in LTR.
More about the details in the linked bug.
Bug: T371804
Change-Id: Icc3562a7b9a72408790c75a93994c0d63c0f66e2
get_debug_type() does the same thing but better (spelling type names
in the same way as in type declarations, and including names of
object classes and resource types). It was added in PHP 8, but the
symfony/polyfill-php80 package provides it while we still support 7.4.
Also remove uses of get_class() and get_resource_type() where the new
method already provides the same information.
For reference:
https://www.php.net/manual/en/function.get-debug-type.phphttps://www.php.net/manual/en/function.gettype.php
In this commit I'm only changing code where it looks like the result
is used only for some king of debug, log, or test output. This
probably won't break anything important, but I'm not sure whether
anything might depend on the exact values.
Change-Id: I7c1f0a8f669228643e86f8e511c0e26a2edb2948
In change I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83 I am planning to
make Wikimedia\Message\MessageValue use it, and we try to pretend that
it is a library separate from MediaWiki, so it makes sense to move
MessageSpecifier to the same namespace under Wikimedia\.
Bug: T353458
Change-Id: I9ff4ff7beb098b60c92f564591937c7d789c6684
Changes to the use statements done automatically via script
Addition of missing use statement done manually
Change-Id: Id9f3e775e143d1a17b6b96812a8230cfba14d9d3
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
Setting this URL parameter will replace the default skin with a
"micro-skin" that omits most of the usual interface elements,
making the page suitable to be displayed in a small popup window.
Its design (such as it is) is mostly based on Vector 2022.
In the future, we might allow normal skins to serve this mode too,
if they advise that they support it by setting a skin option.
For now that is out of scope.
The login/signup process is otherwise completely normal. To make use
of it, launch the login page in a popup, and set &returnto=... to
redirect back to your own success page, which should communicate the
successful login to your app and then close itself.
The display=popup / display=page vocabulary is borrowed from the
OpenID Connect spec.
Bug: T362706
Change-Id: Ic7cbbe98344b25d2e965750e0c4429ce157163ed
This patch introduces a namespace declaration for the
MediaWiki\Json to FormatJson and establishes a class
alias marked as deprecated since version 1.43.
Bug: T353458
Change-Id: I5e1311e4eb7a878a7db319b725ae262f40671c32
This was introduced to allow maintainers during local development,
and e.g. when debugging in production, to capture silenced runtime
warnings, such as those silenced via AtEase or the `@` PHP operator.
These are not expected to be of interest to capture by default on
web requests, hence placed in a separate channel that e.g. one would
only enable during development, or when debugging.
When this was introduced, MediaWiki was only just starting to
experiment with PSR-3 structuerd logging, and thus it hardcoded JSON.
Now that we support structured logging natively, this has been
obsoleted by the "error" channel (for warnings in production),
and (since last December) the "silenced-error" channel (for debugging
and development) with commit f6cb39979b (I34b19837c3).
With the above two alternatives available, there is no longer a need
for the duplicate "error-json" channel.
Bug: T193472
Change-Id: I7a6e6fa52a47a29ec04411a6c8b05e005a0a4fc7
* Avoid looking up the message in the database. We might be
displaying a readonly error or the connection might be in a
broken state, and there is little reason for per-wiki
customization of error messages in any case.
* Prevent a user-language lookup if the user is not available
(this happens e.g. for errors in load.php).
Bug: T127233
Bug: T356578
Change-Id: Ib5ea11a39257bed7381faa277a5df0bf4d0f5e97
The idea is that all formatters that need the user language or
other request specific context should be instantiated by
FormatterFactory.
Change-Id: I8334cc89dcf0f293298b82e004116be50a90f0d1
It's now deprecated to use the individual error printing functions in
MWException or to override them. Printing MWException now works the
same as any other exception, and happens in MWExceptionRenderer.
It's still allowed to override MWException::report() to replace the
entire error page, for example in ErrorPageError.
Bug: T353444
Change-Id: I66d896f6f229b90e6ba9949311b56a6b6ab3da3d
This extracts the MediaWikiEntryPoint base class and ActionEntryPoint
class from the MediaWiki class. MediaWiki itself be deprecated.
The intent is to create other subclasses of MediaWikiEntryPoint for the
use by other entry points such as thumb.php or api.php. This will allow
us to share code between entry points, and make these entry points
testable by moving their implementation into a class.
Bug: T354216
Change-Id: Ib70e4e67e4cb1b65ac218c095864fb6eb43d0929
Replace some other global variable checks with MW_ENTRY_POINT too.
This unfortunately makes it difficult to override the result of
isCommandLine() for testing. However, the existing tests weren't
really checking anything useful, but rather just duplicated the real
code, so I won't miss them.
Bug: T313841
Change-Id: I8bc200d67877ce04f80fd587481a76c7df629d51
Changes to the use statements done automatically via script
Addition of missing use statements and changes to docs done manually
Change-Id: I443aada1c18c8628b02671aa9fd6f441961e5c2e
Follows-up 4f08bb3be9 (I240b75f5a4), which improved the "error" channel
to make use of the PSR-3 severity level (instead of defaulting to
ERROR).
This change exposes the suppressed errors to a new channel,
with a forced severity level DEBUG.
The formatted message is unchanged and reflects the original severity
through its "message" (i.e. "PHP Notice", "PHP Warning", etc.)
Bug: T193472
Change-Id: I34b19837c391ff4acdb55fc0c310c0f554f15da2
Callers should use OutputPage::setPageTitleMsg() instead of the code
inside ::prepareErrorPage() which invokes ::setPageTitle(), in order
to opt in to proper HTML escaping of the message argument. For
backward compatibility, preserve the old behavior of
::prepareErrorPage() but deprecate passing explicit parameters to that
method and instead suggest that callers explicitly call
OutputPage::setPageTitleMsg() themselves.
Bug: T343994
Bug: T343849
Change-Id: I12b19198f09504683ecbeb72c581946c91a744a6
The base phan config uses a file_exists check to determine whether to
use the namespaced class name, but it doesn't work when running against
core because MW_INSTALL_PATH isn't set. So specify the type in the local
config, and remove @phan-var annotations added in I6bbdbbe6.
Also use `::class` instead of string literals for classes.
Change-Id: I994a0ed32ea948253ed07ee3cc8868a0eaa6d8b9