Commit graph

922 commits

Author SHA1 Message Date
DannyS712
e19774125a Remove UserWrapper class from tests, not used
https://codesearch.wmcloud.org/search/?q=UserWrapper&i=nope&files=&excludeFiles=&repos=

Change-Id: I38380cdf647295ad9197939b6ff0b9302d2869b4
2021-01-21 05:26:16 +00:00
Thiemo Kreuz
b655f382db Remove broken/outdated @param/@throws tags from @dataProviders
My personal best practice is to not document @params when there
is a @dataProvider. I mean, these test…() functions are not
meant to be called from anywhere. They do not really need
documentation. @param tags don't do much but duplicate what the
@dataProvider does. This is error-prone, as demonstrated by the
examples in this patch.

This patch also removes @throws tags from tests. A test…() can
never throw an exception. Otherwise the test would fail.

Most of these are found by the not yet released I10559d8.

Change-Id: I3782bca43f875687cd2be972144a7ab6b298454e
2021-01-21 03:42:42 +00:00
Petr Pchelko
bc6f7e4bdc Make User implement Authority
Ideally, only User associated with the global request
should be associated with UserAuthority. For a random
user instance, not the current performer, checking permissions
should be based solely on user groups and perhaps an
existing block. Right now however, PermissionManager
is coupled with global request, so we still instantiate
a UserAuthority for non-current users. This mimics the
behaviour we've had before. As we refactor PermissionManager,
we will be able to replace Authority implementation in this case,
or even entirely prohibit non-performer authority.

Bug: T271459
Depends-On: Iebf2dca34eea751391d9740443c195287399aa5c
Change-Id: Ib094e498fd883db23f2763f171281b1c9e99217e
2021-01-19 18:08:12 -06:00
Umherirrender
0347fd0631 Improve some function documentation in tests
Also fix some whitespaces

Change-Id: Ibed50a4f07442d3f299cf545c16f5dbb5f27a411
2021-01-14 22:13:55 +01:00
Thiemo Kreuz
ac205fa84c Fix incomplete/bogus PHPDoc tags in various tests
Most of these are found by the not yet released I10559d8.

I remove the type MockObject in some cases when the calling
code really does not need to know if he get's a mock or the
real thing. However, I do this only in places that are very
closely related to the fixes.

Change-Id: I26a4c3c5a8ae141bf56161b52b54bce7e68f2e30
2021-01-14 19:02:00 +00:00
daniel
68968305e3 Fix undefined index error in ApiQueryInfo
The code didn't properly handle requests for info about non-existing
pages.

Bug: T271804
Bug: T271815
Change-Id: If4e56ff5ecb4a048767833c89847bb58269cad43
2021-01-12 15:29:52 +00:00
jenkins-bot
0259ec87a7 Merge "Safer autoloading with respect to file-scope code" 2021-01-12 10:23:28 +00:00
Tim Starling
20d06b34bb Safer autoloading with respect to file-scope code
Many files were in the autoloader despite having potentially harmful
file-scope code.

* Exclude all CommandLineInc maintenance scripts from the autoloader.
* Introduce  "NO_AUTOLOAD" tag which excludes the file containing it
  from the autoloader. Use it on CommandLineInc.php and a few
  suspicious-looking files without classes in case they are refactored
  to add classes in the future.
* Add a test which parses all non-PSR4 class files and confirms that
  they do not contain dangerous file-scope code. It's slow (15s) but
  its results were enlightening.
* Several maintenance scripts define constants in the file scope,
  intending to modify the behaviour of MediaWiki. Either move the
  define() to a later setup function, or protect with NO_AUTOLOAD.
* Use require_once consistently with Maintenance.php and
  doMaintenance.php, per the original convention which is supposed to
  allow one maintenance script to use the class of another maintenance
  script. Using require breaks autoloading of these maintenance class
  files.
* When Maintenance.php is included, check if MediaWiki has already
  started, and if so, return early. Revert the fix for T250003 which
  is incompatible with this safety measure. Hopefully it was superseded
  by splitting out the class file.
* In runScript.php add a redundant PHP_SAPI check since it does some
  things in file-scope code before any other check will be run.
* Change the if(false) class_alias(...) to something more hackish and
  more compatible with the new test.
* Some site-related scripts found Maintenance.php in a non-standard way.
  Use the standard way.
* fileOpPerfTest.php called error_reporting(). Probably debugging code
  left in; removed.
