Commit graph

207 commits

Author SHA1 Message Date
Ammarpad
2f0a0370a6 ContributionsPager: Fix getTemplateParams() parameter
This needs to get $classes by reference

Bug: T378132
Depends-On: I9d4507fc8e7b2e44c8ecbda9400c5af8103b7c81
Follow-Up: I95a5b88ec81583e16ccf8e58cdb8e12e00aae5bf
Change-Id: I810f26e04113d5c9c7c51f88430063b0d07e6b25
(cherry picked from commit 83c5211931e1f53448d7dc69956a9584f87b7620)
2024-10-25 13:52:47 +00:00
STran
974b5ce5da Support template overrides in ContributionsPager
Downstream pagers that extend ContributionsPager may want to use their
own templates and fields. To avoid polluting the upstream pager, allow
the template and parameters to be overriden.

- Move template processing into two overrideable functions,
  `getTemplateParams` and `getProcessedTemplate`

Bug: T356292
Change-Id: I95a5b88ec81583e16ccf8e58cdb8e12e00aae5bf
2024-10-22 01:51:22 -07:00
jenkins-bot
82e4b70382 Merge "ContributionsPager: Make $messages property visible to subclasses" 2024-10-18 16:34:04 +00:00
jenkins-bot
fa70d71cd9 Merge "ContributionsPager: Separate method to check revision author visibility" 2024-10-18 16:33:43 +00:00
jenkins-bot
4c3f0c487a Merge "ContributionsPager: Make separate method for adding revId to HTML" 2024-10-18 16:31:35 +00:00
jenkins-bot
3a4b9fe3f1 Merge "ContributionsPager: Format all rows if the pager only has revisions" 2024-10-18 16:31:26 +00:00
jenkins-bot
55767493b6 Merge "ContributionsPager: Re-use existing method to check for revision row" 2024-10-18 16:31:18 +00:00
jenkins-bot
e347b564ad Merge "ContributionsPager: Only pass the row into formatting helper methods" 2024-10-18 16:31:10 +00:00
Thalia
7565f199fe ContributionsPager: Make $messages property visible to subclasses
Why:

* ContributionsPager is being updated to allow subclasses greater
  control over formatting. The $messages property holds a cache of
  messages used for formatting, so is needed by subclasses.

What:

* Make the $messages property protected.

Bug: T377482
Change-Id: Ic3a475cc4fbd730f11a9c68972b89ac52094330c
2024-10-18 14:26:26 +01:00
Thalia
3791dc1202 ContributionsPager: Separate method to check revision author visibility
Why:

* Deleted revision authors are marked in the contributions line. The
  visibility check uses the row's RevisionRecord. However, in some
  subclasses there is no RevisionRecord, but visibility can be
  determined from the row directly. A separate method allows
  subclasses to perform this check.

What:

* Separate out the author visibility check into a new method.

Bug: T377482
Change-Id: I92074f28ff66266e574e743ccd57009589177f06
2024-10-18 14:26:26 +01:00
Thalia
45c0d3cd37 ContributionsPager: Make separate method for adding revId to HTML
Why:

* Each revision is displayed as a <li> with a data attribute
  containing the revision ID. However, for subclasses that show
  contributions from external wikis, it doesn't make sense to add
  revision IDs to the HTML.

What:

* Make a separate method for populating HTML attributes, that can
  be overridden by a subclass.

Bug: T377482
Change-Id: Ia22dde32071408798797b9f6f9f862ec5b57b2a4
2024-10-18 14:26:26 +01:00
Thalia
9061de3ebb ContributionsPager: Format all rows if the pager only has revisions
Why:

* A ContributionsPager can be configured to fetch only revisions,
  or to display revisions and other types of contributions, added
  by extensions. It avoids formatting rows from extensions. It
  infers whether to skip by checking whether a RevisionRecord and
  Title object could be made for the row.
* However, if configured only to fetch revisions, then it should
  never skip the formatting, since every row is a revision.

What:

* Always execute ::formatRow if $revisionsOnly is true.

Bug: T377482
Change-Id: Ia7d4ab2abe4bef482ee8016ccbe4343977053611
2024-10-18 14:26:26 +01:00
Thalia
b970381a8c ContributionsPager: Re-use existing method to check for revision row
Why:

