Commit graph

39 commits

Author SHA1 Message Date
Umherirrender
8585fa9f12 logging: Add class for suppressed items on Special:Log
Similiar to the handling for suppressed edits since b6f148b

Bug: T327538
Follow-Up: I08f14f712479e1b170c606e2b64857f8386acd76
Change-Id: Icfb46d9ef02984510ef1c2c5e4785345cbe6ad2f
2023-01-20 18:45:45 +00:00
Umherirrender
0bcfd1db54 tests: Expand test for LogFormatter::getPerformerElement/Comment
Test the revision deleted part of both functions

Change-Id: I980b39d1e458808e6a6ea9b44e574f9637c67ba4
2023-01-11 00:47:08 +01:00
Umherirrender
f65e6bb488 Replace deprecated Linker::commentBlock/revComment
Bug: T324906
Change-Id: I8cf96c3b7a03127ce1243f7a7e849b6d5a5d3dfa
2022-12-11 01:33:56 +01:00
Amir Sarabadani
2d60ba0c63 Reorg: Move DummyLinker and Linker to linker/
This feels like a no-brainer unless I'm missing something obvious

Bug: T321882
Change-Id: Id49c3d0dd6ea4593211048850856b5b8e05a8fb3
2022-12-08 06:38:17 +01:00
Derick Alangi
175832a8e9 Migrate usage of setMwGlobals() to overrideConfigValue(s)
Change-Id: I49d97864d8f9d8cadf01b0c0dc653fbac4ca9e94
2022-08-01 06:16:22 +01:00
Umherirrender
047c184bfe tests: Use Title::makeTitle instead of Title::newFromText
Avoid parsing known titles in tests to improve performance

Change-Id: Ibfccfe696f0b8bfda0b99abae324e60bbecef7d8
2022-07-06 00:44:00 +02:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
daniel
fed7f0b179 Remove $actor field from UsererIdentityValue
Code that needs to store an actor ID in the database to
represent a UserIdentity, or needs to construct a UserIdentity based on
an actor ID loaded from the database, should use the ActorNormalization
service.

Note: The getActorId() method is removed from the UserIdentity interface,
but all concrete classes continue to support it for now.
UsererIdentityValue::getActorId() is hard deprecated and should
be removed in 1.37. It always returns 0.
User::getActorId() is not deprecated at this point.

Bug: T274179
Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237
Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
2021-04-13 18:18:06 +00: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
DannyS712
370856f0cf Remove use of $wgUser from LogFormatterTest, unneeded
Bug: T243708
Change-Id: I4d76ffbec4f094178059d3cccb65bf4837321f08
2020-09-14 20:26:13 +00:00
Daimona Eaytoy
f5529400cc Stop using assertContains with string haystack
This was done automatically by replacing every assertContains with
string *needle*. Then verifying the results.

Bug: T192167
Change-Id: Id8cbbf3b01e948f80046714183cc299f86be21fd
2019-12-15 00:22:44 +00:00
Max Semenik
dd7026585c Backwards-compatible PHPUnit 8 preparations
This commit splits changes from Ic14f5debc53e55d6714 to reduce it to
only strictly needed things. It can be merged immediately.

Bug: T192167
Change-Id: I8c541a66ea13421dbe7fa51d197d5455cc4786eb
2019-11-02 12:40:07 -07:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Aryeh Gregor
e787246ce8 LanguageFactory to replace Language::factory()
Languages with variants no longer can override the parent's constructor
(which is now used for injecting services). Instead, they need to
override Language::newConverter().

Bug: T201405
Change-Id: I923400d61763cf1db88cb0c3f684c9c10e58032d
2019-10-23 10:48:23 -07:00
Aryeh Gregor
043d88f680 Make LocalisationCache a service
This removes Language::$dataCache without deprecation, because 1) I
don't know of a way to properly simulate it in the new paradigm, and 2)
I found no direct access to the member outside of the Language and
LanguageTest classes.

An earlier version of this patch (e4468a1d6b) had to be reverted
because of a massive slowdown on test runs. Based on some local testing,
this should fix the problem. Running all tests in languages is slowed
down by only around 20% instead of a factor of five, and memory usage is
actually reduced greatly (~350 MB -> ~200 MB). The slowdown is still not
great, but I assume it's par for the course for converting things to
services and is acceptable. If not, I can try to optimize further.

