Commit graph

762 commits

Author SHA1 Message Date
jenkins-bot
53a7614975 Merge "DifferenceEngine: Add user meta information on diff pages" 2023-10-17 18:02:14 +00:00
MusikAnimal
d3903b9c2a TextSlotDiffRenderer: show tooltip instead of help icon on inline switch
Also add to the switch itself, not just the label

Bug: T346429
Change-Id: Ia7319a63878e029765c08a44f890fe96205c35da
2023-10-17 12:31:49 -04:00
Jon Robson
32dd2fb2b5 DifferenceEngine: Add user meta information on diff pages
This will be used to consolidate the mobile and desktop diff
pages. This useful information could also be incorporated into
desktop skins at a future date.

Bug: T347779
Change-Id: If1f6f75ea829e8754fc51c7c15a2f47ad16dba52
2023-10-17 15:48:54 +00:00
thiemowmde
0a453b6c37 Remove meaningless /** #@- */ comments
Some of these comments are more than 20 years old. Almost all of them
are copy pasted from somewhere else, most certainly without knowing
what they mean. I can only guess that they have been part of some
ancient code folding feature that's not supported any more. Even if,
almost all of them are misplaced by now because the surrounding code
changed without updating the comments.

Change-Id: I53c37f050574a530ec772b7a07b67d84b31bb7a0
2023-10-15 12:30:28 +02:00
hmonroy
aae15dca22 diff: add help message to inline switch
Add help message that explains what the inline toggle does when you click
it.

Remove 'diff-table-format-label` text since it is not being used.

Bug: T346429
Change-Id: Idc3aefffd03d491a573b27c7e18b337f68bbc9cf
2023-10-13 12:09:40 -07:00
jenkins-bot
5dd2ee1e3b Merge "DifferenceEngine: Separate previous/next from diff itself" 2023-10-11 02:12:32 +00:00
Jon Robson
4bbfde052a DifferenceEngine: Separate previous/next from diff itself
Having these controls in the diff makes it very difficult to
adapt the diff page for mobile screens. It is proposed we add
links at the top of the diff page, that are initially hidden.

These will initially be used in Minerva skin and possibly
upstreamed at a later date for all skins.

Change:
* Add previous / next breadcrumbs at top of diff page

Bug: T347780
Change-Id: Iae6c140cde54d807204e6d2b8c7b6599f75df89e
2023-10-10 22:00:46 +00:00
jenkins-bot
f7049ef7ff Merge "DifferenceEngine: Comments on diff page should be themeable" 2023-10-10 18:56:41 +00:00
jenkins-bot
4af120071a Merge "DifferenceEngine: Make timestamps data readable" 2023-10-10 18:46:09 +00:00
MusikAnimal
02e7fdb26a diffs: add line number headings to inline diffs
Adds new regex in BaseTextDiffer::localizeLineNumbers() to work with
wikidiff2 inline diffs as well as table diffs.

Since there are no "columns" in inline mode, we have a new message to
indicate how the line numbers changed from the old diff versus the new.

Deprecate DifferenceEngine::localiseLineNumbers() as no longer used and
redundant to BaseTextDiffer::localizeLineNumbers().

Bug: T346460
Change-Id: I7b195879b677e2242ad73070fe19ad82121576a8
2023-10-09 22:53:14 -04:00
Jon Robson
0b2ccb89cd DifferenceEngine: Comments on diff page should be themeable
Remove hardcoded parentheses in favor of CSS pseudo elements to
support different display in different skins.

There should be no visual change in any skin with this change.

Bug: T117279
Change-Id: Iaea122647893acfa405d413e851e14949fb4b8d3
2023-10-04 18:16:58 +00:00
Jon Robson
7f554fc748 DifferenceEngine: Make timestamps data readable
The Minerva skin renders a relative timestamp.
Having this data attribute available will allow the Minerva
skin to render a relative timestamp on this page.

Bug: T117279
Change-Id: Ib66de95bdeca6e9bfa082889f0ed0740dbf8639f
2023-10-04 11:12:37 -07:00
jenkins-bot
5d693f3ff0 Merge "DifferenceEngine: Distinguish between table and inline diffs" 2023-09-29 23:18:23 +00:00
Jon Robson
e832b8f190 DifferenceEngine: Distinguish between table and inline diffs
Having a different class on the diff allows different styling
in the different contexts.

Bug: T117279
Change-Id: I32fc945dac113453351c07bd75fbf2835e616ce2
2023-09-29 22:37:45 +00:00
Maryum Styles
3cc1781815 SECURITY: DifferenceEngine: hide diff-multi-sameuser message for supressed revisions
CVE-2023-PENDING