* Moved mediawiki.compress.7z registration from the class file to the
  caller.

Change-Id: I1b1be90343a5ab678df6f1b1bdd03319dcf6537f
2021-01-11 11:59:36 +11:00
MusikAnimal
21d6f1cd6a ApiQueryInfo: Return watchlist expiry when applicable for inprop=watched
The expiry is returned as a separate key, 'watchlistexpiry', to match
other APIs, and because some clients might expect 'watched' to be a
boolean (or blank string depending on the formatversion).

Bug: T268834
Change-Id: I227d6ed42e70ba1ddec0139e8198f536dfba0b46
2021-01-06 13:51:27 -05:00
jenkins-bot
8ee4aa0df7 Merge "api: Add new 'raw' parameter type which avoids Unicode NFC normalization" 2021-01-01 00:33:14 +00:00
jenkins-bot
288b81ccc9 Merge "Create diff markers with CSS" 2020-12-31 01:23:40 +00:00
jenkins-bot
3c02841c94 Merge "TableDiffFormatter: Build HTML using utility class" 2020-12-31 01:09:13 +00:00
jenkins-bot
9c4e795546 Merge "[API] Ignore watchlist preferences for bot users" 2020-12-30 21:02:42 +00:00
Ed Sanders
27319def63 Create diff markers with CSS
Also put <br>s into empty lines so linebreaks are preserved when copying.

Bug: T192526
Change-Id: I926bedf71562c74a0aa33fbeb11f8d1a4e4130c7
2020-12-30 12:52:08 +00:00
Ed Sanders
351077388f TableDiffFormatter: Build HTML using utility class
Change-Id: Idab793bb1aabe8bffcbb2d00f68860d8b05172ef
2020-12-29 22:24:28 +00:00
DannyS712
6a93b0ca93 More misc test cleanup
* parent::setUp() should be first, and ::tearDown()
  should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
  to /unit

Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
2020-12-24 00:52:06 +00:00
C. Scott Ananian
1408b322b6 api: Add new 'raw' parameter type which avoids Unicode NFC normalization
The mandatory Unicode NFC normalization on API parameters was causing
spurious dirty diffs in VisualEditor/DiscussionTools when editors used
HTML entities to encode non-NFC codepoints, like &#x2001;.  Although
wikitext is (ought to be!) in NFC form, the output HTML may not be,
due to explicit entities in the wikitext.

This type is used in VisualEditor change
I0d34c9a01f1132c2616ed3392ea40d8b73e15325 to prevent Parsoid HTML from
being corrupted when it is round-tripped.

Bug: T266140
Change-Id: I2e78e660ba1867744e34eda7d00ea527ec016b71
2020-12-23 18:24:34 +00:00
Umherirrender
950f9d308d [API] Ignore watchlist preferences for bot users
Every user matching User::isBot would be affected and not longer adding
pages to the watchlist along to its (default) preferences.
To override this behaviour the bot user must change watch explizit.

The watchlist is mostly not useful for bots doing massive edits or
uploads. This reduce the grow of the watchlist tables at all and avoids
less users with massive entries unable to delete or clear.

Bug: T258108
Change-Id: If76127315767bde70147197c88e93f51ca70edaa
2020-12-22 22:28:28 +01:00
James D. Forrester
abdc94a3da Swap out uses of User->isLoggedIn() with ->isRegistered()
Bug: T270450
Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
2020-12-22 03:13:37 +00:00
jenkins-bot
d75edaea7d Merge "Add integration test ApiWatchlistTraitTest" 2020-12-22 01:14:56 +00:00
C. Scott Ananian
3d40c43b1f Deprecate InterwikiLoadPrefix hook
The InterwikiLoadPrefix hook isn't compatible with Parsoid, as it is
unidirectional and doesn't support enumerating all valid prefixes
(T270444).  Set/reset $wgInterwikiCache to mock the interwiki table
for parserTests and other unit tests instead.

This is a soft deprecation, as the used-in-production
Extension:Interwiki still uses InterwikiLoadPrefix, although not in a
way that would break Parsoid (since $wgInterwikiCache is set in
production).

