Initally used a new sniff with autofix (T333745),
but some provide are defined non-static in TestBase class
and need more work to make them static in a compatible way
Bug: T332865
Change-Id: I889d33424f0c01fb26f2d86f8d4fc3de3e568843
action=query&prop=info&intestactions=...:
Add &intestactionsautocreate=1 to also check whether the actions
would result in a creation of a temporary user account.
action=query&meta=siteinfo:
Add &siprop=autocreatetempuser to output the configuration
of temporary user accounts.
Bug: T335532
Change-Id: I62b4bb630decac92cbb8c7ddf00307df0dadb516
It's going to be a bit small and narrow but it's better than sitting in
the root of includes/ plus I hope we can hollow out SiteStatsUpdate
class into the third one and or move this under a better directory in
the future.
Bug: T321882
Change-Id: Ia503b53b31ca00600f8c18b61a2652c3e146494e
Error messages are not guaranteed to be stable, and these tests
prevent us from improving them.
Error codes are supposed to be stable, so we should be asserting
that they do not change (especially since many of them are
dynamically generated by the dodgy code in ApiMessageTrait).
Introduce helpers assertApiErrorCode() and expectApiErrorCode()
to be used instead of the usual PHPUnit assertions/expectations
for this case.
Change-Id: I752f82f29bf5f9405ea117ebf9e5cf70335464ad
* Unnecessary regex modifier. I agree with this inspection which flags
/s modifiers on regexes that don't use a dot.
* Property declared dynamically.
* Unused local variable. But it's acceptable for an unused local
variable to take the return value of a method under test, when it is
being tested for its side-effects. And it's acceptable for an unused
local variable to document unused list expansion elements, or the
nature of array keys in a foreach.
Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.
Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.
Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
ConvertibleTimestamp::setFakeTime is documented to
only take callbacks returning an int. ApiQueryLanguageinfoTest
violated this expectation, resulting in test breakage
(see I06c625abe351b2f189f5dbf6f331d34bb56004b2).
To get some integers to chose from, bump MAX_EXECUTE_SECONDS
to three.
Bug: T329609
Change-Id: I82d49a5e3a52c14dbd7e5324eb4c75cf7c33f3d2
Fix documentation related to ExtraInterlanguageLinkPrefixes
configuration: it should be a list, not a map, and described usage
better.
In ApiQuerySiteInfo, third-party clients (like Parsoid) need to know
whether a given language link core corresponds to a deprecated
language code or a "real" one; the API was also missing information
regarding which language code an "extra language link" prefix
corresponds to (given by InterlanguageLinkCodeMap in the
configuration).
Finally, add the corresponding bcp47 codes for these interlanguage
links, so third-party clients don't need to know details of mediawiki
internal and deprecated language codes.
Change-Id: I82465261bc66f0b0cd30d361c299f08066494762
User objects may hold references to service objects. They need to be
reset when services are reset between and during tests.
Change-Id: I7fe767977f1fe01d508fddf7a92ade3ec8ba2662
PHP 8.0 changed the behavior of numeric comparisons such that
non-numeric strings no longer weakly equal 0.[1] This breaks the logic
in Parser::extractSections(), which was relying on the old comparison
behavior for section indexes and in turn causes the revisions API to
return a bogus 'nosuchsection' for error when called with rvsection=new.
Fix the logic by explicitly casting the section index to a number, which
will yield the appropriate numeric section index for a numbered section
index and 0 for a non-numeric section index (like 'new'). Also add test
cases for the relevant API module.
--
[1] https://wiki.php.net/rfc/string_to_number_comparison
Change-Id: If32aa4d575cff66bd4eee56f9e3b0b0d9ba04fde
Bug: T323373
This proves a way to list all active hooks.
ApiQuerySiteInfo was relying on $ghHooks, which does not contain hooks
that were registered by extensions using the new hook handler system.
Change-Id: Ifae205f22ab4cc7ae0dfd15e994a1921af51b05c
This patch will implement a one-way transliterator (Latin->Cyrillic), per community consensus.
Bug: T268033
Change-Id: I6f3e7efe3630e9960584dca3a5ee55cb92ea722c
Co-Authored-By: Deni <deni@deni.dk>
Co-Authored-By: Winston Sung <winston21.sung@gmail.com>
Having pig-latin enabled per default in dev environments is convenient
for manual testing. More importantly, it will allow us to write
end-to-end tests for variant conversion.
Depends-On: I9dc2f743ac487b0f7cfb667150c0f6950d5e7fce
Depends-On: I85b66c85be3959d48a048733af17197bc4cf70af
Change-Id: Ia80ad33cbf5e311fa8b84bd765a8df8d156f4c38
The legacy 'rvdiffto' API parameter allows consumers to supply a
revision ID or the special strings 'cur', 'prev', 'next' to
revision-related API modules. This will then be resolved to a revision
and the diff of returned revisions against this revision will be
attached to the response.
On PHP 8.0, this parameter is broken as 'cur', 'prev', 'next' no longer
get resolved to the appropriate revision ID but rather are treated as
invalid literal revision IDs. This is because given an associative array
`$params = [ 'diffto' => 'prev' ];`, the expression `$params['diffto']
!= 0` is false on PHP < 8.0 but true on PHP >= 8.0.[1]
Fix it by also checking whether the parameter value is numeric before
treating it as a revision ID, and add a test case for this logic. To
facilitate testing, convert the counter used by ApiQueryRevisionsBase to
count the number of uncached diffs served in the current response to an
instance variable; it is currently a static variable which persists
across test boundaries.
Change-Id: Ifbe14cd2880c98dddc5577d226bef5878bdd657f
---
[1] https://onlinephp.io/c/81e7b
Bug: T322335
Change-Id: Id5032932842c94f4d3ca3707fbc733f5b9704151
Variant names is stored in 'variantname-xx' messages and different from
language names.
Bug: T302200
Change-Id: If1b16f12a6867de7caa9a28e0370745780006bec
Add a new action=query&meta=userinfo&uiprop=cancreateaccount
API property that checks whether the current user is allowed to
create accounts. This replaces the functionality removed from
list=users&usprop=cancreate in Ie94d61640301192b287275311f345,
and makes more sense - list=users is supposed to be about the
username (and re-called every time the username in the
registration form is changed), while meta=userinfo is about the
current user. It's also more accurate: it checks for all things
integrated with the permission system.
Change-Id: I0006500245a7c2bc3be0310ce9860b5771637a29
It's just a nice, lesser known convenience function. Exists since
PHP 5.5.
The changes to SerializationTestTrait ended being a little different.
Original I tried to use array_column() as well. But it drops the
array keys, which is relevant here.
We found that calling the two methods getTestInstances(AndAssertions)
multiple times is quite expensive and should be avoided. I changed
the code slightly so it's much less likely this is done unintentionally.
Change-Id: Ifaba3c370871a7c97b4d81ec21ff6ec134433fc0
Also improve MediaWikiIntegrationTestCase::editPage by accepting
LinkTarget objects and use services instead of static functions
Change-Id: I3d036b0837f212d3500159c1d3a3daa4e706882c
The language codes sr-ec and sr-el are not conform to BCP 47.
BCP 47 explicit mentions sr-Latn and sr-Cyrl as examples.
This change adds support for the language codes sr-cyrl and sr-latn
as fallback languages of the language codes sr-ec and sr-el. This
allows to rename the message files and the system messages without
changing the language codes yet.
The next step is to rename the language codes in Translatewiki as
described in https://translatewiki.net/wiki/Renaming_language_codes
Also local system messages in MediaWiki:*/sr-ec and MediaWiki:*/sr-el
can moved to MediaWiki:*/sr-cyrl and MediaWiki:*/sr-latn.
The final step is the change I75da0af35a2066e7963e50c56c99daf1e07c55e6
to complete the rename of the language codes.
Bug: T117845
Change-Id: I666fbdea89ccf21aab6ca1849adf22813dec052e
The implementation and test are both based on similar code for
meta=siteinfo. I’ve checked manually that, when no continuation is
necessary, the output looks the same as before in all formats, despite
the different way that we now set it.
Bug: T309921
Change-Id: I3b4b7aecdeb6461ae5bd8dc188e5ba49a119858e
This works by using the ip_changes table.
`iprange` parameter is introduced in order to restrict input to only one range.
Result is sorted by name, timestamp similar to `userprefix` parameter,
and T180153 (sort by timestamp first) is not addressed.
Related messages and test cases are added.
Bug: T177150
Change-Id: I3b8a917aaa76e18decf85b621dc77799698e4a77
All revision related classes are namespaced MediaWiki\Revision
instead of MediaWiki\Storage since 1.32. The old namespaced
class names are deprecated and only kept for backwards-compatibility.
Bug: T305784
Change-Id: I34e492d84d9fc4bc78481667202716d93b3c43cb
This ensures that assertions work in a uniform way,
and provides meaningful messages in cause of failure.
Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e