Commit graph

9792 commits

Author SHA1 Message Date
DannyS712
d464f84182 Fix a typo: matser -> master
Bug: T201491
Change-Id: I2230195439582b1977d0c84295a5e8d9ee07a6cf
2020-12-21 06:38:42 +00:00
Ammar Abdulhamid
2bd536b83a Cleanup SpecialBlockTest
Needs to call parent::tearDown() after the table reset.

Use direct assertion and MediaWikiTestCase abstraction
where possible

Change-Id: Iad00569867e6f9a4579ae93b22fc0f570cde6bd7
2020-12-20 02:54:16 +01:00
Umherirrender
86ea6965d3 Add missing @param/@return to MockHttpTrait
Change-Id: I38cb2e0e7f7a0f6a0199670f7aa56a1522d6628c
2020-12-19 07:21:51 +00:00
jenkins-bot
2fa4152473 Merge "Deprecate a bunch of global functions" 2020-12-18 23:36:21 +00:00
jenkins-bot
9f272a13ba Merge "Fix extraneous indents in ResourceLoaderTestCase" 2020-12-18 22:22:25 +00:00
DannyS712
1567f9bafe Fix extraneous indents in ResourceLoaderTestCase
Change-Id: I5a22337fb1a8098bee526453530c85a8bb18e364
2020-12-18 21:49:07 +00:00
DannyS712
f4e21014ce Deprecate a bunch of global functions
* wfAcceptToPrefs
* wfClearOutputBuffers
* wfConfiguredReadOnlyReason
* wfDebugMem
* wfGetPrecompiledData
* wfNegotiateType

Bug: T264976
Bug: T264979
Bug: T264981
Bug: T264983
Bug: T264984
Bug: T264985
Change-Id: Ia05bc84e4d1be7c8a02472f32e2c009e4bb32032
2020-12-18 21:34:50 +00:00
Umherirrender
0b10c1b039 Add missing @return to FileBackendGroupTestTrait
Change-Id: Ifb9eef6594a9520cd687adc287fcab389c3c977c
2020-12-18 22:08:38 +01:00
jenkins-bot
a166abb115 Merge "Remove MediaWikiIntegrationTestCase::assertType" 2020-12-18 20:26:28 +00:00
Daimona Eaytoy
6f7132cbcf Remove MediaWikiIntegrationTestCase::assertType
Deprecated since 1.35, not compatible with PHPUnit 8. This could've
happened earlier, but here we go.

Unused in known repos (except for the sniff looking for this usage):
https://codesearch.wmcloud.org/search/?q=assertType%5C(&i=nope&files=php&repos=

Bug: T192167
Change-Id: I479cf71d0941c35096d21686077b4d1cbc4f898d
2020-12-18 19:23:14 +00:00
Paladox
0b4c4402e8 Fix infinite recursion with wgAutopromote when using getBlock within checkCondition
The problem was that when using $user->getBlock
within checkCondition (APCOND_BLOCKED) caused a infinite
recursion as calling getBlock eventually leads back to checkCondition.

The fix here is to stop using userHasRight as that is the cause of the recursion.

This also fixes testGetUserAutopromoteBlockedDoesNotRecurse test so it
shouldn't fail.

Bug: T270145
Change-Id: Ic751eba70730de286bbd55772bd7562459fb30b4
2020-12-17 19:57:10 +00:00
Paladox
36e2a458b6 Add test showing that getBlock can recurse if you use Autopromote and use APCOND_BLOCKED
Tests are purposely skipped and will be enabled in a follow up change.

Bug: T270145
Change-Id: I7f28bd9f5644d0f4b90927525ab93e2fac2f9d8f
2020-12-17 17:21:51 +00:00
jenkins-bot
2697ba639e Merge "WikiPage: add interim replacement for WikiPage::doEditContent() requiring $user" 2020-12-17 15:11:00 +00:00
Petr Pchelko
0eef0a6a3a Article: view from old revision cache - set correct revId.
Bug: T270361
Change-Id: Ice99038df450bb6892a5064b67f3d35f3255267b
2020-12-17 07:22:35 -06:00
jenkins-bot
491492ef5a Merge "Fix hang of ApiMainTest" 2020-12-16 23:26:43 +00:00
jenkins-bot
f438ebcd7f Merge "FeedUtils: Update regex to match classes appropriately, and test" 2020-12-16 18:15:42 +00:00
jenkins-bot
fe8779ebf9 Merge "Parser tests: Update TestFileReader to the latest reader from Parsoid" 2020-12-16 17:45:01 +00:00
jenkins-bot
add80561d2 Merge "ParserOptions: Deprecate fallback to $wgUser" 2020-12-16 15:17:05 +00:00
Petr Pchelko
71bb51ed55 ParserCache: general code cleanup, abstracted expiration checks.
Change-Id: I7374f30d582064236b8f782e6a2528eb692e3010
2020-12-16 12:09:55 +00:00
DannyS712
25db391d53 ParserOptions: Deprecate fallback to $wgUser
Emit deprecation notices in the constructor
if falling back to $wgUser, and fix core
calls

