Commit graph

137 commits

Author SHA1 Message Date
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
Petr Pchelko
c4f28d017b Replace some usages of User with Authority/UserIdentity
Change-Id: I7dfbf9bbd1709f5e67de7f6680a5a5ad156994fa
2021-03-04 17:20:40 -07:00
jenkins-bot
e585399247 Merge "Use Authority for revision audience where possible" 2021-02-25 16:31:44 +00:00
Petr Pchelko
782a46f661 Use Authority for revision audience where possible
Depends-On: I963a79d94b9e39086940a43945def7c8eff1536d
Change-Id: If99d428b391c0eaf61396565af7f38740bef6c4a
2021-02-24 10:56:50 -07:00
Thiemo Kreuz
c09f4fd6ef Fix and add various type hints
I keep fixing type hints in my local dev environment whenever I
see something that is worth updating. This is what I collected
over the past weeks.

Change-Id: Ia4f1b4bee2019abe4ab0fb0df8164e1b446229e7
2021-02-16 17:22:15 +00:00
Petr Pchelko
8d2c674ab0 Introduce ActorStore, ActorLookup and ActorFactory.
The ActorNormalization factory methods create
UserIdentityValue from the database rows, either via
fields of a joined table, or via a row from actor table.
They assume that the actor_id exist and throw othervise.

ActorNormalization is a storage-layer service providing
access to finding and acquiring actor_id.

The UserIdentityLookup methods do not instantiate new actor
on demand, they just find an appropriate row in the actor
table and return the result.

Bug: T272689
Depends-On: I74d81f3f0233efb17fc8df5178e4c477cc669c6f
Change-Id: Icfa1daca960c696a8cef8adab5eab53985802858
2021-02-08 10:06:46 -06:00
Umherirrender
4c2d2ec407 Improve docs about @param/@return object[] $row to stdClass[]
Change-Id: I4f85d90548caa1403e822ecb2333ab44787346f2
2020-11-13 23:38:06 +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
Sam Wilson
070ffce218 Add days left messages to changes-lists' clock icons
Add a new resource module for watchlist expiry behaviour in
changes lists, to add a message when the clock is clicked on
mobile.

Bug: T261415
Change-Id: I621b1571b57686beb9fb5802533b1e70d293bc2a
2020-09-16 12:00:32 +08:00
hmonroy
0c2cc49bdc Update language in watchlist expiry
Update watchlist expiry language indicators (dropdowns, tooltips, watch
via star, watch via edit):
 * Change "Permanently" to "Permanent"
 * Change "XX days left" and "Expires in X days" to "XX days left in
   watchlist"
 * Update the "Click.." sentence by star to "Click to remove it."
 * Change watch period for a page that is less than "1 day left" to "A
   few hours left"

Bug: T253135
Bug: T255632
Change-Id: I114c6f77e86ad81b1810fedcd49f52c88700ca16
2020-08-14 11:47:03 -07:00
Sam Wilson
cde153d25c Add watchlist clock icon to RecentChanges
Extend the watchlist expiry clock icon from Special:Watchlist to
also be displayed on Special:RecentChanges for expiring watchlist
items.

Bug: T258310
Change-Id: I254570addd1835119c863639111bd5394cb4b697
2020-07-28 15:30:18 +08:00
Sam Wilson
1342c90537 Fix watchlist query and filters for RecentChanges
This query was correctly excluding expired items from RC, but it
was failing to include them when the unwatched filter was set.

This is a follow-up to https://gerrit.wikimedia.org/r/c/mediawiki/core/+/602211

Bug: T252136
Change-Id: I5d43d746df21cc3674eb2e92c3f604b7c87b7d1a
2020-07-28 08:38:25 +08:00
jenkins-bot
da6f6a2aa8 Merge "Add clock icon to expiring items in Special:Watchlist" 2020-06-24 17:34:50 +00:00
Umherirrender
17a5d5a84b Fix combination of (int) and ??
(int) has higher precedence as ?? and that means the array key is always
casted first and the error suppression part of ?? cannot work

https://www.php.net/manual/en/language.operators.precedence.php

