Commit graph

177 commits

Author SHA1 Message Date
Jon Robson
b6adccbed6 Special:NewPages should generate markup consistent with other pager pages
This will allow us to style NewPages consistent with other Minerva
special pages.

Update getStartBody and getEndBody to be consistent with ContribsPager,
now that the output of the UL is output by mGroupByDate

Bug: T360843
Change-Id: I3424d8f4f7a40ff60827065e83532315ba35dfd3
2024-04-17 16:30:40 -07:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
James D. Forrester
0398171625 ChangesList: Switch from mixed Xml and Html classes to pure Html ones
Bug: T356544
Change-Id: Ic7c32515357610bd89d0e3965107d89a3d01f3f4
2024-02-05 21:54:21 +00:00
Arlo Breault
fc2a7030a8 Avoid misnesting div in span in OldChangesList
When OldChangesList is used, the mw-changeslist-line-inner that the
mw-changeslist-links is nested in is a span.

mw-changeslist-links is formatted as inline-block in skinStyles.less as
it is.

Bug: T275230
Change-Id: If97aa95472a73fce1f73c65dfcad961d24cf7e37
2024-01-25 17:37:25 -05:00
Dogu
43fcf91171 Consolidate duplicate branch in 'switch' statement
Merged duplicate branches in the switch statement related to the
RecentChange::SRC_NEW case, combining them with existing cases
for RecentChange::SRC_EDIT and RecentChange::SRC_CATEGORIZE.

Change-Id: If09288dcfdf40b4cf095a568eacac3621956e063
2024-01-04 00:48:16 +00:00
Amir Sarabadani
f5abfb8d58 Bump codesniffer to 42.0.0
Most noisily, this enables MediaWiki.Arrays.OneSpaceInlineArray.

Change-Id: I8ab11399c67ce7e3ab1b6249b591452774393428
2023-09-27 15:06:32 -04:00
James D. Forrester
468e69bccc Namespace Sanitizer under \MediaWiki\Parser
Bug: T166010
Change-Id: Id13dcbf7a0372017495958dbc4f601f40c122508
2023-09-21 05:39:23 +00:00
James D. Forrester
1d0b7ae1e2 Namespace User under \MediaWiki\User
Bug: T166010
Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
2023-09-19 19:18:16 +00:00
James D. Forrester
5088626212 Namespace 'special' Pagers under \MediaWiki\Pager
They're under 'specials' because that's where they're mostly used,
but they're just another kind of Pager (shown by their use outwith
the MediaWiki\Specials hierarchy, which is a bad code smell for us
to review later).

Bug: T166010
Change-Id: Iad3f91582b723c1e6679525aa852ffdfd8c6d5ba
2023-09-18 18:23:13 +01:00
Matěj Suchánek
02389446a5 ChangesList: Cache user links
Follow up to a468534. The caching added to RCCacheEntryFactory
would be utilized only by EnhancedChangesList. This should
improve performance for OldChangesList, too.

Bug: T341319
Change-Id: Ibb1907732c71d0783d1a627063debb2a484cafe7
2023-08-20 16:55:58 +02:00
Matěj Suchánek
cfad5d8d71 Cache some more repeated messages in changes lists
Change-Id: I635eaf947280fd1071e308b19715d581e1c1cb15
2023-08-19 14:32:58 +02:00
Matěj Suchánek
f3b25b3891 ChangesList: Call MapCacheLRU::makeKey
Also split the cache by context, like it's done
in ::insertTags. Follows-up 17deb8353b (I0b5e48ef5).

Change-Id: I5b539a63c3210a8cd1debb2ba625b0f2dedacc39
2023-08-16 03:31:00 +00:00
Timo Tijhof
17deb8353b objectcache: Add MapCacheLRU::makeKey() and adopt in ChangesList
This came up during code review of change I91588aebae7e49e3d3c.

Change-Id: I0b5e48ef52513f012bfbb460ab5a649178ebf255
2023-08-03 17:19:33 +00:00
jenkins-bot
0fadd34392 Merge "RecentChanges: Add process caching to RecentChanges UserLinks and Tags parsing" 2023-07-20 01:32:58 +00:00
ttomalak
a468534689 RecentChanges: Add process caching to RecentChanges UserLinks and Tags parsing
Rendering UserLinks or Tags requires parsing, which when run on thousands of records, adds up to a significant amount of processing time. More often than not, this can be optimized by storing already visited tags or user links as those "renders" will not change for the single request run and are repeated constantly on the list.