Bug: T270444
Change-Id: If2507017c99c4ee42c104a0890bc45a84d7239d5
2020-12-21 19:28:48 +00:00
Umherirrender
1f03065c60 Add integration test ApiWatchlistTraitTest
Change-Id: Ifc3c340cac1799ae0546b2050be3dc327aadff57
2020-12-21 20:27:14 +01:00
jenkins-bot
491492ef5a Merge "Fix hang of ApiMainTest" 2020-12-16 23:26:43 +00:00
jenkins-bot
02342b9065 Merge "Don't access $wgRequest from User" 2020-12-16 05:06:16 +00:00
Tim Starling
8212527dfe Fix hang of ApiMainTest
If I try to run ApiMainTest with GlobalPreferences enabled, it takes
forever (or at least some number of minutes) to run. This is because
when @depends is used to transfer data from one test to another via
the return value, PHPUnit runs Enumerator::enumerate() on the data. When
it contains a reference to the active TestCase, PHPUnit ends up
iterating through its internal data structures, which takes a long time.

My conclusion is that @depends with a return value should be considered
harmful. Stop doing it in ApiMainTest. Stop recommending it in
SampleTest.

Change-Id: I63e94f2886a4ee4b3fd0ea6b19cd2fb67ba912de
2020-12-16 15:39:19 +11:00
Tim Starling
6b2a52181f Don't access $wgRequest from User
Some User methods fail if they are called before $wgRequest is
set. But according to the Setup.php comment, it is only set for b/c.
The global request object can be lazy-initialised at any time.

This is sufficient to avoid T263911 (loss/obfuscation of the $wgServer
error message).

In tests, try to keep $wgRequest and RequestContext::$request in sync.
Introduce MediaWikiIntegrationTestCase::setRequest() which sets both at
once, and use that instead of setMwGlobals() or direct assignment.

BlockManagerTest was accidentally exploiting the fact that the global
context request and $wgRequest were separate objects. Making them the
same causes session cookies to appear in the response, breaking the
cookie counts. Use a new response for the test.

Bug: T263911
Bug: T245940
Change-Id: I2be99f7251a837bc6b62be0b152038157dec10f2
2020-12-16 12:21:00 +11:00
Bartosz Dziewoński
245aa6e34c Fix error message mentioning the removed $wgEnableWriteAPI config
Change-Id: Idee35e7d37ea17f0a6bdbdc70b45822ec7c89b71
2020-12-15 23:38:03 +01:00
jenkins-bot
f3e1a5aa22 Merge "api: Use GetLinkColours hook to export CSS classes in page info" 2020-12-15 00:27:48 +00:00
C. Scott Ananian
f9433de05e api: Use GetLinkColours hook to export CSS classes in page info
Several important extensions (Disambiguator, ProofreadPage, and
SoftRedirector) use the GetLinkColours hook to add additional CSS
classes to links on article pages. Parsoid previously relied on
backdoor knowledge of the way Disambiguator used the page property
table to support these, but they should be exported properly from the
API.

Bug: T237538
Change-Id: I945940aa872541d7e01f1e543ca854231c857fe2
2020-12-14 17:51:50 -05:00
daniel
00a3439dce Introduce RevisionOutputCache
Bug: T267981
Change-Id: Ib1dc641ed10d786918362b25bd655780d5844ba1
2020-12-14 16:50:28 +00:00
Umherirrender
b64d838062 Skip undo related phpunit tests when diff3 is missing
Change-Id: I7fcbcfcd191805c00bdac07f681d266fe3e1fccb
2020-12-12 20:22:17 +00:00
jdlrobson
d11cb401d6 Deprecate the use of Skin::setupSkinUserCss to alter the internal array of styles
Check the internal array of styles to determine whether
the method was inappropriately used to alter the array of styles and
if it was, call wfDeprecatedMsg().

Change-Id: I591b03c2e19d4b8cadfe220b498ae244d332f9fb
2020-11-24 10:49:09 +11:00
Tim Starling
e9608cc17d Revert "Deprecate Skin::setupSkinUserCss"
The commit did not really hard-deprecate overriding of setupSkinUserCss() as stated in the commit message, rather it removed core calls to setupSkinUserCss(), instantly breaking the many skins that still override it. It did not actually create a deprecation period for graceful migration.

As discussed in T267080, there is presently no way to hard-deprecate the override of a method.

This reverts commit 334cfeffd6.