Bug: T246861
Depends-On: I51117931d527a3bdda468b48de577a7faafbcd69
Change-Id: Ibd0a8ffd0494c17a378cc43e6b6164166130adf4
2020-12-16 09:03:29 +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
jenkins-bot
f0d9e5e182 Merge "Implement caching for old revision HTML endpoint" 2020-12-16 00:41:27 +00:00
daniel
637f630fe9 Implement caching for old revision HTML endpoint
Bug: T269663
Change-Id: I2d17ec37d25f3a6e1c4836c05576bf0fabb7d429
2020-12-15 23:40:08 +01: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
e1e1e6e5a5 Merge "LanguageConverterTest: reduce direct references to $wgUser" 2020-12-15 20:31:40 +00:00
jenkins-bot
37a29d3dde Merge "DumpTestCase - stop writing to $wgUser" 2020-12-15 20:31:32 +00:00
Subin Siby
8922c83875 FeedUtils: Update regex to match classes appropriately, and test
Not all classes are matched correctly in feed output because of
regex used. Fixed it by updating regex and adding unit tests

Bug: T36801
Change-Id: I6e7a883caee2a36c11966991b19ba93c229683cf
2020-12-15 07:35:10 +00:00
Taavi Väänänen
0ffed5799d WikiPage: add interim replacement for WikiPage::doEditContent() requiring $user
This patch adds a method named WikiPage::doUserEditContent() as an interim
replacement to existing deprecated ::doEditContent() method. The new
method requires $user to be passed as a parameter and no longer supports
passing in the unused $serialFormat parameter. The new method otherwise
behaves identically compared to the old doEditContent() method.

Bug: T255507
Change-Id: Ibc0052b27a6d3cda3eb9663b95b4f45116dcc9f1
2020-12-15 08:59:57 +02:00
jenkins-bot
030a38065f Merge "ResourceLoaderSkinModule defines the order of feature styles" 2020-12-15 02:35:40 +00:00
jdlrobson
4a287f9217 ResourceLoaderSkinModule defines the order of feature styles
Previously, the order of styles outputted by this module was
arbitrary, based on the order of the feature files passed in.

This was not how it was intended to work - the ResourceLoaderSkinModule
should be aware of the correct ordering.

In the case of normalize for example - it should always be the first
file output.

The implementation is adapted to check for valid features once in
the constructor and to also consider a DEFAULT_FEATURES value has been
set.

We  use the FEATURE_FILES constant to determine
the order of CSS output.

This is all documented in the class.

Bug: T269618
Change-Id: Iecbf11b5f09882e55d694651210d6d132d3cd412
2020-12-15 02:11:22 +00: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
02ec9de651 Parser tests: Update TestFileReader to the latest reader from Parsoid
This replaces the 'requirements' from parser tests (hooks and
functionhooks) with a more flexible 'options' clause to allow
additional file-level requirements/options to support running parser
tests in multiple modes.  (For example, with the legacy parser or in
one of two parsoid modes.)

Bug: T254181
Depends-On: I636bd1f2c8aee327acbbd1636e2ac76355f1d80e
Change-Id: I58373d135c3a804f4ce9967112c338435f5cd4b6
2020-12-14 18:49:11 -05: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
DannyS712
3fcb2ec73f DumpTestCase - stop writing to $wgUser
Shouldn't be needed anymore

Bug: T243708
Change-Id: If3c934c2146927a5564a75fa48c5d213cfe40722
2020-12-14 22:19:42 +00:00
DannyS712
9c47a99639 LanguageConverterTest: reduce direct references to $wgUser
Should be a no-op, doesn't actually reduce the places where $wgUser
is set, just reduces the number of hits in codesearch and makes the
future migration of LanguageConverter to not use $wgUser a bit
easier

Bug: T243708
Change-Id: Ieb04b0e760dd37e037a95408ef429ac5c510f1d9
2020-12-14 21:24:17 +00:00
daniel
fa8ddd48fc Implement /revision/{id} endpoint
Also implements and endpoint for revision source,
for parity with /page/{title}.

Bug: T267981
Change-Id: I88c714df6e428fbc02aa4ff7f4ecea7d8b458468
2020-12-14 16:54:43 +00:00
daniel
a4b51d2774 Implement /revision/{id}/html endpoint
This doesn't have caching yet.