Bug: T341319
Change-Id: I91588aebae7e49e3d3cb77702cf28677b4a14c8d
2023-07-18 12:05:33 +02:00
Umherirrender
1086958611 Replace array_keys in foreach to use $_ as value instead
When the value of the associated array is not used, there is no need to
use array_keys and create internal a copy of the array, just omit the
value with $_ to tell static analyzer that the var is unused.

Change-Id: I5c6d667e98c0167c0573c683f0d617bc1d4ca619
2023-07-10 02:53:52 +00:00
thiemowmde
990ef704ce Collapse sequences of if into short return if possible
The main goal is to make this code faster and easier to read, and to
avoid duplication.

Change-Id: I925d742d560e9d90e3ecc9ff19fe7e87b60bf9a4
2023-06-15 15:14:40 +02:00
Umherirrender
e04d3a28f6 Replace internal Hooks::runner
The Hooks class contains deprecated functions and the whole class is
going to get removed, so remove the convenience function and inline the
code.

Bug: T335536
Change-Id: I8ef3468a64a0199996f26ef293543fcacdf2797f
2023-05-11 06:17:38 +00:00
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
This is moderately messy.

Process was principally:

* xargs rg --files-with-matches '^use Title;' | grep 'php$' | \
  xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1'
* rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \
  xargs rg --files-with-matches 'Title\b' | \
  xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1'
* composer fix

Then manual fix-ups for a few files that don't have any use statements.

Bug: T166010
Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a
Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
2023-03-02 08:46:53 -05:00
Amir Sarabadani
7d8768e931 Reorg: Move HTML-related classes out of includes/ to Html/
Bug: T321882
Change-Id: I5dc1f7e9c303cd3f5b9dd7010d6bb470d8400a18
2023-02-16 20:40:01 +01:00
Thalia
3ed0dfcf80 OldChangesList: Pass revision ID through to user link
Bug: T326396
Change-Id: I09a407f24572312c9ec2ce9653ebbf28ea7819c1
2023-01-30 17:11:25 +00:00
Gergő Tisza
20d7a519ec
Fix history pager tools
Follows up Ia03038e86c6a607c8b75eefedbf0285ca1a2f8c8.

* Only generate a rollback link for the latest revisions in
  ContribsPager.
* Gate the entire ChangesList::insertPageTools beind the RC
  attribs check, not just the rollback link generation.
* In ContribsPager::formatRow, check for the existence of $page in
  a more reasonable place. This was already broken before Ia03038e
  so I suspect $page is never null in practice (in theory, a
  ContribsPager__reallyDoQuery hook handler could somehow produce
  a $row with no title information), but it can't hurt.
* Add some documentation and FIXMEs.
* Remove a comment from ChangesList - part of it is not true
  anymore after Ia03038e, part of it already didn't make sense
  before that.

Bug: T51541
Bug: T325753
Change-Id: If848e38b568492579382a2c920cb865fb0326d99
2022-12-22 14:36:14 -08:00
jenkins-bot
c903124b77 Merge "Make use of ?:, ?? and ??= operators in mostly trivial cases" 2022-12-16 02:51:26 +00:00
Jon Robson
012a387587 Generalize History pager tools for use in other contexts
The history page renders an extensible list of tools for each
change list row. I've factored this code out so that it
can also be used on other pages that use the Pager class.

This generalizes the logic for the rollback link and makes sure
the control is standardized across pages. It also allows
the onHistoryTools hook run. I suggest we rename this to something
more generic in a follow up.

Right now usages of onHistoryTools are low but there should be
no issues with running it on more than the history page. One of
the benefits of this is the thanks link will now show on the
contributions page, watchlist and recent changes.

Bug: T51541
Change-Id: Ia03038e86c6a607c8b75eefedbf0285ca1a2f8c8
2022-12-15 14:44:18 -08: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
thiemowmde
70aa9c8e35 Make use of ?:, ?? and ??= operators in mostly trivial cases
The motivation is to make the code less confusing. I hope this is the
case.

?? is an older PHP 7.0 feature.
??= was added in PHP 7.4, which we can finally use.

Change-Id: Id807affa52bd1151a74c064623b41d950a389560
2022-12-05 21:37:13 +01:00
Tim Starling
0077c5da15 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

I used regex replacement.

Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
2022-10-21 15:33:37 +11:00
STran
d35ac50fd4 Add revid to category changes
Pass along a revid to category changes on Special:RecentChanges
This change allows IPInfo downstream to pull the revid for use in
its subsequent API call