reduce the edit count if a user for a given revision is suppress-deleted

Bug: T341529
Change-Id: I79539464cf3500065cb4f42e1542ff5feec31395
2023-09-29 00:32:14 +01:00
Daimona Eaytoy
95d75e831a Add first batch of taint-check annotations
These are the same as taint-check's MediaWikiSecurityCheckPlugin.php.

The notable exception is methods in WebRequest that were previously
hardcoded as returning a safe value. This was a consequence of said
methods return safe types (e.g., int, bool). Instead of adding
taint-check annotations, add return typehints instead, which let
taint-check remove any taintedness.

Fix some taint-check issues that were previously not spotted or whose
suppressions were removed in other patches.

Also fix the following bugs spotted by phan thanks to the type hints:
- SpecialExport did not have explicit handling of null $depth, and just
  returned 0 because null fails both the < and the > comparisons.
- Improve documentation of params and props in ProtectedPagesPager.
  SpecialProtectedPages can pass null $namespace and $size.
- Remove unused parameter from SpecialProtectedPages::showOptions, of
  which $ns and $size were not documented as nullable.
- Add FIXMEs in SpecialVersion about very inconsistent escaping.

Bug: T321806
Change-Id: I726f528856614c92329683a0ad8936a42e262748
2023-09-23 17:51:06 +02:00
James D. Forrester
1d0b7ae1e2 Namespace User under \MediaWiki\User
Bug: T166010
Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
2023-09-19 19:18:16 +00:00
jenkins-bot
85addf1312 Merge "Use OutputPage::setPageTitleMsg() instead of ::setPageTitle()" 2023-09-19 18:42:52 +00:00
James D. Forrester
459cbb0494 Namespace remaining 'specialpage' files under \MediaWiki\SpecialPage
SpecialPageFactory is already here, but none of the others were yet.

Bug: T166010
Change-Id: I9689bf0a1ab329625e23669b99f019b96295fffd
2023-09-18 18:23:13 +01:00
C. Scott Ananian
111d9177af Use OutputPage::setPageTitleMsg() instead of ::setPageTitle()
Passing a Message argument to OutputPage::setPageTitle() is
deprecated, because the message is not properly HTML-escaped by
default.  Use ::setPageTitleMsg() instead wherever the message doesn't
include HTML metacharacters.

Also protect arguments with Message::plaintextParams() where
appropriate.

Bug: T343994
Bug: T343849
Change-Id: Iba67d008545249772c136c5d6d302110516d3b94
2023-09-18 11:52:36 -04:00
Bartosz Dziewoński
d45f68b1a9 Infuse the inline diff toggle's layout to fix accessibility
Infusing just the toggle widget, without the layout wrapping it,
causes them to get disconnected, which breaks some accessibility
features, including lack of "aria-labelledby" and no support for
activating the toggle by clicking on its label.

Bug: T346132
Change-Id: I227f47d4e6c25e19b4c02a16c287fc481efc2bf4
2023-09-16 01:14:30 +02:00
Bartosz Dziewoński
8769e265b4 DifferenceEngine: Use real type hints for services etc.
Change-Id: I1d47da6595ccf9d22abbcced4363c3092fc10a94
2023-09-07 21:16:00 +00:00
TheresNoTime
b20ea3a54f DiffToggleSwitch: remove temporary inline switch flag
Remove `$wgShowDiffToggleSwitch`, ensure the inline switcher
is always shown.

Bug: T341630
Change-Id: I37d1abe0d9773654df24dd8316cd1b351e3b91a4
2023-09-06 20:13:00 +00:00
jenkins-bot
bbfa65643f Merge "ArchivedRevisionLookup: Allow lookups using just the revision ID" 2023-09-06 18:43:32 +00:00
Amir Sarabadani
d8e542abf9 Reorg: Move three output related classes to includes/Output/
And namesapce them:
 - StreamFile
 - OutputHandler
 - OutputPage

Bug: T321882
Change-Id: Iedf8d88c595e580f2d8f0734c92aa5c45618ba33
2023-09-05 19:36:42 +01:00
Bartosz Dziewoński
2911de600f ArchivedRevisionLookup: Allow lookups using just the revision ID
A unique index on ar_rev_id was added in T193180 (2019), allowing
revisions of deleted pages to be reliably looked up by just their ID.

Use the improved getArchivedRevisionRecord() method in a few places
that previously had to use manual queries.