Bug: T231220
Bug: T231198
Bug: T231200
Bug: T201405
Change-Id: Ieadbd820379a006d8ad2d2e4a1e96241e172ec5a
2019-10-07 13:18:47 -07:00
Amir Sarabadani
308e6427ae Revert "Make LocalisationCache a service"
This reverts commits:
 - 76a940350d
 - b78b8804d0
 - 2e52f48c2e
 - e4468a1d6b

Bug: T231200
Bug: T231198
Change-Id: I1a7e46a979ae5c9c8130dd3927f6663a216ba753
2019-08-26 18:28:26 +02:00
Aryeh Gregor
e4468a1d6b Make LocalisationCache a service
This removes Language::$dataCache without deprecation, because 1) I
don't know of a way to properly simulate it in the new paradigm, and 2)
I found no direct access to the member outside of the Language and
LanguageTest classes.

Change-Id: Iaa86c48e7434f081a53f5bae8723c37c5a34f503
2019-08-22 14:25:18 +03:00
daniel
20717fd031 LogFormatter::formatParameterValue: handle bad user names
This makes LogFormatter more robust against bad user names coming from
broken log records.

Bug: T224368
Change-Id: Ifce9e86bddba274182253cd25338766e8093d6ad
2019-07-03 18:49:58 +02:00
Roan Kattouw
5ce1e2b743 Linker: Use parentheses by default in userToolLinksRedContribs()
This function had been changed to unconditionally disable parentheses,
but none of its callers load the CSS needed to make that work.

Bug: T220767
Change-Id: I566d65e155258d3bd1a1a06bca9aa2b3a2d417ee
Follows-Up: I6eeeaa3b58d37adb7fefb4cc6915022229b3b324
2019-04-19 15:09:36 -07:00
Kunal Mehta
6066f6c063 Declare LogFormatter::$parsedParameters property
And rework LogFormatterTest so it doesn't need to access that property.

Change-Id: I4d429430efe74dc083019a1a8bb07257785484b9
2018-05-01 19:56:13 -07:00
Umherirrender
45da581551 Use ::class to resolve class names in tests
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
2018-01-26 22:49:13 +01:00
Brad Jorsch
fa2724fa84 LogFormatter: Don't return a non-array from formatParameterValueForApi
If the title for a 'title' or 'title-link' type is invalid, the code
still must not return a non-array from the method.

I'm not sure this is what was behind T176938, but it's the only thing I
can find that might cause the errors I saw logged at about the same
time.

Change-Id: Iae77eb6ad9a64d8b67074164ff0c0fea36826f3c
2017-09-28 10:06:53 -04:00
Timo Tijhof
8596a01658 phpunit: Make LogFormatterTest less slow
Right now it's quite slow because it reloads LocalisationCache
for every test case.

Change the reload to only happen once for the entire class.

Also use RequestContext instead of wgLang to match logic in
the parent class (MediaWikiLangTestCase).

$ phpunit includes/logging/LogFormatterTest.php
Before
- run 1) Time: 23.56 seconds, Memory: 48.00MB
- run 2) Time: 22.41 seconds, Memory: 48.75MB
After
- run 1) Time: 14.27 seconds, Memory: 47.50MB
- run 2) Time: 13.45 seconds, Memory: 47.25MB

Change-Id: Ia791563ca9094c36782acfe9826def45f2a1d621
2017-04-14 23:44:23 +00:00
James D. Forrester
1e9c361960 tests: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I46261416f7603558dceb76ebe695a5cac274e417
2017-02-21 02:14:34 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Amir E. Aharoni
bfdd3369c2 Fix Generic.Files.LineLength phpcs check in files under phpunit/includes
Bug: T102614
Change-Id: Iee3df5f064f595ecebe8210cc936bc3d20a122c9
2015-10-03 17:13:29 +00:00
addshore
349ca056b7 Move LogFormatter test comment block
This was missed in:
https://gerrit.wikimedia.org/r/#/c/239783/
Ia5016c82c00dd7c35a6f1253d6e385b587ec485e

