aboutsummaryrefslogtreecommitdiffstats
path: root/includes/diff/DifferenceEngine.php
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2023-07-14 11:35:08 +1000
committerTim Starling <tstarling@wikimedia.org>2023-07-25 10:49:51 +1000
commit2b608a35ede101dbfe4c1195bd8776475fee722f (patch)
tree814f7d6c7562c905235f708e5aec10804d4f9fe0 /includes/diff/DifferenceEngine.php
parentb81e02c18d78c3e35e3b417830d7f859975b6a94 (diff)
downloadmediawikicore-2b608a35ede101dbfe4c1195bd8776475fee722f.tar.gz
mediawikicore-2b608a35ede101dbfe4c1195bd8776475fee722f.zip
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
Diffstat (limited to 'includes/diff/DifferenceEngine.php')
-rw-r--r--includes/diff/DifferenceEngine.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php
index 0d895063f861..102efcd9bc5f 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -220,6 +220,11 @@ class DifferenceEngine extends ContextSource {
*/
private $slotDiffOptions = [];
+ /**
+ * Extra query parameters to be appended to diff page links
+ */
+ private $extraQueryParams = [];
+
/** @var ManifoldTextDiffer|null */
private $textDiffer;
@@ -708,7 +713,7 @@ class DifferenceEngine extends ContextSource {
$rollback = '';
- $query = $this->slotDiffOptions;
+ $query = $this->extraQueryParams;
# Carry over 'diffonly' param via navigation links
if ( $diffOnly != MediaWikiServices::getInstance()
->getUserOptionsLookup()->getBoolOption( $user, 'diffonly' )
@@ -1509,6 +1514,17 @@ class DifferenceEngine extends ContextSource {
}
/**
+ * Set query parameters to append to diff page links
+ *
+ * @since 1.41
+ *
+ * @param array $params
+ */
+ public function setExtraQueryParams( $params ) {
+ $this->extraQueryParams = $params;
+ }
+
+ /**
* Generate a diff, no caching.
*
* @since 1.21