Bug: T257990
Change-Id: I8f669ba30affc437800890c3a875994a9f2eb3c8
2020-11-24 10:03:11 +11:00
jenkins-bot
1976283835 Merge "Update a lot of unspecific "array" types in PHPDocs" 2020-11-13 21:48:24 +00:00
Thiemo Kreuz
6f901ef17c Make use of native array_column() function where possible
Change-Id: I78108e7dc5a10d892e97b0101c1b72cb8d363e97
2020-11-11 22:48:53 +00:00
jenkins-bot
b8c277c932 Merge "Add API validator for titles" 2020-11-07 00:22:42 +00:00
Gergő Tisza
84e9702349
Add API validator for titles
The ISMULTI logic is copied from UserDef.

Change-Id: I794e2277c462b86cb5c3888d1ba509b11fad62aa
2020-11-06 14:09:04 -08:00
jenkins-bot
8eb56c37f3 Merge "Move ApiQuery* tests under the /query subdirectory" 2020-11-04 06:07:39 +00:00
Umherirrender
27816323e5 Use SpecialPageFactory to create special pages in ApiFeedRecentChanges
This makes it easier to change the constructor of both special pages

Change-Id: Id485ffa9fc1c1a9818ab487aed6ef886a7eb35a5
2020-11-03 18:11:46 +00:00
jenkins-bot
3c262bffdf Merge "Make unit tests assertion about assertNotEquals more strict" 2020-11-02 00:37:36 +00:00
Umherirrender
bdf8cefaf8 Make unit tests assertion about assertNotEquals more strict
Originally an autofix of PHPUnitAssertEquals sniff, but manually
updated.

Change-Id: I78efc6f7997f0b7227b40d7eab1495cc7a1d7da5
2020-11-01 23:12:06 +00:00
jenkins-bot
1c67aa07c7 Merge "Fix tests assume badaccess-groups message in singular form" 2020-10-30 23:17:00 +00:00
jenkins-bot
a026fc870e Merge "ApiQueryContinueTestBase: use lower camel case function name" 2020-10-30 20:06:40 +00:00
jenkins-bot
484024b14f Merge "[ApiBaseTest] Set apihighlimits permission to false" 2020-10-30 19:54:08 +00:00
DannyS712
65153e6c4c ApiQueryContinueTestBase: use lower camel case function name
Change-Id: Ie7d3bd0fc6999e8c25881c3befbf565dc258c2aa
2020-10-30 19:03:36 +00:00
Umherirrender
749fb81542 [ApiBaseTest] Set apihighlimits permission to false
The limit tests would fail if there is apihighlimits for everyone
(group *)
mergeMwGlobalArrayValue does not do deep merge, it just overrides;
setting the '*' group to the minimum required to pass tests.

Change-Id: I95fba69af1845f28132370e9ded3350acdfdb8c4
2020-10-30 18:50:00 +00:00
Umherirrender
4c8cbf14ca Fix tests assume badaccess-groups message in singular form
Change-Id: I63476388655ae317453b9ebca793329a23519a4c
2020-10-30 17:20:54 +01:00
Umherirrender
f1d409e095 [ApiUserrightsTest] Start with empty $wgAddGroups/$wgRemoveGroups
In some tests mergeMwGlobalArrayValue should merge the empty array,
but when have settings in LocalSettings.php the result is not the empty
array as needed for the tests.
Just start with empty array to work on top of that.

1) ApiUserrightsTest::testAddAndRemoveGroups with data set "Add with
only remove permission" (array(array(), array('sysop')),
array(array('sysop'), array()), array('bot'))
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
 Array &0 (
     0 => 'bot'
+    1 => 'sysop'
 )
with $wgAddGroups['bureaucrat'] = true; in LocalSettings.php

Change-Id: I092a3353aa65d53c84b765c04ec213ed8294b65d
2020-10-30 16:36:02 +01:00
Aaron Schulz
815912062f Move ApiQuery* tests under the /query subdirectory
Consistency aside, this is useful for grouping more tests
into separate threads when using directory based suites.

Bug: T50217
Change-Id: Ife9acd5990c4ae4a5fc18371559e93d7d86fb57d
2020-10-30 03:31:12 +00:00
Umherirrender
448d2f4d51 Avoid local variable with wg prefix
Change-Id: Ib32cc0db07636238aa0b4f8ea7f8c1ae37084889
2020-10-28 22:21:24 +01:00
Thiemo Kreuz
b0130ca649 Update a lot of unspecific "array" types in PHPDocs
This includes fixing some mistakes, as well as removing
redundant text that doesn't add new information, either because
it literally repeats what the code already says, or is actually
duplicated.