* ContributionsPager::doBatchLookups should skip a row if a
  RevisionRecord can't be made. The check is hard-coded instead
  of using the ::tryCreatingRevisionRecord method. This means that
  if a subclass overrides ::tryCreatingRevisionRecord, the
  override won't be used here.

What:

* Call ::tryCreatingRevisionRecord from ::doBatchLookups.

Bug: T377482
Change-Id: Ic6675e31a12360d81fc8f16029ec0e7b170ec32f
2024-10-18 14:26:26 +01:00
Thalia
e978ba9c4b ContributionsPager: Only pass the row into formatting helper methods
Why:

* Formatting helper methods were introduced so that subclasses could
  have more control of formatting their rows.
* These helper methods should take only the actual row as an argument,
  since that is the only thing a subclass can guarantee is available,
  e.g. it may not be possible to make a Title or RevisionRecord from
  the row.

What:

* Pass only the row into the formatting helper methods.

Bug: T377482
Change-Id: Ic03b00bf93d25265cc162f57464f9d92d0a3c717
2024-10-18 14:26:00 +01:00
Ebrahim Byagowi
5a318a56cc Remove <bdi> around comments in Special:Contributions
.comment has a unicode-bidi: isolate; so this isn't needed.

It fixes yet other regression of
I919bb8270ddb13b38d747dba1a3a7fa0d3bb1a4f

Bug: T377555
Change-Id: Id60a7df155e550639004543026459b97eb01d840
2024-10-18 14:13:18 +03:30
jenkins-bot
abc8da60be Merge "Use explicit nullable type on parameter arguments" 2024-10-16 23:10:14 +00:00
Umherirrender
e662614f95 Use explicit nullable type on parameter arguments
Implicitly marking parameter $... as nullable is deprecated in php8.4,
the explicit nullable type must be used instead

Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a

Break one long line in SpecialPage.php

Bug: T376276
Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
2024-10-16 20:58:33 +02:00
James D. Forrester
e7db78e8d6 Replace uses of deprecated ChangeTags static methods
Bug: T360664
Change-Id: I3363a225e54bb2cae01ba066d432a8b7b21933d2
2024-10-16 13:30:12 -04:00
Thalia
a75d5370f2 ContributionsPager: Split formatRow into separate methods
Why:

* ContributionsPager::formatRow builds links and other elements in
  a contributions row. It is a long, old method that is difficult
  to work with since it does a lot and is sometimes in a confusing
  order.
* Since ContributionsPager is extended by various classes, it is
  helpful to have separate, overridable methods for some of the
  formatting.

What:

* Refactor ::formatRow by introducing separate methods for each link
  or other element in the row. This allows handling to be overridden
  by subclasses, and also makes the formatRow easier to understand.
* To make code review easier and safer, make minimal changes - e.g.
  keep old variable names, comments and flow structure.

Bug: T356292
Change-Id: Iee83deafa584fbfe7f6adb1c30df014ec6945288
2024-10-15 06:57:41 +01:00
Ebrahim Byagowi
596c2355aa Use HTML markup instead of bidi control chars in wiki changes
This removes use of getDirMark() in Special:Contributions and
both forms of Special:RecentChanges (the old and "new" grouped
one).

They had common parts that's why they should've been dealt with
at once.

Bug: T375975
Change-Id: I919bb8270ddb13b38d747dba1a3a7fa0d3bb1a4f
2024-10-04 00:27:00 +03:30
Umherirrender
ca8b1eb476 Add missing documentation to class properties (frontend-related)
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: Id75cb2e5fbee0fe7600f92473d876f23730d46b7
2024-09-05 21:41:19 +02:00
Derk-Jan Hartman
6d2c0119af Remove Y2K38 limit from reverse chronology pager
Y2K38 is 14 years from now. Past experience shows that some installs
survive well over 14 years.

Windows 32bit is 0.04% and those systems are very unlikely to ever run a
2025 version of MediaWiki.

Bug: T122660
Change-Id: I45274f639159de83413e05aa498539f7be5f0e05
2024-08-24 23:33:54 +02:00
Matěj Suchánek
ef02621005 Preload parent revision sizes for archive rows
Not nice, but hopefully working solution.