Change-Id: Ibf537aaca2a0ca9d2c509499f6da5b9e51b06037
2015-09-25 15:36:06 +00:00
umherirrender
d6961552b3 Migrate protect log to new log system
This localize the protect type, level and expiry on Special:Log/protect.
To allow i18n there are some details stored in the log params of new log
items, these details also shown on API output.
The details cannot get from the old existing data, because there are
containing L10n strings therefore i18n works only for new items.
In the api and for IRC the old description text is still stored in the
log params for backward compatibility.

This allows use of gender on Special:Log. Old messages are kept for use
in IRC. Tests already exists to ensure an unchanged IRC message.

Bug: T47988
Change-Id: I3bb85c61b857972e66c99c499d7d785c88cafb25
2015-09-25 17:07:50 +02:00
addshore
829d1a4c15 Cleanup RecentChangeTest, move things out that don't belong
This moves out a bunch of stuff that doesnt
seem to test anything in RecentChange....

This also shows us how few tests RecentChange
actually has!

Change-Id: Ia5016c82c00dd7c35a6f1253d6e385b587ec485e
2015-09-21 14:33:10 +01:00
Brad Jorsch
61233fc847 API: Move parameter formatting into LogFormatter
This allows for extensions to format their log entry parameters, and
keeps the code for formatting API log entry parameters in the same place
as for other formatting.

This also takes the opportunity to rearrange the output format slightly
to avoid conflicts like what's happening in T73020.

Bug: T35235
Bug: T73020
Bug: T91466
Change-Id: I6846ce09322eb404c506b5a51780a44ce9279fe2
2015-04-17 04:59:41 +00:00
umherirrender
ea18e5efe7 Call Language::getLocalisationCache() static
Change-Id: Ibbe03b92f2beebaaf93ba9e3c5bebbf3d7626b7a
2014-01-04 21:33:12 +01:00
Alexandre Emsenhuber
2d0e98df31 Change mode of non-executable files back to 0644
Change-Id: Ib9dce1eea8c34986364aabed7f1770101c72c649
2013-11-05 08:13:32 +01:00
addshore
749599fc3c @covers tags for unit tests
Change-Id: I2b486b38326bf23bd379efba2142034e24c0745f
2013-10-24 18:22:57 +01:00
Siebrand Mazeland
de04f37ef1 Update formatting
5 of n.

Change-Id: I811ca957b6588085d67606ebc0cd4033a1e53839
2013-02-15 12:35:50 +00:00
Brad Jorsch
3b1ce49023 (bug 43307) L10n recache needed in LogFormatterTest::tearDown
LogFormatterTest replaces all extension localization files in
$wgExtensionMessagesFiles with its own, and correctly restores this
variable. But it neglects to refresh the localization cache after
restoring the variable, so subsequent extension tests are missing their
localization.

Change-Id: I74809af47830a5e09c36f8fec20c9c65b1e3aa17
2012-12-20 14:55:40 -05:00
jan
8b5bfd8b88 (bug 24620) Add types and test for LogFormatter
This change adds types to LogFormatter like "msg" so log values
(parameters for the log message) can be formated as e.g. a message in
user or content language.

This change adds tests for LogFormatter, too. Tested are the normal log
params, the log params with type and the output of the comment.

This change repairs the changes I6a56c204 and I7218a173

Change-Id: Ief3665056b3bb613ff709821306017ee7967c444
2012-12-12 01:00:03 +00:00
Siebrand
1879a95a76 Revert "(bug 24620) Add tests for LogFormatter"
As I6a56c204 breaks extensions because of changing protected methods to public, this has to be reverted. We need a solid solution and the next 1.21-wmf is being branched tomorrow. Revert is the sanest solution at the moment.

This reverts commit 888fe0ffb3
2012-12-10 01:23:07 +00:00
jan
888fe0ffb3 (bug 24620) Add tests for LogFormatter
This change adds tests for LogFormatter. Tested are the normal log
params, the log params with type and the output of the comment.

Change-Id: I7218a1738c97db1d888605cecdfbffe21ca00fbf
2012-12-10 00:01:14 +00:00