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
Also split the cache by context, like it's done
in ::insertTags. Follows-up 17deb8353b (I0b5e48ef5).
Change-Id: I5b539a63c3210a8cd1debb2ba625b0f2dedacc39
"BadMethodCallException" sounds like it would fit, but it does
have a very different meaning, described as "exception thrown if
a callback refers to an undefined method or if some arguments are
missing". This is not what's going on here. These are methods that
should only be called from unit tests.
This appears to be a common mistake, often copy-pasted.
Change-Id: Ib39e28f596a883481d5f526460a5c871c75f5313
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
The collapsing on the enhanced changes list now works without
JavaScript.
Keyboard navigation is still supported but only the space and not the
return toggles the collapsing toggle button.
The <input type="checkbox"> element needs an unique identifier in the
`id` attribute and the same value must be in the `for` attribute of the
<label> element. A simple counter in the class EnhancedChangesList
starts twice from the beginning if the recent changes get included as:
{{Special:RecentChanges|enhanced=1}}
{{Special:RecentChanges|enhanced=1}}
Therefore a random value is used as checkbox identifier.
The module 'jquery.makeCollapsible' and its classes `mw-collapsible`,
`mw-collapsed` and `mw-collapsible-toggle-collapsed` are not needed
anymore.
The icons from module 'mediawiki.icon' are directly included because the
module has fixed selectors which do not fit here.
Bug: T172618
Change-Id: Iafd27e5d760b78ae386d833946005f86cee8dd64
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
I did this using a script written on top of antlr4 parser so it doesn't
have some clean ups a human would do but it's pretty nice already.
Bug: T330640
Change-Id: I608566700c6d737ee986bf47dda87effc69614d6
* Move the current URL logic from IRCColourfulRCFeedFormatter
to a new method RecentChange::getNotifyUrl (covered by tests now).
* Re-use this method in MachineReadableRCFeedFormatter so that
the diff/patrol/rcid etc URL is also available in the modern
JSON-based EventStreams service. And in particular to allow
porting of the legacy irc.wikimedia.org backend to a much simpler
one that is based on this.
* Also expose a title_url field which was previously missing,
and made consumption of the data needlessly difficult.
Bug: T234234
Depends-On: Id740134ef30b2276688d7b7caedb6bb652158761
Change-Id: Ic3e0aebdb61b5c0e5fbed08656db4a1e90b67518
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
Make this subroutine same as that in ::recentChangesBlockLine.
This solves the illogical issue where diff links would be displayed
only for ungrouped categorization entries, but not within groups
of them, making such entries useless for patrolling.
Bug: T270662
Change-Id: Ib4f02673cb47b42fcb1c2268691ca41cd637b0c5
* Illegal string offset and invalid argument supplied to foreach, due to incorrect type information
* Array internal pointer reset is unnecessary
* $hookData unused since MW 1.35 due to incomplete revert
* array_push() with single element
* Unnecessary sprintf()
* for loop can be replaced with str_repeat()
* preg_replace() can be replaced with rtrim()
* array_values() call is redundant
* Unnecessary cast to string
* Unnecessary ternary. Often the result relies on short-circuit evaluation, but I find it more readable nonetheless.
Change-Id: I4c45bdb59b51b243fa96286bec8b58deb097d707
There was no clean way to do this but using the global state.
The parameter is three-state to keep backward compatibility.
Bug: T304428
Change-Id: I01c5f8e9646cbe861516100c3b8d165aefb95ca0
The code assumed that curid is same for all changes in the block
(more precisely, the first one applies to all others).
This is not true when the block includes categorization changes.
Refactor the code to prefer individual link params instead of
global approach.
Bug: T270774
Change-Id: Id2286392239b67a44fbb2e95346daad9fc2a0e4f
rc_this_oldid and rc_last_oldid of categorization entries
reference revisions of the page that had its categorization
changed rather than the category page itself. These should
not be considered when building the diff link(s).
Introduce new aggregate variable $allCategorization and use
it instead of examining $rcObj (which deals only with the last
change in the block).
Finally, drop the ::userCan check deciding whether the user
can see the diff. It wouldn't work properly either, because
it would check only the last (oldest) entry in the block, not
the first (newest) and the one before the last.
Bug: T261068
Change-Id: I10bdfbad9d8a36f210ffd11a832604104f8ecdc5
It was definitely already wrong when it was added in 2008
(r33013). !$type will return true for RC_EDIT (!0), false for
all other types (RC_NEW, RC_LOG, etc.). The weak equality
comparison then casts RC_LOG to boolean (3 -> true).
So the first condition will pass if and only if $type is
RC_EDIT.
As this piece of code lasted for 15 years and there
seems to be no objection to the behavior, I just
rewrite it to make it more clear and keep the same
behavior.
Cudos to Thiemo Kreuz who disassembled the code.
Change-Id: I93f853b2a191fc3011b47fcd1ac22ac649ce541a
Keep action=history after curid=, like was done in 39783472b.
Follows up I1aa3be64f9b4e9c63cb72037b131361616f76292.
Change-Id: Ie319052754c910857adca370e1d7c8b8ff9d7618
This branch has the identical output as the default one.
There is probably no reason for unpatrolled new pages
to be handled separately (and skip check for special pages).
Change-Id: I1f2f2dcc6fe9f6b4a6b2f6d920adb6eede5fdc1f
No functional changes, pure refactoring.
- Merge two loops over the same array.
- Move "enhancedrc-since-last-visit" message generation
where it actually is needed. This should save a bit of time.
- Store the title in a variable.
- New-style comments.
Change-Id: I1aa3be64f9b4e9c63cb72037b131361616f76292
Follows-up I9bfa502a0b (9b8f153f). Also document the reason for
this logic, to the best of my knowledge, and some ideas to improve
it.
Bug: T305093
Change-Id: I4c5bf4d4da83ff1e03d0fe0dd9891507b1f1e455
The problem this patch fixes:
- Step 1: Move an existing page A to a new title B.
- Step 2: Delete the redirect at the old title A.
- What happened: All the edits made to the page prior to the move
are gone from recent changes.
- What should have happened: all the edits made to the page prior
to the move are still in recent changes under the (now redlinked)
title A.
Contrary to that, moving a page with redirect suppression would
preserve the changes.
Bug: T140960
Bug: T307865
Change-Id: Ib52a9c657620275388012a778bc9d839dd740624
I9cae1afa made the order of 'curid=...' and 'action=history' in the
history links for category changes inconsistent with other history links
on the changeslist.
Bug: T264491
Change-Id: I311c375d9250ab8a92bcf8e0b79af9e075487f96
Also, added a parameters to XmlDumpWriter so that they could be
inject via WikiExporter.
Bug: T325475
Change-Id: I84b82506509e2c09dad0691af2df958a5af5b5b0
so that extensions (i.e. CheckUser) can implement their own comment
store without having a lot of code duplication
basically the comment store version of I3a6486532f2ef36
Bug: T233004
Change-Id: Ib40f99e00a514d41776ce521baf113e46d37e9cd
Patch Ifa7a9bc replaced some longer `=== null` constructs with the
new ??= operator we have since PHP 7.4. However, some of these can be
simplified even more with the ?? operator we have since PHP 7.0.
Follow-Up: Ifa7a9bc7b2ec415ad7ecb23f4c1776f51f58fd6b
Change-Id: I7b05e723810558bb5437adc97eab54ca04d38c06
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
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
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
The result of the method has been inappropriate and
surprising since rc_patrolled was changed to distinguish
between manually patrolled and autopatrolled changes
(T184791).
When called with $auto = true, it would mark the change
as manually patrolled (not autopatrolled), but it would
not log it as such in patrol log and would still require
'autopatrol' right (not 'patrol').
Change-Id: I0bd6f2cf317d2b1c8dd50b7998724a57f5f549fb
Follow up to I14c6c22d822ae4
Fixes a warning on php 8.1 where the comment on log entries
might be null.
Change-Id: If0e41f0696a24a56f112e05c46a9a7fdbfaa3aaa
It is not possible to set $wgUseEnotif on LocalSettings.php,
because it is always set on setup, it should not be a global/setting.
Just remove it from the dynamic setup and use the config it is set from
Bug: T305093
Change-Id: I9bfa502a0b9798bd149b4cfe4db86a0461e76f55
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
It should avoid using straight join when there is a condition on the
actor table which potentionally could make the query faster.
Bug: T311360
Change-Id: Iad3d0cf2479c560be255f85d8896f37efae606c5
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
This covers all occurrences of /onfig->.*get( '/ in includes/.
Undoubtedly there are still plenty more to go.
Change-Id: I33196c4153437778496f40436bcde399638ac361
Part 1, proof of concept. Hundreds of files left to go. These changes
brought to you in large part by vim macros.
Bug: T305805
Change-Id: I44789091e9f6394c800a11b29f22528c8dcacf71
Make phan stricter about array keys
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together
Bug: T304887
Depends-On: I3105a5fd4826f8667b5232834defc5ec93be32a1
Depends-On: Ie9610a6e83731468311edb3ed17f80fc509de385
Change-Id: I701f12ab94478c3b8e7fd82110ade74a8e6b04ef
Follows-up 39a6e3dc4d (I8be497c623c5d92).
* Improve documentation all around and advertise 'class'
everywhere instead of 'uri'.
* Add test coverage for RCFeed::factory().
* Deprecate the $wgRCEngines "uri to class" mapping in favour
of specifying "class" directly in $wgRCFeeds.
* Deprecate RCFeedEngine in favour of FormattedRCFeed.
Convert to class_alias so that UDPRCFeedEngine no longer has
to extend the deprecated class name explicitly (for instanceof compat).
* Hard-deprecate RecentChange::getEngine.
Bug: T250628
Depends-On: Ie939e1d06b9ee2d841ec7256c8d24cc4e7e386dd
Change-Id: Ib6758d724c7200404c89c7ab157aa55f1cad9763
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
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
When the called function has a doc of int, it should be cast to be
explicit here.
Also cast for arithmetic operations to be explicit about the number
Change-Id: I905b78dfb66e66443e0e3203488bab5b548db543
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
The following User methods, deprecated in 1.35, have been removed:
- ::isIP,
- ::isIPRange,
- ::isValidUserName,
- ::isUsableName,
- ::isCreatableName,
- ::getCanonicalName,
- ::addAutopromoteOnceGroups,
- ::getDefaultOptions,
- ::getDefaultOption,
- ::getOptions,
- ::getBoolOption,
- ::getIntOption,
- ::setOption
- ::listOptionKinds
- ::getOptionKinds,
- ::resetOptions,
- ::getEffectiveGroups,
- ::getAutomaticGroups,
- ::getFormerGroups
User::GETOPTIONS_EXCLUDE_DEFAULTS has been removed, since it is used only in the description of User::getOptions.
Bug: T277511
Depends-On: Ida05c22f81b30d9b46678e8ede3d531c38855d83
Change-Id: I72bbc2336f8ddbc66ce67226cd2d5baaa2f807d8
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