Bug: T251066
Change-Id: I9352f64952ac4b803d76e9e72f88a01be7317c56
2023-09-02 01:56:20 +00:00
hmonroy
13ffa17b71 DiffToggleSwitch: use PHP ToggleSwitchWidget
Add logic that renders the new OOUI/ToggleSwitchWidget (just added to
OOUI) in PHP for the inline switch. This will provide no-JS support, and will get rid of the flash when loading the page for JS users.

Bug: T341955
Change-Id: Ifc8104937cd23e9b85208b7f283db238a0e6849d
2023-09-01 15:49:15 -07:00
Amir Sarabadani
f4e68e055f Reorg: Move Status to MediaWiki\Status\
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.

Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
2023-08-25 15:44:17 +02:00
Tim Starling
7887b66ade Include $wgWikidiff2Options in the diff cache key
Bug: T341754
Change-Id: I3b7d71f811d7ebd0cf83273164c479762e1a680b
2023-08-23 10:00:47 +10:00
Amir Sarabadani
c57cdf4276 Migrate last batch of simple Database::select* calls to SQB
Done semi-automatically via a parser written on top of ANTLR4

Bug: T311866
Change-Id: Ib71d6810e480d7176726082347b569e346557de7
2023-08-01 20:38:13 +02:00
jenkins-bot
1d5e4f3d0a Merge "Add support for wikidiff2_multi_format_diff()" 2023-07-31 11:54:12 +00:00
Tim Starling
8d69f99a1a Don't show the inline toggle selector on Special:MobileDiff
Have Article opt in to inline toggle switch display, so that random
callers of DifferenceEngine::showDiffPage() do not receive a
non-functional format selector.

Bug: T342158
Change-Id: Id4e38c2a20b5381e5f70b1244304da2895eaf8e7
2023-07-26 05:16:55 +00:00
Tim Starling
2b608a35ed Add an API-only user preference for diff type
* Add an API-only user preference for diff type
* Retain query parameter stickiness but fix it so that the diff-type
  from user preferences does not leak into the query string. So the
  no-JS control continues to work. If a no-JS user has the inline
  preference set, respect it on the initial load, but add an explicit
  diff-type=table to the query string of the table link so that the
  preference can be overridden.
* Get the diff type from the initial state of the no-JS button. Infuse
  the widget to access the active property using the OOUI public API.
* For a logged-in user, when the JS toggle is clicked, fetch the new
  diff body and update the user preference.
* For an anonymous user, when the JS toggle is clicked, update the
  prev/next links to include the correct diff-type query parameter.

Bug: T336713
Change-Id: Ie409d79ac8222dfa6ec8fd170b76be088be80b3a
2023-07-25 10:49:51 +10:00
Tim Starling
4014f56d73 Add SlotDiffRenderer::localizeDiff()
It makes sense for SlotDiffRenderer to localize the diffs that it
returns.

DifferenceEngine can't conveniently use this right now since it stores
all slot diffs concatenated together in a cache entry. It can't break
the string apart again to call the right SlotDiffRenderer on each
slot diff. So it assumes there must be a text diff in there somewhere
and calls TextDiffer over the whole thing.

EntitySchema does not have this problem and can benefit from this
method.

Bug: T342209
Change-Id: Ie06e100bb0e945de5dbe3dade14b2e6b706e078d
2023-07-20 10:09:42 +10:00
Lucas Werkmeister
1a3f15cd43 Restore DifferenceEngine::localiseLineNumbers()
Since it’s needed by EntitySchema, and because it was also, as far as I
can tell, removed without following the stable interface policy in
change I5c506e3916 (commit 2aa87cdf2c).

Not marked as soft-deprecated because there doesn’t seem to be a way to
access the replacement.

Bug: T342209
Change-Id: Iba9fd8bb56ea0e1543c9a9beab85b01f9549fbd7
2023-07-19 12:26:43 +02:00
Tim Starling
2ed4e600b4 Add support for wikidiff2_multi_format_diff()
Bug: T341754
Change-Id: I17396985d0b26516a06df17e9bd1343054521e01
2023-07-19 12:38:18 +10:00
Tim Starling
191ec35340 Add unified format
The code is there, so we may as well expose it.

Change-Id: Ic4cf5c0d4a5b46f0f0f25454815dcea1f69970eb
2023-07-19 12:38:18 +10:00
Tim Starling
2aa87cdf2c Factor out TextDiffer hierarchy from TextSlotDiffRenderer
* Follow the TODO comment in TextSlotDiffRenderer
  ::getTextDiffInternal() by moving the code out to three parallel
  implementations, namely ExternalTextDiffer, PhpTextDiffer and
  Wikidiff2TextDiffer.