Bug: T372611
Change-Id: I64f2ca4a97cda89d9dc21cd5bc5cbba53af13e33
2024-08-20 18:50:44 +02:00
Thalia
106155e0a4 Extend ContributionsPager from DeletedContribsPager
Why:

* Special:DeletedContributions is built entirely separately
  from Special:Contributions and lacks many of the features
  that Special:Contributions has, such as search form filters.
* As part of the temporary accounts project, a special page
  showing deleted contributions for temporary accounts was
  added via the CheckUser extension (T363362), which has
  feature parity with Special:Contributions. This was achieved
  by factoring out abstract base classes for contributions
  pages.
* SpecialDeletedContributions and DeletedContribsPager should
  be updated to make use of this shared functionality, to
  avoid confusion for users switching between these various
  pages.

What:

* Update DeletedContribsPager to extend ContributionsPager.
* Two hooks were run from DeletedContribsPager:
    - DeletedContribsPager__reallyDoQuery
    - onDeletedContributionsLineEnding
  Run both from ContributionsPager instead, when in archive
  mode, similar to their normal-mode counterpart hooks.
* Add a basic test to ensure that Special:DeletedContributions
  doesn't encounter an error while building the pager.
* SpecialDeletedContributions will be updated in a separate
  patch.

Bug: T370438
Change-Id: Ifa266898781449a1ebd99bcf3e72182899c2452d
2024-08-06 11:56:32 +01:00
Thalia
33cef31331 ContributionsPager: Re-work comment to be more generic
Don't refer to Special:Contributions in a debug log and HTML
comment, since that is only one subclass of ContributionsPager.

This is needed ahead of work to make DeletedContribsPager extend
ContributionsPager.

Bug: T370438
Change-Id: Ifbc15998861b4a3ab5e47f620d139618d7b674b8
2024-08-01 18:15:33 +01:00
Thalia
c6bc185226 ContributionsPager: Fix date link in archive mode
Why:

* ContributionsPager::formatRow creates the same date link for
  normal and archive mode. This links to the revision, which is
  deleted when in archive mode.
* Instead, it should do what DeletedContribsPager does, and link
  to Special:Undelete.

What:

* Handle the date links the same in ContributionsPager (archive
  mode) as in DeletedContribsPager.
* Also rename the variable $lang to $language for clarity.

Bug: T371518
Change-Id: Ied2282d06e7c2be0735203c132c605e3d7f40857
2024-08-01 18:15:26 +01:00
Thalia
7f40a85966 Don't show 'latest' field in archive mode on contributions search form
Why:

* ContributionsSpecialPage builds a search form for filtering
  contributions. Subclasses can show different types of contributions,
  from the revision or the archive table.
* When searching the archive table, the filter for showing only
  contributions that are the latest version of a page don't make any
  sense, since the page gets deleted when the revisions are moved to
  the archive table. Therefore it should be removed in archive mode.

What:
* Add isArchive method to ContributionsSpecialPage for subclasses to
  define whether they search the revision or archive table. Default
  to true, to avoid needing to update SpecialContributions.
* Only add the filter for showng latest page revisions if not in
  archive mode.

Bug: T371495
Change-Id: If1c5772ec4693300e770e34faae9197fe6138fe4
2024-07-31 18:59:15 +01:00
Umherirrender
02256a060c pager: Simplify namespace condition from pagers
Use expression builder to use IN() or NOT IN() when the associated
namespace is also part of the condition.

old: (rc_namespace != 0 AND rc_namespace != 1)
new: (rc_namespace NOT IN (0,1))

Change-Id: I8bec03812607d61894594081c1be9e6f69f478d7
2024-07-17 23:15:34 +02:00
Thalia
2246951178 Allow ContributionsPager to show revisions from the archive table
Why:

* ContributionsPager is an abstract class that can be extended to
  show contributions lists from different sources. For example the
  CheckUser extension displays contributions based on lookups in
  the CheckUser tables.
* A contribution is modelled as a RevisionRecord object,
  corresponding to a row in the `revision` table.
* RevisionRecord objects can also correspond to rows in the
  `archive` table, where deleted revisions are stored; however,
  ContributionsPager doesn't recognize these.
* By allowing ContributionsPager to handle revisions from the
  `archive` table, we allow any subclasses to choose revision or
  archive mode.