Change-Id: Iee7dc9297c0745ce48295f637a7591ce9385aa4d
2020-06-19 17:28:22 +02:00
Sam Wilson
93396e965e Add clock icon to expiring items in Special:Watchlist
If a changeslist item has an expiry date, add a grey clock icon
after the page title, with a tooltip indicating when the item
expires.

Bug: T250212
Change-Id: I38f8c85321cf257eeea8de5a3bd73bbc0b5ea393
2020-06-19 05:48:21 +08:00
Reedy
d53e91d272 Fix more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I94520b10d78a17ea8e965633dd475ea711f25c99
2020-05-15 00:33:32 +01:00
Tim Starling
28ae2a60e9 Introduce ProtectedHookAccessorTrait and pilot the Hooks::run() migration
* 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.
* Migrate ChangesList and subclasses from Hooks::run() to the new system,
  as a pilot for full migration.

Change-Id: Ic2d408fdb108087d81d0981aa670b35e0a6bb0ce
2020-05-13 13:50:32 +10:00
DannyS712
3d4fb45f96 ChangesList::insertRollback - Force rc_this_oldid to integer before use
Same for the other fields that needed to be integers

Follow up to 71b64e46e4

Bug: T251386
Change-Id: Idf4cc7d3cc54a98e46619c0996f8109bc1e88620
2020-04-29 10:56:51 +00:00
DannyS712
71b64e46e4 ChangesList::insertRollback - remove internal use of Revision objects
Bug: T246284
Change-Id: I0f506e73eee994c1dd8610803f8ce1c53164ca59
2020-04-27 22:10:25 +00:00
DannyS712
af7f397ccc Pass RevisionRecord to Linker methods
Hard deprecation of passing Revision objects will follow soon,
but until that is ready core calls can be updated

There is some code cleanup that could be done around the calls, but
to simplify review no other changes are made.

Bug: T249561
Change-Id: Ifcfb3811650decffeaa87dc033c41fd1710b47a6
2020-04-18 01:24:54 +00:00
DannyS712
9e561b4e65 Use RevisionRecord in ChangesList::revDateLink
The change to ChangesList::revDateLink is not backwards compatible,
because the method was marked as @internal

Due to a breaking change in HistoryPager::revLink, and the fact that
it didn't have a visibility defined, it has been made private

Bug: T246284
Change-Id: I2f1309fda1c312a6cf634de48ad0bbcfcb2d83ae
2020-04-04 00:49:28 +00:00
DannyS712
78bc3ae255 Hard deprecate Revision::userCan
Replace remaining uses outside of tests, hide deprecated in tests

Bug: T247259
Change-Id: I91dfb46ed6864ee89d968aea8ec93b5ea2f8389e
2020-03-11 02:10:52 +00:00
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
jdlrobson
5128caa3e5 Remove extraneous semicolons in unintended places and DOCUMENT!
The contributions and history page was showing some semicolons in unexpected places.
These unwanted semicolons are now supressed by reverting to a new standalone element
in exactly the same place as the previous semicolon. This avoids the issue of
ordering that we hit before.

I have documented the behaviour of the semicolon separator in contribpager pages
My seemingly harmless change in Ic4508788299a13c4c830f447141d17d99ebe002e

For future generations I have encapsulated what I've learned in extensive
comments which seem important given the information I have acquired while
working on this patch.

Bug: T233649
Change-Id: I9723ead1815685a9cbcccf2c4e2f3ffff36dcee3
2019-11-12 09:24:47 -08:00
jdlrobson
30c98e2351 Semicolon separator for article title and timestamp is a pseudo element
This helps us avoid a stray semicolon in mobile mode.

Bug: T233649
Change-Id: Ic4508788299a13c4c830f447141d17d99ebe002e
2019-11-04 13:49:21 -08:00
Volker E
203f7aba8c Mark consistently with any edit summaries
Marking with `.comment` to be consistent with `Linker:commentBlock`.