Bug: T310813
Change-Id: I533d5fffd64dc741d5b28563f9e0c0827a48906c
2022-07-27 21:32:42 -07:00
diesel kapasule
e908b23627 Adding log links for deletion and protection to ChangesList
Add action links for deletion and protection on Changeslist.php.
This will make links more consistent with the log page entries.

Bug: T49466
Change-Id: Ic1fdb2b4280bdeac521323aafe4548819778c870
2022-06-01 09:56:45 +00:00
Umherirrender
1af94959bf changes: Replace deprecated User::getOption
Bug: T296083
Change-Id: I6744ed237fb30aec5540eb68140ab6f8c5d71246
2022-04-29 21:51:20 +02:00
Aryeh Gregor
666ca1bdf3 Use MainConfigNames instead of string literals, #2
This covers all occurrences of /onfig->.*get( '/ in includes/.
Undoubtedly there are still plenty more to go.

Change-Id: I33196c4153437778496f40436bcde399638ac361
2022-04-13 18:55:46 +03:00
C. Scott Ananian
9e033de4f2 Don't double-escape the ellipses in Language::truncateForVisual()
It turns out this gets rid of a bunch of suppressed
"SecurityCheck-DoubleEscaped" that appear to have been accurate
warnings.

There seems to have been some confusion about how ::truncateForVisual()
is supposed to be used; in particular it is to be passed *unescaped*
output, because it is not (generally speaking) safe to truncate
HTML-escaped strings.  The goal of ::truncateForVisual() is to have
a specific number of codepoints in the output for display purposes,
the encoding of those codepoints is not an issue (htmlspecialchars
can be applied to the *return value*.)  If you need a specific number
of *bytes* you should be using ::truncateForDatabase().  If you want
a certain number of *HTML bytes* then the ::truncateHtml() method
is probably what you want.

Slightly refactor some code in RevDelLogItem to avoid a false positive.

Bug: T301205
Bug: T290624
Change-Id: I893362e049aedfa699043fcf27caf4815196f748
2022-02-10 17:09:18 -05:00
Jon Robson
6c67798d6c [ChangesList] Time element in ChangesList should be consistently named
Follow up to I0cba011f0ab8cb8fd59962b5eafb7650deefe841

This class is usually used for dates.
In Special:Contributions an additional class is used for times
so let's use that here.

This will be helpful for T219349

Change-Id: Ibd5cff5cc37bec8eb840d7f0479fcb4eb8346611
2022-01-20 22:28:21 +00:00
jenkins-bot
0f062d1803 Merge "ChangesList: Add .mw-changeslist-time (no date) to output to each row" 2022-01-10 23:40:14 +00:00
jdlrobson
be86676347 ChangesList: Add .mw-changeslist-time (no date) to output to each row
Bug: T298639
Change-Id: I0cba011f0ab8cb8fd59962b5eafb7650deefe841
2022-01-10 23:19:40 +00:00
TChin
47adb6d65a Refactor global variables to use MediaWikiServices instead
Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI.

Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228

* This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it.

A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki

Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
2022-01-10 13:55:53 -05:00
Siddharth VP
191cadb6a5 Fix typos in comments (C-D)
Change-Id: I568fb93b53feb83f026d485136dd0d116d677f4f
2021-12-30 18:00:02 +05:30
Umherirrender
e056134711 Call static ChangesList::isDeleted statically
Using static:: and not self::,
because subclass EnhancedChangesList already calling it that way

Change-Id: Ibc57bf9bbfdb86a0fe6a7dd18e9ff730b882dab5
2021-12-05 01:23:46 +01:00
Amir Sarabadani
9bcd3fdfa5 Remove ActionAjax
Bug: T42786
Change-Id: I8bda0c281e1f4abbffbddb80ac74a6d61a034d28
2021-12-01 22:31:30 +01:00
Umherirrender
bb8d3e0d68 Fix missing history-deleted class for suppressed revision on changeslist
For comment and content the class mw-history-suppressed is added
additional, should be the same for the user.

Follow-Up: I08f14f712479e1b170c606e2b64857f8386acd76
Change-Id: I7d477913952b9cc67314d1ec96f83db2846a74cb
2021-11-27 23:49:12 +01:00
Tim Starling
f7f84dddb3 Introduce CommentFormatter
CommentParser:

* Move comment formatting backend from Linker to a CommentParser service.
  Allow link existence and file existence to be batched.
* Rename $local to $samePage since I think that is clearer.
* Rename $title to $selfLinkTarget since it was unclear what the title
  was used for.
* Rename the "autocomment" concept to "section link" in public
  interfaces, although the old term remains in CSS classes.
* Keep unsafe HTML pass-through in separate "unsafe" methods, for easier
  static analysis and code review.

CommentFormatter:

* Add CommentFormatter and RowCommentFormatter services as a usable
  frontend for comment batches, and to replace the Linker static methods.
* Provide fluent and parametric interfaces.

Linker:

* Remove Linker::makeCommentLink() without deprecation -- nothing calls
  it and it is obviously an internal helper.
* Soft-deprecate Linker methods formatComment(), formatLinksInComment(),
  commentBlock() and revComment().

Caller migration:

* CommentFormatter single: Linker, RollbackAction, ApiComparePages,
  ApiParse
* CommentFormatter parametric batch: ImageHistoryPseudoPager
* CommentFormatter fluent batch: ApiQueryFilearchive
* RowCommentFormatter sequential: History feed, BlocklistPager,
  ProtectedPagesPager, ApiQueryProtectedTitles
* RowCommentFormatter with index: ChangesFeed, ChangesList,
  ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryRecentChanges
* RevisionCommentBatch: HistoryPager, ContribsPager

Bug: T285917
Change-Id: Ia3fd50a4a13138ba5003d884962da24746d562d0
2021-09-28 11:13:03 -07:00
Umherirrender
07b499fbcf build: Update mediawiki/mediawiki-phan-config to 0.11.0
Addition and remove of suppression needs to be done with the version
update.

Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
2021-09-07 17:19:05 +02:00
Umherirrender
e29cd309d1 changes: Remove ChangesList->skin
Each Skin is a IContextSource, which makes the instanceof checks in the
constructor not needed

Change-Id: Ie44ee72c70956da5f82cd6b562e527a485030b51
2021-09-03 23:03:24 +02:00
Umherirrender
57b196cac3 docs: Improve doc types around changes list and the changes special page
Add type hints to closures and fix doc types

Change-Id: Ib864f1b4c384bc0cd553596b5dd5ba05a3f4f22d
2021-08-31 19:13:35 +02:00
DannyS712
47d70dbfba Post Revision-removal cleanup
Updates for the removal of the Revision class itself
and the various methods/hooks/variables removed in the
process, including:

- Update some documentation removing most references
to the Revision class and updating the MCR migration
notes to reflect the past tense for Revision methods.

- Change some capitalization from "Revision" to "revision"
to make it clear comments are about revisions in general,
not the Revision class in particular.

- Minor code tweaks including removing unused variables that
were around for the old hooks that were removed, and
removing the use of DeprecatablePropertyArray where no
longer needed for anything.

- Fix incorrect documentation for PageUpdater::getStatus(),
the status value changed a while ago to have revision-record
in addition to revision, and recently to only have the
revision-record, but ironically PageUpdater was never updated.

- Removed Parser::$mRevisionObject, used to be a Revision object
and was deprecated in 1.35, missed earlier because it was no
longer being set to Revision objects, always null.

- Add RevisionRecord typehints in DummyLinker to match those
in the corresponding Linker methods

This should be a no-op in terms of functionality.

Bug: T247143
Change-Id: I03bbb94fc29085855448780b1a5ad9063911ecc4
2021-06-24 00:32:39 +00:00
Amir Sarabadani
b6f148bec6 Add classes to when a linked change is suppressed
This also tries to centralize adding logic of adding history-deleted
class as well. To make future changes easier.

This doesn't affect history deletion on files, recentchanges, and logs yet

Bug: T23272
Change-Id: I08f14f712479e1b170c606e2b64857f8386acd76
2021-04-29 15:28:06 +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
mainframe98
f38fee2171 Fix missing styles on diff
The markers for minor, bot, unpatrolled and new page edits used to
be bolded, but weren't after I3f45c95d2856c8fce2da5175b52089d4e629a41e.
Move the relevant styles to mediawiki.interface.helpers.styles, which
is used on all places where these markers can be found.

Bug: T279099
Change-Id: I7af935da13669b6519ba770b413cb1ef027cac1c
2021-04-02 10:52:26 +02:00
Petr Pchelko
9011bfd4cf Convert CategoryMembershipChange to Authority
Change-Id: Icbc1c7f7f248dfbc8a391f91d9b3608fdf2224a1
2021-03-24 11:47:26 -06:00
Petr Pchelko
eec331897e Replace various usages of PermissionManager with Authority
Change-Id: Idc303bdbbe2b7ce9e7011ee1f3926c781c56af71
2021-03-17 20:23:58 -06:00