Bug: T267981
Change-Id: I32a35bb7bc6c6832ce7c79fb942922abc1ddb0e0
2020-12-14 16:54:35 +00:00
daniel
00a3439dce Introduce RevisionOutputCache
Bug: T267981
Change-Id: Ib1dc641ed10d786918362b25bd655780d5844ba1
2020-12-14 16:50:28 +00:00
jenkins-bot
2389becaef Merge "LanguageClassesTestCase::setup: Validate language code" 2020-12-13 18:28:08 +00:00
Umherirrender
12e15e410b LanguageClassesTestCase::setup: Validate language code
This trait is used in class LanguageIntegrationTest, resulting in the
language code "integration" being used, which is an invalid language.

Change-Id: I9398015bb0e85eb26116bb8608c8f39216ce8204
2020-12-13 17:19:57 +00:00
Umherirrender
339f86629f AutoLoaderStructureTest: Re-write slashes so test passes on Windows
A difference between UNIX and Windows is the dir separator,
which makes this test failing, because the file name does not match to
filter out the psr4 loaded classes to just keep the alias, which must be
part of the autoloader class list.

1) AutoLoaderStructureTest::testAutoLoadConfig
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
     'ParserTestFileSuite' => '[...]...te.php'
     'ParserTestTopLevelSuite' => '[...]...te.php'
     'SuiteEventsTrait' => '[...]...it.php'
+    'MediaWiki\Block\DatabaseBlock' => '[...]...ck.php'
+    'MediaWiki\SpecialPage\SpecialPageFactory' => '[...]...ry.php'
+    'MediaWiki\Revision\IncompleteRevisionException' =>
'[...]...on.php'
+    'MediaWiki\Revision\MutableRevisionRecord' => '[...]...rd.php'
+    'MediaWiki\Revision\MutableRevisionSlots' => '[...]...ts.php'
+    'MediaWiki\Revision\RevisionAccessException' => '[...]...on.php'
+    'MediaWiki\Revision\RevisionArchiveRecord' => '[...]...rd.php'
+    'MediaWiki\Revision\RevisionFactory' => '[...]...ry.php'
+    'MediaWiki\Revision\RevisionLookup' => '[...]...up.php'
+    'MediaWiki\Revision\RevisionRecord' => '[...]...rd.php'
+    'MediaWiki\Revision\RevisionSlots' => '[...]...ts.php'
+    'MediaWiki\Revision\RevisionStore' => '[...]...re.php'
+    'MediaWiki\Revision\RevisionStoreRecord' => '[...]...rd.php'
+    'MediaWiki\Revision\SlotRecord' => '[...]...rd.php'
+    'MediaWiki\Revision\SuppressedDataException' => '[...]...on.php'
 )

Change-Id: I1485cc7309c20d131f398473367d281a3ce78a25
2020-12-13 17:16:53 +00:00
Umherirrender
b64d838062 Skip undo related phpunit tests when diff3 is missing
Change-Id: I7fcbcfcd191805c00bdac07f681d266fe3e1fccb
2020-12-12 20:22:17 +00:00
jenkins-bot
35987b5cf2 Merge "[FileTest] Do not assume /tmp exists on windows" 2020-12-12 20:06:17 +00:00
Umherirrender
8f80236a6f [FileTest] Do not assume /tmp exists on windows
Needs to be a real path, not relative one

6) FileTest::testGetThumbnailSource with data set #2 (array(true,
array('/tmp'), 1024, 2048, '/tmp', 'Temporary path because temp f...
found'))
Temporary path because temp file was found
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'/tmp'
+'fsFilePath'

The file_exists in File::getThumbnailSource gets the path '/tmp' and
that does not exists on windows, because it is relative to one of the
core folder

Change-Id: I8618c8b34261451da42f88360a9d65353960e91f
2020-12-12 14:56:12 +00:00
Matěj Suchánek
4633339894 Compute experience level correctly for accounts without registration date
These accounts are usually very old and User::getRegistration returns
null for them because user_registration is null. Treat these accounts
as old enough to be in the most experienced group and only decide
on edit count. Fix queries in recent changes to avoid comparisons
with nulls as well.

Also improve documentation of User::getExperienceLevel.

Change-Id: I6090cf9b9097069469e8e547b217f0d16f0fe372
2020-12-12 13:07:20 +01:00
jenkins-bot
f49e8f4f56 Merge "Clean up temp files correctly after unit tests" 2020-12-12 10:33:19 +00:00
jenkins-bot
355c5782ab Merge "Add dependency injection to RevDelList classes" 2020-12-11 22:11:28 +00:00
jenkins-bot
339f945940 Merge "Make ParserCache use CachedBagOStuff" 2020-12-11 21:58:29 +00:00