* Add a container/factory class ManifoldTextDiffer to glue them
  together and collate available formats.
* Move the inline legend to Wikidiff2TextDiffer. Not the toggle since
  the ability to toggle depends on the available format, not the current
  format.
* Update the diff cache keys so that ManifoldTextDiffer can store the
  engine=>format map it used to generate the diff.
* Drop support for the second parameter to TextSlotDiffRenderer
 ::setEngine(), since nothing used it anymore.
* Provide a format batch API, since some engines are able to efficiently
  generate multiple formats. This might be used by DifferenceEngine in
  future.

Needs risky change notification for the cache key change.

Bug: T339184
Depends-On: I8a35b9b8ec1622c9a36d2496bdd24f51bc52c85f
Change-Id: I5c506e39162855aff53dd420dd8145156739059c
2023-07-19 12:38:18 +10:00
Tim Starling
cbeceb1ae3 Slot diff option "contentLanguage" should be a string
Quick fix for production error.

Bug: T342099
Bug: T341961
Change-Id: Ifab76ab7018ee1498851223e1181b527d506efbb
2023-07-18 21:56:11 +10:00
Tim Starling
6790bf9910 Remove $wgLang usage from Title
StubUserLang was meant to avoid the cost of looking up the user
preferences on requests which don't need it. There's no point in using
it if you are going to unconditionally call a method on the resulting
object.

StubUserLang proxies to RequestContext::getLanguage() via __call(),
which has a cost. Originally this cost was avoided on subsequent calls
by overwriting $wgLang, but this mechanism is not effective if you retain
a reference to the StubUserLang.

Removing the potential for Title::getPageLanguage() to return
StubUserLang simplifies the type declarations for methods that call it.

Bug: T160814
Change-Id: I12ad75c2496ca727580aac55e860178d15febb6e
2023-07-11 11:15:02 +10:00
jenkins-bot
77f2208a22 Merge "Fix Chinese diff segmentation" 2023-07-07 05:07:18 +00:00
jenkins-bot
e7373e24e3 Merge "Inject page language into TextSlotDiffRenderer" 2023-07-07 01:37:43 +00:00
jenkins-bot
2b68525941 Merge "Add DifferenceEngine::getDefaultLanguage()" 2023-07-06 09:31:09 +00:00
Tim Starling
5d26080d62 Fix Chinese diff segmentation
segmentForDiff() is supposed to allow character-level diffing of Chinese
text, by adding spaces and then removing them after the diff is
complete. But when I tested it for I2d0a6996b02d37a3, unsegmentForDiff()
failed to remove the spaces, since there was an <ins> tag between the space
and the Chinese character.

So instead, use formfeed characters to separate the Chinese characters,
and strip them unconditionally instead of relying on them being next to
Chinese characters.

Add test.

Change-Id: I230d8261bbda34ad313785a1f7c31d4db7bf989b
2023-07-06 18:14:30 +10:00
Tim Starling
36b92d45db Inject page language into TextSlotDiffRenderer
Fix fixme by sending the language code to SlotDiffRenderer as an option.

Note that this is the language used for word segmentation of the
content, not the UI language.

Change-Id: I2d0a6996b02d37a3f2d8fefa851244803025bb6c
2023-07-06 10:35:03 +10:00
jenkins-bot
f74a79dc4f Merge "Migrate several wfGetDB() to use ICP" 2023-07-05 10:50:57 +00:00
Amir Sarabadani
3e157496ff Migrate several wfGetDB() to use ICP
And doing proper dependency injection.

Bug: T330641
Change-Id: I4978c158e513f88f5547343c4fbbe4b39078dc09
2023-07-05 11:00:59 +02:00
jenkins-bot
77e2974aa8 Merge "Optimise DifferenceEngine::addLocalisedTitleTooltips()" 2023-07-05 05:21:40 +00:00
Tim Starling
4fd2b0dfd5 Add DifferenceEngine::getDefaultLanguage()
So that Wikibase can stop accessing the protected property mDiffLang.

Change-Id: I1fc6dd8b6187682659a1689708405ddb81e22acd
2023-07-05 10:48:42 +10:00
Tim Starling
f1d1092f73 Optimise DifferenceEngine::addLocalisedTitleTooltips()
* Remove unnecessary regex
* Move message expansion outside the loop

Change-Id: I44c273f1d798c436687be1a43b3aa94be0a8fdcc
2023-07-03 18:44:31 +10:00