Change-Id: Idba91bd3d1345aa18da6745ad86f1bac2628dae7
2019-09-19 18:06:48 -07:00
jenkins-bot
60882bb6b0 Merge "Log entries can be rendered with parentheses in HTML" 2019-09-20 00:22:16 +00:00
jdlrobson
432cc11fae Log entries can be rendered with parentheses in HTML
Entries such as "User creation log" on Special:RecentChanges can
be wrapped or not wrapped in parentheses

Bug: T219348
Change-Id: Ic764081497dbe8d6d9e5bff6f8a1ceeac4b306e2
2019-09-19 03:58:51 +00:00
Umherirrender
f74400487f phan: Disable enable_class_alias_support
It is enabled for b/c in extensions, but not needed in core

Change-Id: I51dca12be9c77049f77563d9bf0edd07928c2300
2019-09-15 08:26:52 +00:00
Daimona Eaytoy
b5cbb5ab3f Upgrade phan config to 0.7.1
This allows us to remove many suppressions for phan false positives.

Bug: T231636
Depends-On: I82a279e1f7b0fdefd3bb712e46c7d0665429d065
Change-Id: I5c251e9584a1ae9fb1577afcafb5001e0dcd41c7
2019-09-04 08:20:53 +00:00
Petr Pchelko
f1914810a7 Remove usages of Title::quickUserCan
Change-Id: Ifa53e0ec800e23dc4184d133a100fb9378dfee9e
2019-08-29 11:48:30 -07:00
Stephane Bisson
04f0b682a5 RCFilters: add namespace filters for all contents and all discussions
These filters provide a shortcut to see or highlight all entries associated
with a subject or a talk namespace.

They are defined as real filters on the client-side and are superset
of all other namespace filters.

They are expanded to the list of namespaces they represent on the server-side.

Bug: T201520
Change-Id: Id9e04a38c2d7c8165c27af98959aa5715225faa8
2019-08-15 13:57:02 -04:00
jenkins-bot
c698fe313e Merge "Clean up spacing of doc comments" 2019-08-05 22:51:10 +00:00
Umherirrender
2664eeb632 Clean up spacing of doc comments
Align the doc stars and normalize start and end tokens

Change-Id: Ib0d92e128e7b882bb5b838bd00c74fc16ef14303
2019-08-05 22:29:50 +00:00
jdlrobson
2336c51488 Improve log entries display in change lists
Log entries are wrapped with parenthesis - not hardcoded into HTML
causing stray brackets in Minerva where this element is floated.
Has no impact on other skins

In addition to this the entire log entry item is wrapped in a new
span mw-changeslist-log-entry to ensure the text is recognised
as a whole entity - on Minerva floats were leading to the action
and the action object being separated (e.g. uploaded and "File:Name
were separated

Bug: T229360
Change-Id: Idae997b15f68bb0dfcaa857f7458ba3497233d41
2019-08-05 12:23:39 -07:00
Derick Alangi
40c88a6ac9 changes: Avoid use of deprecated method Revision::userCanBitfield()
Revision::userCanBitfield() is deprecated and RevisionRecord should
be used instead.

Change-Id: I0d6ad6863be520d3264809be69532dfb2e3dab9a
2019-08-03 22:43:24 +00:00
jenkins-bot
d1f681a77d Merge "ChangesList: Add $groups parameter to FetchChangesList hook" 2019-07-22 21:45:41 +00:00
jdlrobson
d7f8c45856 ChangesList: Add $groups parameter to FetchChangesList hook
This parameter is needed for consumers trying to return a $list object.

Bug: T228280
Change-Id: Ib68ff8fa782ac12479ef02247cdf78e405b64bad
2019-07-22 21:31:40 +00:00
jenkins-bot
0854352fa7 Merge "Do not hardcode square brackets in "rollback link"" 2019-07-21 19:41:24 +00:00
Derick Alangi
c5b7101a15 Avoid usage of deprecated Revision::* constants
Change-Id: Ibb55d5a01f997f9c79bcf2f5e09d4f02d22152d2
2019-07-21 17:26:48 +01:00
Derick Alangi
339211a1ea Avoid usage of deprecated Revision::* constants, use RevisionRecord
Change-Id: I872fc89e5c02dd6a3ae9cd7e76640b95dc33f514
2019-07-21 15:03:03 +01:00