| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Change-Id: I56b31870ce9be46d15fcd9095f9a12e0f2488ed9
|
|
|
|
|
| |
Bug: T353458
Change-Id: I35864ad9bd48701703c51367d62f8ebde963c52d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Why:
- In I884433ad1def225590dd304a015f3a24e8d32fe5, we added additional
error logging to MultiHttpClient for internal cURL failures.
- However, these errors aren't being surfaced in production currently,
because the 'http' logging channel that the logger injected into
MultiHttpClient is using is only configured to log ERROR and higher
levels.
- Promoting these errors into warnings would be consistent with the
behavior of GuzzleHttpRequest, which already logs errors for
connection-level errors, and also provide a useful stack trace.
What:
- Promote MultiHttpClient warnings into errors.
- Add a new optional caller parameter to MultiHttpClient methods
to allow filtering errors by calling code.
Bug: T384717
Change-Id: Ib5d4913b384cb86ec7066f5788c4fb9d3dce10a7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now that MessageParser has been split out, MessageCache has no
remaining calls to Language methods except for getCode().
The only non-deprecated usage of Language is as a parameter to the
callbacks registered by the MessageCacheFetchOverrides hook. Review of
all MessageCacheFetchOverrides handlers in Code Search shows that none
are actually using the Language parameter. None of the closures even
declare a third parameter.
A Language object is a complex and inefficient way to pass a language
code.
So:
* Revert the deprecation of string language codes in the language
passed to MessageCache::get().
* Pass a string code internally instead of a Language object.
* Relax the validation applied to string language codes, so that it is
similar to LanguageFactory. Callers were often passing a Language
object with a code like "qqx" which is not a known language tag, but
is allowed as a parameter to LanguageFactory::getLanguage().
* Remove the third and fourth parameters to the override callbacks.
* Remove the LanguageFactory constructor parameter.
Depends-On: Ic4beec7373e799e51082957ab96d26e4c692c413
Change-Id: Ia9ddb1b83a6f20d3f7cee2afaf5987dbc99ea00b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Why:
- I95ef4219cc7b45d20f784dab233450467551334d updated MockAuthorityTrait
to be in sync with the base interface.
- The $block parameter wasn't captured by one of the closures added in
this change, causing an E_NOTICE on PHP 7.4 and E_WARNING on PHP 8.0
and newer.
What:
- Capture the variable in the closure.
Change-Id: I38d32fc90a1f558dc50ed44beabf87f2973cbff9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There's about 100 callers of the DatabaseBlock constructor in core
tests, most of them passing an address parameter which needs access to
the global service container to parse.
Many are passing the constructed object straight to
DatabaseBlockStore::insertBlock(). So add insertWithParams() for their
convenience, which has some handy shortcut parameters, has service
access, and throws on failure. The calling code tends to be shorter
than before.
For unit tests trying to construct DatabaseBlock objects without a
service container, direct construction of BlockTarget subclasses is
warranted. Add a default to the $wikiId parameters for their
convenience.
MockBlockManager had its own 'target' parameter, mixed in with block
options, carrying its own special idea of a target, which conflicted
with DatabaseBlock's new 'target' parameter. Harmonise the parameters
and fix the callers.
Bug: T382106
Bug: T385966
Change-Id: I78b45a6003b62962211379c36da5587081f90f00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For the linked bug, I would really like GenderCache to use
UserOptionsManager. But all user-related services need UserNameUtils
which depends on TitleParser, and TitleFormatter needs GenderCache to
correctly format NS_USER titles. Having TitleFormatter and TitleParser
together in a single class creates an intractable dependency loop.
So, split MediaWikiTitleCodec. On Daniel's advice I converted the
existing TitleParser and TitleFormatter interfaces to classes. The code
was always structured to allow this. Extensions require surprisingly few
updates. MediaWikiTitleCodec remains only for its deprecated static
methods.
The implementations were split cleanly with no need for shared code. The
tests did have a little bit of shared code, for round-trip testing, so I
added a shared test base class for that.
Bug: T386584
Depends-On: Ibf307e953b666d8923bc96a507907421558da378
Depends-On: I47e83e95727e6830500e9af7cff92e7d3f91167e
Depends-On: Id9c045864a9dc3c640a896e6b34f516c7e42b050
Change-Id: I3dcce6639ed01c7611a663671c872cec775bdaa2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since f42320b1093de029e238542c8bfe979c589e0775 (2023), several methods
of the Authority interface accept an optional $status parameter, and
mutate it to add relevant error messages and other information.
Several methods were also added. MockAuthorityTrait was never updated
to match the changes. Add the optional parameters and the new methods.
This fixes incorrect expected values in RollbackPageTest - the real
RollbackPage code depends on the $status having an error message if
the action is not authorized.
Also fix calling $permissionCallback to always use consistent argument
types. Previously it was sometimes called with arguments like
`$permissionCallback(string, ?PermissionStatus)`, and sometimes
`$permissionCallback(string, PageIdentity, ?PermissionStatus)`,
depending on which Authority method were used by the code under test.
These changes may result in test failures in extensions. I will fix
them if we find any.
Change-Id: I95ef4219cc7b45d20f784dab233450467551334d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, BlockErrorFormatter would only generate a human-readable
error message for permission errors caused by blocks, and
PermissionManager would build a PermissionStatus object out of them.
Machine-readable block info was added later: UserAuthority would add
a Block object to each one, then finally each API module (via
ApiBlockInfoTrait) would generate block info from these Block objects.
Now all of this happens in BlockErrorFormatter and PermissionManager.
For compatibility with older code, remove the extra information when
using the deprecated PermissionManager::getPermissionErrors() method.
This is a small hack that can be removed together with that method in
the future.
The changes seem to make a workaround for T357063 in ApiQueryInfo
unnecessary (tests added in c55d33ef11 still pass).
Bug: T357063
Change-Id: Id121d51a24fbb1d8210e60bdd54c61b16938dd70
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Why: before we change how we do dummy revisions, we should have tests in
place that check which events and hooks get fired, and how updates to
other parts of the system propagate when dummy revisions are inserted.
This protect us from unexpected changes in behavior.
Bug: T198297
Bug: T384691
Change-Id: I1f8c0ac68b91f101699fe9a9cf9ccbada514030a
|
|/
|
|
| |
Change-Id: I23ce3b4d26bbe58257b449993a54c45093007a3e
|
|
|
|
| |
Change-Id: I0f8a8cac36015bba52aea3ee2affd92f83d3574a
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Why:
- Improve test readability by removing awkward boiler plate code
for checking whether an event or hook was triggered.
What:
- Introduce ExpectCallbackTrait for asserting the number of times an
event or hook was triggered.
Bug: T376063
Change-Id: I97f83f38c0fd14c041525f8faa00cc164d7d1124
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
psr/log 3.0.0 adds this return type, forcing all subclasses to have it
too. MediaWiki does not yet declare compatibility with that version, but
if people don’t use the composer merge plugin (or do use it, but also
still have separate vendor directories in some extensions or skins e.g.
to run development tools like phpcs), and they are also on PHP 8.0 or
later (on PHP 7.4, composer should not permit installation of psr/log
2.0.0 or later which requires PHP 8), then it’s possible for them to end
up with psr/log 3.0.0 in some other vendor directory, and this version
may then override the one MediaWiki depends on. In general, this kind of
composer accident is not something we can protect against (MediaWiki
can’t support all incompatible library versions that may end up in the
autoload path), but for this specific case the fix is very simple, fully
compatible with the older version of psr/log as well (adding a return
type in a subclass when the superclass doesn’t have one is always
allowed), and something we’ll have to do sooner or later anyway, so I
propose we just do it now.
Bug: T356451
Change-Id: I49562ac7f1a71e82cab79fe44296feea573e26d4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Same as Ia294bf4 did for 1-line comments. This patch removes slightly
more complex 2-line PHPDoc comments that don't add any new information
to the code, but literally repeat what the code already says.
They say "don't document the code, code the documentation", and we
are doing this more and more. We just tend to forget to remove the
obsolete comments.
Note I'm also removing a line of text in a few cases when it's very
short and literally says the same as the method name. Again, such
comments add zero new information.
Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Why:
* The CheckUser extension wants to use the MockTitleTrait
to make a mock title for a unit test.
* The code being tested calls Title::isSpecialPage, but this
method is not defined in the mock Title returned by
MockTitleTrait::makeMockTitle.
* Therefore, MockTitleTrait should mock the return value of
the ::isSpecialPage method which only needs to check if
the namespace is NS_SPECIAL.
What:
* Define Title::isSpecialPage in the Title class mock returned
by MockTitleTrait::makeMockTitle
Bug: T370083
Change-Id: If5a5b98299674264c33c6a87f5e0877ae0e1b241
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Why:
* WikiMap::getWiki is a static function that can't be mocked in
tests, and returns null if a wiki is unknown.
* Some integration tests call pathways that require the test
environment wiki to be recognized.
What:
* Add a trait that overrides the SiteLookup service to recognize
the current wiki in the test environment.
* The trait has one method, ::mockWikiMap, which is copied from
CentralAuth's SharedDomainHookHandlerTest.
* This work is being done now to support T376315.
Change-Id: I237f7a0490501be2dd7e841f3dd5ac6ce8b40889
|
|
|
|
|
|
|
|
| |
Use for engines that might be able to optimize some queries or
installations where the number of total hits is not particular useful.
Depends-On: I97e11dacf17bc7633a99078e1bf1a4d3eaee852e
Change-Id: I3550063d1b297e4caab3426e3ef66804b985e5fa
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Applied return type hints to improve type safety in Message classes.
Adjusted constructors to specify parameter types for consistency.
Enhanced `newFromJsonArray` in `ScalarParam`, `DataMessageValue`,
and `MessageParam` to clarify deserialization logic.
Key updates:
- Added `: string` return types for `getLangCode`, `getKey`, `dump`.
- Added `: array` return type for `getParams`, `getData`, `toJsonArray`.
- Revised `ScalarParam` JSON parsing to ensure a consistent return.
These adjustments enhance type safety across the Message classes.
Depends-On: Id7cc576693f5f1830e1d261cb13c626c901fb40f
Depends-On: I260e3f526be10f7b11e5c77a1e300590c6fc5b2b
Depends-On: I3c318273856d15407c71cb9b4ab7c23a0debb314
Change-Id: I7e50be91c01b4b70e1d1380651f001e35bd60523
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add more precise type hints to every method I could find that takes
message params as arguments, so that Phan will warn if bool or null
is passed, which is deprecated (T378876).
Errors found in this repository thanks to these checks
are fixed in I286a4a51e879bdf61f65c87dc078621c51045bee.
Bug: T378876
Change-Id: I3e0df790ff9db2fa630f82408a7254a359fe61ca
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This was seen in WMF production during a train deployment, where namespacing of classes,
which had been serialized (for example CacheTime), along with our PSR-4 definitions may result
in cases where PHP tries to load the same PHP file more than once. Combined with non obvious
error messages, require_once gives us better behaviour and error messages.
More explicitly:
In T378006, the autoloader is entered from class_exists(), and the class has a filename
resolvable with PSR-4 which is already loaded by a non-PSR-4 class name. Using require_once
would allow class_exists() to return false in that case.
In T372500, the autoloader is entered from unserialize(). It looks like require_once would
just give you a more informative error message.
Bug: T378006
Bug: T372500
Change-Id: I928f29198af9baf81a3cae604b3adf41595c2176
|
|
|
|
|
|
|
|
| |
Changes to the use statements and some additions
are done automatically via script
This also updates @covers tag for the namespaced classes
Change-Id: I859ba6d05018c99710b744e2becab432410d3bca
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix two problems that made it difficult to convert between Message
and MessageValue, or to write code that could accept both of them,
as exemplified by the StatusValue class:
* Implement a common interface
* Use the same internal format for message parameters
While these changes should be compatible with most of existing code,
where the authors were courteous enough to simply call methods such
as Message::numParam() and not look inside the values they return,
it is potentially a breaking change for anything that depended on
the formatted params being arrays or accessed their keys.
Example patches: https://gerrit.wikimedia.org/r/q/topic:message-param
Notable changes:
* Message and MessageValue now both implement MessageSpecifier
(only Message implemented it before).
* Message::numParam() and other static methods for encoding params
now return MessageParam objects, instead of special arrays.
Use these MessageParam objects internally in Message.
* Narrow down the return type of MessageSpecifier::getParams() (it
was just `array`, allowing any type in the array). Narrow down the
types for Message::params() and MessageValue::params() to match.
* Deprecate MediaWiki\Message\Converter. As a replacement add
MessageValue::newFromSpecifier(), which is analogous to
Message::newFromSpecifier(), but without weird legacy edge cases.
* Make StatusValue::getMessages() return MessageValues. Remove code
that converted between Message and MessageValue, no longer needed.
* Update many type declarations and comments to use MessageSpecifier
instead of MessageValue, as well as a couple of tests that depended
on implementation details.
Bug: T358779
Change-Id: I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This adds support for serializing/deserializing objects which
implement the JsonCodecable interface from the wikimedia/json-codec
library used by Parsoid. JsonCodecable allows customizing the encoding
of objects of a given class using a class-specific codec object, and
JsonCodecable is an interface which is defined and can be used outside
mediawiki core.
In addition json-codec supports deserialization in the presence of
aliased class names, fixing T353883.
Backward and forward compatibility established via the mechanism
described in
https://www.mediawiki.org/wiki/Manual:Parser_cache/Serialization_compatibility
Test data generated by this patch was added in
I109640b510cef9b3b870a8c188f3b4f086d75d06 to ensure forward
compatibility with the output after this patch is merged.
Benchmarks:
PHP 7.4.33 PHP 8.2.19 PHP 8.3.6
BEFORE AFTER BEFORE AFTER BEFORE AFTER
Serialize: 926.7/s 1424.8/s 978.5/s 1542.4/s 1023.5/s 1488.6/s
Serialize (assoc): 930.2/s 1378.6/s 974.6/s 1541.9/s 1022.4/s 1463.4/s
Deserialize: 1942.7/s 1961.3/s 2118.8/s 2175.9/s 2129.8/s 2063.5/s
Deserialize (assoc): 1952.0/s 1905.7/s 2107.5/s 2192.1/s 2153.3/s 2011.1/s
These numbers definitely do not have as many significant digits as
written here. But they should be sufficient to demonstrate that
performance is not impaired by this patch and in fact serialization
speed improves slightly.
Bug: T273540
Bug: T327439
Bug: T346829
Bug: T353883
Depends-On: If1d70ba18712839615c1f4fea236843ffebc8645
Change-Id: Ia1017dcef462f3ac1ff5112106f7df81f5cc384f
|
|/
|
|
|
| |
Bug: T353458
Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
|
|
|
|
| |
Change-Id: Ib59455882f703f4473f1ff2d14dc3d8a7caa034e
|
|
|
|
|
|
| |
Also use namespaced version of the class
Change-Id: Idce009e4d0a8e77f95244d95db008d64a2025c5f
|
|
|
|
|
|
|
|
|
|
| |
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: I56a1d27ba2dfbcdd929a0e0c96664bc2a31e38f2
|
|
|
|
|
|
|
|
|
|
| |
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: I46f46f1855ca32c89a276b06f4e2051ff541886e
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Why:
* Maintenance scripts in core have low test coverage
* Improving this will reduce the chances of regressions and bugs
What:
* Create a MockLocalisationCacheTrait which is used to generate
a mock LocalisationCache instance which has a limited and fixed
set of message keys
** This is created by splitting code from LocalisationCacheTest
* Create AllTransTest and DumpMessagesTest which make use of this
new trait.
Bug: T371167
Change-Id: Ie814c8136504d2af94ec9377d64b19d3a0e25eed
|
|/
|
|
|
|
|
|
|
|
| |
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: I2606072015d71b4bdda70a7c149d9f55ac205a3c
|
|\ |
|
| |
| |
| |
| |
| |
| | |
(plus some other tweaks to code using array unpacking weirdly)
Change-Id: I76a280548952ee5144ca7e75e00d530ad55c22d7
|
|/
|
|
|
|
|
| |
The main benefit is that this syntax avoids repeating the variable
name. It does the same as before.
Change-Id: I2040be889c749f4e2416ca9948ba261345858af2
|
|
|
|
|
| |
Bug: T353458
Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
|
|
|
|
|
| |
Bug: T353458
Change-Id: Ia0f3e22078550be410c4b87faf6aa4eabe6e270d
|
|
|
|
|
|
|
|
|
|
| |
I believe the more recent syntax is quite a bit more readable. The
most obvious benefit is that it allows for much less duplication.
Note this patch is intentionally only touching tests, so it can't
have any effect on production code.
Change-Id: Ibdde9e37edf80f0d3bb3cb9056bee5f7df8010ee
|
|
|
|
|
|
|
|
|
|
| |
MediaWikiUnitTestCase::setService is defined as (string $name,
$service), which is incompatible with the ($name, $service) signature
MockHttpTrait expects for this method. As a fix, add the type hint to
the trait and MediaWikiIntegrationTestCase as well, to allow using
MockHttpTrait in tests extending MediaWikiUnitTestCase.
Change-Id: Ic7df40469947eff4b2be07d53eb9e09f452a4886
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Why:
* When temporary accounts are disabled, no new temporary
accounts should be created either on edit or through
a CentralAuth autocreation.
* UserNameUtils::isUsable is used to prevent the
CentralAuth autocreation making the temporary account
username not usable for login or account creation.
* However, this check to determine if the name is
reserved by the temporary user system still considers
the name as a valid temporary account if the system
was once enabled (but since disabled).
* This is a bug, and instead if the feature is disabled
the username should be considered unusable. This then
prevents the CentralAuth autocreation on a wiki which
knows the feature but has it disabled.
What:
* Update UserNameUtils::isUsable to return false if
the name is reserved by the temporary user system
and TempUserConfig::isEnabled returns false.
* Test this new behaviour with a unit test.
Bug: T370513
Change-Id: I467c39538796a660a7417397c99928a1a25007bc
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
And deprecated aliases for the the no namespaced classes.
ReplicatedBagOStuff that already is deprecated isn't moved.
Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
|
|/
|
|
|
|
|
|
|
| |
getPermissionStatus() does the same thing but better.
A lot of things use the legacy error arrays though, we're nowhere near
removing it.
Change-Id: Iff60dbb0593329a584d003b2407bbf24d5b22aea
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With temp accounts becoming a new kind of user besides logged-out and
named users, it makes sense to provide utility methods for testing
permissions with them. This is especially true as 1) more and more code
becomes aware of temp users, and 2) Authority itself has a `isTemp`
method, but its return value cannot be altered with the existing methods
in this trait.
Also change some documented union types to intersection types where that
makes sense.
Change-Id: I83f079bf3c39843adb5279ab325ea1fc2a127609
|
|
|
|
|
|
| |
Follow-up to 279fd16bab170eba95158a7cf438cfac17ff37b5.
Change-Id: I966e688cfaafdfe3af4b12ced1c3acf2062aa302
|