Change-Id: I3a8dd8ce57192deda8916cc444c87d7ab1a36515
2020-10-28 11:01:33 +01:00
Thiemo Kreuz
1fc8d79ac6 Remove documentation that literally repeats the code
For example, documenting the method getUser() with "get the User
object" does not add any information that's not already there.
But I have to read the text first to understand that it doesn't
document anything that's not already obvious from the code.

Some of this is from a time when we had a PHPCS sniff that was
complaining when a line like `@param User $user` doesn't end
with some descriptive text. Some users started adding text like
`@param User $user The User` back then. Let's please remove
this.

Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
2020-10-27 19:20:26 +00:00
jenkins-bot
0fa9827ee4 Merge "ApiPageSet: Avoid infinite loop when merging redirects" 2020-10-08 17:48:01 +00:00
Erik Bernhardson
861293a36c ApiPageSet: Avoid infinite loop when merging redirects
Redirects can form a loop but it was unaccounted for in this process.
Track seen pages to detect when a loop has formed. In the case of a
redirect loop the ApiPageSet will include the source page and ignore
the found redirects.

Bug: T264534
Change-Id: Ia5f4eeb9a4d90f02aceec3ed83bd4fc4a8a23ca4
2020-10-08 10:00:45 -07:00
hmonroy
45bb027122 Normalize WatchedItem expiry field
Normalize watchlist expiry field so that it is set to
ConvertibleTimestamp and the expiry value validation is
handled by the WatchedItem class.

Bug: T260868
Bug: T260009
Change-Id: I3ef31900cfbe7bce23c5ebe1db777a5137ea6167
2020-10-06 13:00:50 -07:00
jenkins-bot
1d49ad1e5b Merge "ApiEditPage: Don't swap undo and undoafter parameters" 2020-09-30 01:45:14 +00:00
DannyS712
cebbfe47fd Reduce some direct references to $wgUser
Bug: T243708
Change-Id: Ief59ce77469de4185c031413e64d0dee3ea26e60
2020-09-25 17:46:56 +00:00
jdlrobson
7f0412e644 Expose portlet data in SkinMustache
This data structure is sufficient to generate menus in
all Wikimedia deployed skins.

This new method will be used immediately in Example skin:
 Ifb30a2c1314692c2869bd99c523e19c821be1f08

and Vector skin:
I5f7adc1840441b508ffee40139b85b64021789e6

Bug: T262098
Bug: T255924
Change-Id: I1a163cac0bff7620dcac50350cb6b93445a0cfbc
2020-09-22 14:06:29 -07:00
Martin Urbanec
a656d03597 Introduce backend class for blocking users
Rather than having to do DatabaseBlock calls directly,
and then ManualLogEntry calls to facilitate logging,
let's create a BlockUser service, capable of blocking users
and logging, optionally with permission checking.

This should make blocking users easier for developers,
for instance, AbuseFilter or CheckUser can easily
benefit from this commit.

Bug: T189073
Change-Id: Ifdced735b694b85116cb0e43dadbfa8e4cdb8cab
2020-09-22 14:14:01 +01:00
Dov Alperin
a1cd498fdf ApiEditPage: Don't swap undo and undoafter parameters
This made it impossible to correctly undo changes if revision IDs are out of
order with respect to timestamps.

Removes block of code responsible for creating this bug, and updates tests to reflect the change

Bug: T190285
Change-Id: Id5837ed958023bdbf544ae0f79e2d5e05c94cc64
2020-09-21 19:08:20 +01:00
DannyS712
b2ba90191e Add tests for ApiBlock return values when blocking by userid
To ensure the functionality doesn't break as part of
Ifdced735b694b85116cb0e43dadbfa8e4cdb8cab,
which refactors the block handling

Bug: T189073
Change-Id: I7cb1be6532c5b32a4a77924c42483d43a290c464
2020-09-19 17:13:18 +00:00
DannyS712
3d18c1def9 Remove use of $wgUser in ApiUserrightsTest
Bug: T243708
Change-Id: I898561bef67dc2452e5e4a4af60d96b477b13dff
2020-09-13 23:33:21 +00:00
Thalia
addb098c39 Deprecate DatabaseBlock methods moved to DatabaseBlockStore
Following 23c3c70d7f, soft deprecate the static methods on
DatabaseBlock that have been moved to DatabaseBlockStore:
* ::insert
* ::delete
* ::update
* ::purgeExpired