* Although out of scope here, DeletedContribsPager could later be
  replaced with ContributionsPager in `archive` mode, allowing
  better feature parity between SpecialContributions and
  SpecialDeletedContributions, e.g. T36524, T36523.

What:

* Add isArchive property that subclasses can set, to control
  whether revisions are fetched from `revision` or `archive`.
* Add relevant links to each row (history, diff, undelete, etc.)
  depending on whether the revisions are existing or archived.
* Only run hooks when in `revision` mode, because handlers assume
  certain field names are present.
* Make the selected field names configurable so that a subclass
  can override them. Default to the field names used for a
  `revision` table lookup. (Note that an extension might want to
  specify its own table, so make these completely configurable,
  rather than just allowing fields from either the `revision` or
  the `archive` table.)

Bug: T366510
Change-Id: Ie48b728d98a74022aa11c2135ee871bfda1f2a9f
2024-06-13 16:10:32 +01:00
Ebrahim Byagowi
14b4269d83 Add namespace and deprecation alias to Xml and XmlSelect
This patch introduces a new namespace declaration,
MediaWiki\Xml and adds Xml and XmlSelect to it
and establishes class aliases marked as deprecated
since version 1.43.

Bug: T353458
Change-Id: I45cccd540b6e15f267d3ab588a064fbeb719d921
2024-05-16 15:23:14 +03:30
Thalia
5362096f27 Revert "Revert "Add ContributionsPager, an abstract parent for ContribsPager""
This reverts commit e6fb3df2a6.

This re-instates I08a5d39036047484e3b44fcd83989072006b88e2.

Bug: T363358
Change-Id: I847c60a493d9973554ceb1232f3799c42321ee2b
2024-05-13 15:38:34 +01:00
jenkins-bot
04787125e8 Merge "Revert "Add ContributionsPager, an abstract parent for ContribsPager"" 2024-05-09 19:39:16 +00:00
DannyS712
e6fb3df2a6 Revert "Add ContributionsPager, an abstract parent for ContribsPager"
This reverts commit e1ffed0af6.

Reason for revert: breaking change, caused T364569

Bug: T364569
Bug: T363358
Change-Id: I08a5d39036047484e3b44fcd83989072006b88e2
2024-05-09 17:28:32 +00:00
jenkins-bot
47987acdfd Merge "Add ContributionsPager, an abstract parent for ContribsPager" 2024-05-09 13:13:38 +00:00
Thalia
e1ffed0af6 Add ContributionsPager, an abstract parent for ContribsPager
Why:
* For the temporary accounts project, we will make some changes to
  how user contributions can be viewed, including showing global
  contributions (T337089) and showing contributions from temporary
  accounts using the same IP (T358852).
* We will create new pagers that re-use logic from ContribsPager.
  These will behave similarly to ContribsPager, but will get the
  revisions using a different query.

What:
* Make ContribsPager extend a new abstract parent class,
  ContributionsPager.
* ContributionsPager:
  - handles filtering on edit type (minor, etc), namespace, tag,
    date and user permissions (e.g. hiding suppressed revisions)
  - runs the hooks that ContribsPager used to run, and keeps the
    same names for backwards compatability
  - handles displaying results
  - provides an abstract method getRevisionQuery for a subclass
    to specify where the revision comes from. (Examples are
    the `revision` table or the `cu_changes` table, but in the
    future this could also include archive.)
* ContribsPager:
  - handles an IP range target by using the ip_changes table
  - includes some public static functions that are kept for
    backwards compatability. (Future work could put them somewhere
    more appropriate.)

Scope:
* ContributionsPager is designed to select (existing) revisions.
  It could be abstracted out further to handle deleted revisions
  from the archive table, to help bring feature parity to
  Special:DeletedContributions. This is left out of scope for this
  patch.
* To keep the scope limited and the commit history clean, this
  patch doesn't attempt to fix the various TODOs in ContribsPager,
  or update old styles that are used.

Bug: T363358
Change-Id: I85bb28c9d85426ecc82c533a0cdd3f010c247b02
2024-05-09 05:22:37 -07:00
Umherirrender
9bca88cde6 pager: Use SelectQueryBuilder::rawTables in IndexPager
UsersPager defines a "join group", which is not supported by
SelectQueryBuilder::tables