Update calls to the deprecated methods from core.

Change-Id: I1272eb978594fd4f386bda12cbc24131ad7d882f
2020-09-13 22:17:27 +00:00
jenkins-bot
2ed425f39e Merge "PHPUnit integration tests: fix handling of null user in editPage()" 2020-09-13 09:24:18 +00:00
Ostrzyciel
81ac2fc852 PHPUnit integration tests: fix handling of null user in editPage()
The PHPDoc for the editPage method stated that if $user is null,
the test sysop user will be used instead. This is not the case in
practice, as the method simply passes null to the doEditContent
method.

As Ammarpad has pointed out in a comment, this confusion is due to
I5a10163 assuming the sysop would be used, which is incorrect.
It's also probably better for the default user to be a "regular"
user, not a sysop, so I changed it to getTestUser() and noted this
in the doc block.

Depends-On: I7a79e0eaa1617e4d87a8d615a5391723c0e30b6a
Change-Id: I9f77474f40e0f6901aa2c6f846e471b822636aa5
2020-09-13 09:42:52 +02:00
jenkins-bot
a425b0f94d Merge "ApiLogoutTest: Remove use of global $wgUser" 2020-09-10 00:30:53 +00:00
Ammar Abdulhamid
7af5678847 API: Handle ContentHandler exception for content model mismatch
Ensure the content we are trying to save and the base content have
identical content models before proceeding to save so as to forestall
Exception that may be thrown by ContentHandler if it founds they're not.

There are two cases where the models are allowed to differ: Edit that
undoes content model change or edit that's meant to explicitly change
the model. The logic for these is handled separately and may succeed
or fail, but exception will not be thrown.

Bug: T255700
Change-Id: I8782732bb0fc3059693cd7035b7ebb43fd71d333
2020-09-04 03:41:58 +01:00
MusikAnimal
d3c13fc2ce WatchAction: avoid unnecessary UPDATEs when expiry is unchanged
Bug: T258649
Change-Id: I0a5a84480bbd630c7dd1744b4316ea31d7bedd5b
2020-08-11 16:17:01 -04:00
Ammar Abdulhamid
334cfeffd6 Deprecate Skin::setupSkinUserCss
Bug: T257990
Depends-On: I132513a897e40162acd973b9817b3103f4a33333
Depends-On: I363f8c9e39298ab9f74274d288681f2ef88a1894
Change-Id: I13bedd8c14de419ff1a88d5087f5669652cd3123
2020-08-09 02:09:08 +01:00
jenkins-bot
cf29d50e0d Merge "ApiQueryWatchlist: set anon flag as false when relevant instead of omitting" 2020-08-07 19:56:49 +00:00
jenkins-bot
54fcd1c72f Merge "Default to using watchlist expiry of old page when moving pages" 2020-08-06 04:32:24 +00:00
MusikAnimal
884fa47d09 Default to using watchlist expiry of old page when moving pages
Expiries are copied post-send so as to not slow anything down.

Note the expiry feature has been disabled in some unit tests that mock
database queries, simply because these tests are so hard to maintain and
are very fragile. The logic introduced with this patch is covered by the
integration tests.

Bug: T257259
Change-Id: I4223eaa6782a319fb684acf656f54b88a92e5288
2020-08-05 23:32:00 -04:00
jenkins-bot
59aeebc22a Merge "Remove usages of Skin::getAllowedSkins." 2020-08-05 20:43:49 +00:00
Ammar Abdulhamid
5dafaf9028 Remove usages of Skin::getAllowedSkins.
* Move the method to SkinFactory and replaces usages.
* Inject $wgSkipSkins into the SkinFactory

Bug: T257993
Change-Id: I9869cf34c5e87cbad963f48db0649b3b7a252a4a
2020-08-05 02:48:29 +01:00
DannyS712
ac66469a6d Remove hard deprecated ApiTestCase::doLogin
No known uses in any repo on codesearch:
https://codesearch.wmcloud.org/search/?q=doLogin%5C(&i=nope&files=&repos=

Bug: T245355
Change-Id: I606d4f922a3034af786cf64e6d8b211cd12a09af
2020-07-27 14:35:14 +00:00
MusikAnimal
6a898faed2 Add watchlist expiry support to applicable APIs
This introduces an ApiWatchlistTrait that refactors out common code
across APIs that allow you to watch pages. Some methods have been
migrated from ApiBase and changed completely, but codesearch suggests
they aren't being used outside the API modules in this patch.

Bug: T248512
Bug: T248514
Change-Id: Ia18627b9824dca81f44f0571e8420d89b7626cf6
2020-07-13 18:18:15 -04:00
jenkins-bot
8ada06dca1 Merge "Hard deprecate the rest of the Revision class" 2020-07-06 13:57:55 +00:00
DannyS712
2f4b71fc6c Replace uses of Revision constants
Bug: T257010
Change-Id: Id63123e8b8becd31756d5b68ca11edb238ec8a59
2020-07-03 01:23:44 +00:00
DannyS712
0637d80572 Hard deprecate the rest of the Revision class
Bug: T246284
Change-Id: I126d7892c90aa2200c668b5717820e729613bed8
2020-07-02 09:02:02 +00:00
jenkins-bot
a18a39f413 Merge "MediaWikiTestCase to MediaWikiIntegrationTestCase" 2020-07-01 18:39:57 +00:00
addshore
959bc315f2 MediaWikiTestCase to MediaWikiIntegrationTestCase
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)

My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.

Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
2020-06-30 17:02:22 +01:00
DannyS712
9ab8615d36 PageUpdater: set DeprecatablePropertyArray to hard deprecate Revision
Bug: T254952
Change-Id: Idfdbdcf00b875bd88045c71a30c6a8ddd1057a78
2020-06-30 15:59:57 +00:00
Thiemo Kreuz
5f3a92385b Fix visibility of setUp/tearDown
Change-Id: I636be48eb9f713680abac35d46091f7b49374696
2020-06-16 21:02:05 +02:00
DannyS712
f8cc519222 Hard deprecate Revision::getPage and ::getComment
Bug: T251853
Bug: T254960
Change-Id: I09fadbebd839a16b46a027f64eaac9a435622321
2020-06-10 04:10:41 +00:00
DannyS712
c595f2fd7e Remove use of the Revision object returned in WikiPage::doEditContent (2)
Each file's changes are independent and can be reviewed separately

Bug: T251853
Bug: T254952
Change-Id: Ifdc192796f0989c12fda7c0317bf2458874d6e19
2020-06-10 01:15:45 +00:00
DannyS712
e36fc3a8dd Remove use of the Revision object returned in WikiPage::doEditContent
Each file's changes are independent and can be reviewed separately

Bug: T251853
Bug: T254952
Change-Id: I197c3db4cfb2ead920c8e6071120ae29543ee404
2020-06-09 23:38:03 +00:00
jenkins-bot
9a9872e221 Merge "Hard deprecate Revision::getContent" 2020-06-08 17:51:15 +00:00
jenkins-bot
26095750d5 Merge "Simplify \stdClass object creation in ApiResultTest" 2020-06-08 16:28:12 +00:00
DannyS712
df7906cd0f Hard deprecate Revision::getContent
Bug: T254703
Change-Id: I50e82d29f87725a2d583a0fc1ebacc467ffee935
2020-06-08 02:44:21 +00:00
DannyS712
25a90e8009 Remove unneeded ::setUp and ::tearDown methods that only call parent
Change-Id: I2a12859cfc56059bb71afa2aac08a8f86e746612
2020-06-07 10:09:32 +00:00
Thiemo Kreuz
6aa6d10e86 Replace all call_user_func(_array) in all tests
There is native support for all of this now in PHP, thanks to changes
and additions that have been made in later versions. There should be no
need any more to ever use call_user_func() or call_user_func_array().

Reviewing this should be fairly easy: Because this patch touches
exclusivly tests, but no production code, there is no such thing as
"insufficent test coverage". As long as CI goes green, this should be
fine.

Change-Id: Ib9690103687734bb5a85d3dab0e5642a07087bbc
2020-06-06 18:41:20 +02:00
DannyS712
cc20c65b23 Hard deprecate Revision::newFromId
Bug: T249021
Change-Id: Iee63d5b0fe00dff9f43fcf5cbf43ac1516978e2e
2020-06-03 02:58:57 +00:00
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