Bug: T364428
Follow-Up: I6490caae3984efaae81bd2583220a7dd1c3b371d
Change-Id: I27e4de5d2d114fd8b0bfb86ca28278e16108c959
2024-05-07 22:15:09 +02:00
Umherirrender
33dd935478 Migrate to IReadableDatabase::newSelectQueryBuilder
This cases cannot benefit from the SelectQueryBuilder as each argument
get processed by hooks with fix signature or coming from abstract
functions providing the arguments separate.

Bug: T344971
Change-Id: I6490caae3984efaae81bd2583220a7dd1c3b371d
2024-05-05 17:29:51 +02:00
James D. Forrester
a06bf12c86 Drop TablePager::getBody(), deprecated since 1.24
Change-Id: Id7ee6a55938723dc426ca54c7c37d50415f819da
2024-05-02 21:36:12 +03:00
James D. Forrester
8e940c4f21 Standardise all our class alias deprecation comments for ease of grepping
Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
2024-03-19 20:11:29 +00:00
C. Scott Ananian
72c4945a72 [ParserOutput] Rename $mText to $mRawText and ::setText() to ::setRawText()
ParserOutput::getText() is not a simple getter, but does
transformations on the "text" of the ParserOutput; the simple getter
is named ::getRawText().

To maintain consistency, rename ParserOutput::setText() to
::setRawText() and the property name ParserOutput::$mText to
::$mRawText so future readers are not confused.

The JSON property name as it appears in the serialized ParserCache
is left as 'Text' so that we don't have any forward- or backward-
rollback issues.

Change-Id: I3ef34814ab9473cc70d0a6806e8c5a4a02b73491
2024-02-20 17:13:28 +00:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
Bartosz Dziewoński
e4c7272976 Change uses of getDBLoadBalancerFactory() to getConnectionProvider()
Update cases where one of the IConnectionProvider methods is called
immediately.

This doesn't really change anything, but I hope it helps promote
getConnectionProvider() as the common way to do this.

Follow-up to 8604c384f6.

Change-Id: Id0e7d02bab0c570343c2b1f03c70b44ee39db112
2024-01-22 22:27:45 +01:00
Dogu
137d046c12 Replace all the OOUI qualifiers with imports
List of affected classes:
- TablePager
- DefaultPreferencesFactory
- SignatureValidator
- SearchFormWidget
- SpecialUndelete

Change-Id: I63ba23108adb16ee4f8b0f965b05605c70ff7957
2024-01-07 21:17:57 +00:00
James D. Forrester
9bfb75ff90 Namespace ParserOutput
Most used non-namespaced class!

Bug: T353458
Change-Id: I4c2cbb0a808b3881a4d6ca489eee5d8c8ebf26cf
2023-12-14 14:57:34 -05:00
Bartosz Dziewoński
978d739bc6 Replace single-value $db->buildComparison() with $db->expr()
Find:
->buildComparison\( ('..?'), \[(\s*)([^\],]+) => ([^\],]+)(\s*)\] \)

Replace with:
->expr($2$3, $1, $4$5)

Change-Id: I2cfc3070c2a08fc3888ad48a995f7d79198cc336
2023-10-22 01:05:47 +02:00
Amir Sarabadani
e207a13230 Switch to ICP in some easy cases
Bug: T330641
Change-Id: I84454d0e42a0faef1b17a79d2ba3cc96db8782ca
2023-09-26 21:05:16 +02:00
James D. Forrester
3aeb9d681c Namespace core Pagers under \MediaWiki\Pager
Bug: T166010
Change-Id: Ibe12d1754709d48f71edd4cde1f13a542344a21e
2023-09-18 12:27:56 +01:00
Amir Sarabadani
5bd33d46ef Reorg: Move WebRequest to includes\Request
This has been approved as part of RFC T166010

Bug: T321882
Change-Id: I6bbdbbe6ea48cc1f50bc568bb8780fc7c5361a6f
2023-09-11 21:44:34 +01:00
jenkins-bot
f193b40e7a Merge "TablePager: Hard-deprecate getBody(), deprecated in 1.24" 2023-08-23 22:30:16 +00:00
James D. Forrester
e25d7bdbcf TablePager: Hard-deprecate getBody(), deprecated in 1.24
Change-Id: I1a4e706f1c364e5ac41aea3b29bfe08d79911411
2023-08-23 17:46:33 -04:00