General principles:
* Use DI if it is already used. We're not changing the way state is
  managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
  is a service, it's a more generic interface, it is the only
  thing that provides isRegistered() which is needed in some cases,
  and a HookRunner can be efficiently constructed from it
  (confirmed by benchmark). Because HookContainer is needed
  for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
  SpecialPage and ApiBase have getHookContainer() and getHookRunner()
  methods in the base class, and classes that extend that base class
  are not expected to know or care where the base class gets its
  HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
  getHookRunner() methods, getting them from the global service
  container. The point of this is to ease migration to DI by ensuring
  that call sites ask their local friendly base class rather than
  getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
  methods did not seem warranted, there is a private HookRunner property
  which is accessed directly. Very rarely (two cases), there is a
  protected property, for consistency with code that conventionally
  assumes protected=private, but in cases where the class might actually
  be overridden, a protected accessor is preferred over a protected
  property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
  global code. In a few cases it was used for objects with broken
  construction schemes, out of horror or laziness.

Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore

Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router

setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
Thiemo Kreuz
edd26046e9 Simplify \stdClass object creation in ApiResultTest
I find this …->{…} curly bracket syntax surprising and confusing,
and try to avoid it as hard as I can. And that's indeed very, very
easy here. Note this really creates the exact same \stdClass object.

Change-Id: I612184be877b2aa404db9829a827cfcec2d253cf
2020-05-29 08:23:59 +02:00
jenkins-bot
aef18790c6 Merge "ExtensionRegistry: Remove exporting and caching of wgExtensionCredits" 2020-05-28 19:12:06 +00:00
Timo Tijhof
5d8f62bdd3 ExtensionRegistry: Remove exporting and caching of wgExtensionCredits
This data is the same as the 'credits' data that is already compiled,
cached and made available via ExtensionRegistry.

Similar to various other configuration variables previously, the
$wgExtensionCredits variable is now also required to only be used
for providing input to the system (e.g. from LocalSettings.php,
or from legacy extension PHP entry points). It is no longer
supported to use this variable to reliably read out a full view
of all extension credits (specifically those registered via
extension.json).

Doing so had the downside of adding processing cost to every
web request, as well as taking one the single largest portion
of the ExtensionRegistry APCu cache key, which in PHP7+ incurs
a linear cost for every string value, string key, of every
(sub)array in this huge structure; and does to on every request
just in case something reads from $wgExtensionCredits.

The new method to access this information reliably is owned
by SpecialVersion for now (could be moved elsewhere). This
also makes the merging logic more testable and incurs it on-demand
rather than upfront.

Details:

* Move 'type' internally from NOT_ATTRIBS to CREDIT_ATTRIBS.
  These two arrays behave identically for most purposes (they are
  both used to mean "don't export this as a global attribute").

  By placing it in CREDIT_ATTRIBS it becomes complete and makes
  it easy to refer to in docs. Previously, extractCredits()
  read the 'type' key outside the loop for CREDIT_ATTRIBS.

* Remove redundant code in ApiBase.php, that is now more obviously
  redundant. Looks like a left-over or merge conflict mistake
  from when ExtensionRegistry was first introduced.

Bug: T187154
Change-Id: I6d66c58fbe57c530f9a43cae504b0d6aa4ffcd0d
2020-05-28 18:46:41 +00:00
jenkins-bot
d535ebeb51 Merge "WatchedItemStore: Enforce a maximum watchlist expiry duration" 2020-05-27 22:32:06 +00:00
Reedy
229b2c15e8 Fix a plethora of class and function call case mismatches
Bug: T231412
Change-Id: I597a25de3294a6673424f30475760280ef209a8a
2020-05-26 14:14:46 +01:00
MusikAnimal
0694cc02f1 WatchedItemStore: Enforce a maximum watchlist expiry duration
Introduces $wgWatchlistExpiryMaxDuration which is used instead of given
expiry if the given exceeds it. This is done in the storage layer. The
reasoning is to control the size of the watchlist_expiry table. Hence,
the max duration does not apply to indefinite expiries (since that would
mean now row in watchlist_expiry).

The frontend is responsible for disallowing expiries greater than the
max, if it choses to do so.

APIs should now pass in $wgWatchlistExpiryMaxDuration as the PARAM_MAX
setting for the 'expiry' type. They should also set PARAM_USE_MAX so
that the maximum value is used if it is exceeded.

Other APIs that watch pages will be updated in separate patches
(see T248512 and T248514).

Bug: T249672
Change-Id: I811c444c36c1da1470f2d6e185404b6121a263eb
2020-05-22 00:15:23 -04:00
jenkins-bot
fedbf6ba82 Merge "Use new TalkPageNotificationManager" 2020-05-20 19:21:52 +00:00