Commit graph

1745 commits

Author SHA1 Message Date
Bartosz Dziewoński a129899971 Remove unnecessary contentType: 'multipart/form-data' from an API query
This was copied from somewhere else (probably VisualEditor), but it is
not needed here.

Using the multipart/form-data encoding is beneficial when sending long
binary data (such as the compressed HTML VisualEditor sends), and is
also required when uploading files, but it is not helpful when sending
a short query like we do here.

Also rename a variable.

Change-Id: I9bcce2ce1ca7c218e4cd147960d1070dd23ea9fa
2021-08-16 21:33:59 +02:00
Bartosz Dziewoński ad04b24ffd Create a hidden revision tag for talk page comments
Bug: T262107
Depends-On: I21159d03eebaf46ad94f4273ba698a59b8019185
Change-Id: Iceddfaf6a4bcc5e8b5c85c8cd5638bf14aa7db03
2021-08-16 15:42:51 +00:00
Bartosz Dziewoński 47510a22f3 EventDispatcher: Fix ignoring level 3+ headings
The code (prior to d25825a754) assumed
that level 3+ headings would always follow a level 2 heading or the
placeholder heading, but we don't generate a placeholder heading if
there are no comments in section zero.

Add more tests to confirm that comments under level 3+ headings (that
are not sub-headings of level 2), and level 1 headings, are ignored
when generating notifications, and do not mess with normal headings.

Bug: T288775
Change-Id: Ic57b56752a4797cb01234f66e0ed7b849752bd70
2021-08-16 15:42:06 +00:00
Translation updater bot 4c103576e8 Localisation updates from https://translatewiki.net.
Change-Id: If470919a929b62537e563a33a3c88f70f429766f
2021-08-16 08:16:13 +02:00
Translation updater bot 98da78306a Localisation updates from https://translatewiki.net.
Change-Id: I2ecddb22f0abb9deb46e2d46c043894743a99d0f
2021-08-13 08:18:37 +02:00
Bartosz Dziewoński d25825a754 EventDispatcher: Remove failing invariant check
To be investigated in the future.

Bug: T288775
Change-Id: Ic27418a0ec976347be5fa586bbd32cc4a0d8d511
2021-08-12 22:37:51 +02:00
Translation updater bot 98f79545d6 Localisation updates from https://translatewiki.net.
Change-Id: I2d7c1927d1d917302951b26410f69665b5845e84
2021-08-12 08:09:30 +02:00
David Lynch 642fede864 Apply design tweaks to empty states
Bug: T274831
Bug: T274832
Bug: T277329
Change-Id: I0dcdb3479ba668b78cf247856a8ec00d5ea37ab4
2021-08-11 14:33:43 -05:00
libraryupgrader 912e9d874a build: Updating path-parse to 1.0.7
* https://npmjs.com/advisories/1773 (CVE-2021-23343)

Change-Id: Ia4f226e1704eaed9d482546e5e4826c43f5b939f
2021-08-11 17:38:12 +00:00
Translation updater bot f436692239 Localisation updates from https://translatewiki.net.
Change-Id: I9a5ea45cbe009337cd4725ac62ec5ac4b12e16fc
2021-08-11 08:19:13 +02:00
vladshapik 613b0a9b27 Avoid using deprecated ParserOptions::getUser
Bug: T287858
Change-Id: I13ef6ef128a8316f699c6e038adf82d18bf81b96
2021-08-10 16:43:11 +03:00
Translation updater bot 5cf1cee1e4 Localisation updates from https://translatewiki.net.
Change-Id: I6da7968f52ff25ff9d23f7c22f29d6190c3f2a49
2021-08-10 08:06:31 +02:00
DannyS712 88ba997bed Injected SubscriptionStore into UnsubscribeAction
Dependency injection is now available to actions,
extension already requires MW 1.37+

Bug: T253078
Change-Id: I473abac19ed5e6f3c6706797e91704ff635f64c6
2021-08-09 22:38:52 +00:00
Bartosz Dziewoński b46893eb7d Remove pointless uses of preserveWhiteSpace property
This DOMDocument property has no effect, because we do not use
DOMDocument methods for parsing HTML, but rather DOMUtils::parseHTML()
provided by Parsoid.

Change-Id: I1d9e73e53f2d44f41cf9dcda4f06ac8647671096
2021-08-09 23:45:48 +02:00
Translation updater bot a9abb268bb Localisation updates from https://translatewiki.net.
Change-Id: I55fa8bb02f396b304938a9a4da79b09de43f7d88
2021-08-09 08:23:53 +02:00
jenkins-bot dfa2646604 Merge "Only show the empty state on talk namespaces" 2021-08-07 16:19:16 +00:00
David Lynch 93f2e64f3f Only show the empty state on talk namespaces
This should only affect some edge cases like the project namespace (e.g.
Wikipedia:Village_pump isn't a talk page, but does get discussiontools.)

Bug: T288317
Change-Id: I509101063a1d64d09cff71a84bf48c69ab7a8c08
2021-08-06 16:04:23 -05:00
David Lynch 0cb756f248 Don't detach the reply widget when posting to an empty page
This will avoid a flash of the empty-state while we're reloading the
page to get new tabs.

Refactor out the new topic controller's clear behavior from its teardown
behavior, so we can still wipe out the storage when redirecting.

Bug: T288314
Bug: T288320
Change-Id: I6a5313b5e5b3bc9925e5cdaea04d8fbd3dc796af
2021-08-06 15:18:17 -05:00
Bartosz Dziewoński 076242e3b4 Revert "Silence JQMIGRATE warnings when running tests"
This reverts commit f075e37303.

No longer needed after Iaf786cd0f1d870cbcf0b968b7adce616c82df3d8
in MediaWiki core, and now causes exceptions because
UNSAFE_restoreLegacyHtmlPrefilter is undefined.

Bug: T280944
Change-Id: I0dbd6fcb5dce939de334815e9fe371425cf5641f
2021-08-06 18:19:42 +00:00
Translation updater bot 3150c533a6 Localisation updates from https://translatewiki.net.
Change-Id: Ib5325a1e137a46b011f52067d4c563958b67354a
2021-08-06 08:13:28 +02:00
jenkins-bot 10c23d0eb1 Merge "Deal with document body consistently" 2021-08-06 03:08:28 +00:00
jenkins-bot 02c09106ab Merge "Remove use of DOMXPath to remove Phan suppressions" 2021-08-06 03:05:13 +00:00
jenkins-bot 125cb495e2 Merge "ImmutableRange: Remove Phan suppression" 2021-08-06 02:47:07 +00:00
Bartosz Dziewoński 7fcaae95b7 When opening new topic tool using any link, always activate the link in page tabs too
Bug: T288267
Bug: T277371
Change-Id: I1854c82853abf16d9552765df983b4490fcd4b30
2021-08-05 19:09:05 +00:00
jenkins-bot 2fa030aafc Merge "Apply an empty-state to pages with the new topic tool enabled" 2021-08-05 16:52:49 +00:00
Translation updater bot b3ae9c3695 Localisation updates from https://translatewiki.net.
Change-Id: I7c172be4f0bab67b3ae473e3baef82083efb49fa
2021-08-05 08:22:01 +02:00
jenkins-bot 4aa139899e Merge "Change 'sourcemodetoolbar' default to enabled (when available)" 2021-08-05 00:01:14 +00:00
David Lynch 91af0594b5 Apply an empty-state to pages with the new topic tool enabled
This includes the dtrepliedto URL functionality from
I3f81e4d77faed367606e47678b8896051982359d.

Bug: T274831
Bug: T274832
Bug: T277329
Change-Id: I035d04f30c8312b0cb42902d3bf940df1482ffb3
2021-08-04 18:46:28 -05:00
Bartosz Dziewoński 9016f652ff Change 'sourcemodetoolbar' default to enabled (when available)
Bug: T287927
Change-Id: I4c55efee787ab624ecfb499c36e52f5f01f18a5c
2021-08-04 19:32:32 +02:00
David Lynch b492d3d635 Update preferences language for source mode toolbar
Also, fix some copy-paste errors in the topic subscription qqq text.

Bug: T287315
Change-Id: I153467e6c02fb938825692204a02a6c327c941cb
2021-08-04 12:24:23 -05:00
Translation updater bot 93f7afac5d Localisation updates from https://translatewiki.net.
Change-Id: I53b86456b2e52e914cd8309d343224860f3035f4
2021-08-04 08:14:47 +02:00
jenkins-bot 56f4dbbf86 Merge "Test cases for interactions with events generated by base Echo" 2021-08-03 23:18:46 +00:00
jenkins-bot d14f31fd08 Merge "Improve notifications for comments posted in close succession" 2021-08-03 23:17:55 +00:00
jenkins-bot 352a4d0555 Merge "Test cases for comments posted in close succession" 2021-08-03 20:44:02 +00:00
jenkins-bot d4f4e49c7e Merge "Allow the new topic tool to handle URLs like action=edit&section=new" 2021-08-03 16:14:21 +00:00
Bartosz Dziewoński 8de8d80cde Deal with document body consistently
Use `DOMCompat::getBody( ... )` as a nicer getter than
`->getElementsByTagName( 'body' )->item( 0 )`.

Remove overly defensive checks and redundant annotations on its
return value. Since we're dealing with HTML documents throughout,
the document body is guaranteed to exist.

We previously needed some of them to convince Phan when it thought
the body may be null, but this seems to no longer be needed.

Change-Id: If7aee7b6adbfa78269c7ba28b26a6eaa21fe935b
2021-08-03 15:12:55 +02:00
jenkins-bot 1f4706a308 Merge "Recognize links to add a new topic that use Special:NewSection" 2021-08-02 17:42:30 +00:00
Bartosz Dziewoński 7a9fd40eb9 Remove use of DOMXPath to remove Phan suppressions
Use DOMCompat::querySelectorAll() instead.

CommentModifier::isHtmlSigned()
* Copied the CSS selector from the JS equivalent function.
CommentUtils::unwrapParsoidSections()
* Copied the CSS selector from the JS equivalent function (in VisualEditor).
CommentItem::getMentions()
* Trivial.

This causes Phan to report some more issues, which are also fixed.

Follow-up to 25272e7a4a.

Change-Id: Iaf1222f7114916f2eca19942c3686168899486fd
2021-08-02 18:23:16 +02:00
Bartosz Dziewoński 8b73612585 ImmutableRange: Remove Phan suppression
We can just use insertBefore() normally. There was never a PHP bug,
but rather a Phan bug, and it no longer affects us.
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/596813/70/includes/ImmutableRange.php#373

This reveals a bug in CommentParser where it sometimes produces
incorrect ranges (we were incorrectly treating `false` like `null`,
hiding the issue). I'll fix it in a separate commit.

Follow-up to 25272e7a4a.

Change-Id: I4afba38f1d82ddbf8732bfe3e4d4f6ebe2f8de5d
2021-08-02 17:51:26 +02:00
Translation updater bot cd889f8aa2 Localisation updates from https://translatewiki.net.
Change-Id: I73d78e0341cb64330617f36c962bad1d45e5a3f3
2021-08-02 08:36:39 +02:00
Bartosz Dziewoński 80704b6e80 Test cases for interactions with events generated by base Echo
Adding test cases in a separate commit to make it easier to review how
the test results change after I98fbca8e.

* For mentions, the 'mentioned-users' extra parameter is copied to our
  event (which is then used to avoid duplicate notifications).
* For user talk page edit, nothing special happens right now (we use
  the target page title to avoid duplicate notifications, but this is
  not apparent from the test case, since page titles are not present).

Bug: T281590
Bug: T253082
Change-Id: I153e7735f63f1e2643ed881281d807313cd699c3
2021-08-01 12:27:33 +02:00
Bartosz Dziewoński a5099739a6 Improve notifications for comments posted in close succession
In case 4 and case 6, no notifications are expected. In all other
cases we now get the expected notifications.

Bug: T285528
Change-Id: I9e813bb3a053bc1232783f9eae1ad75672b4fa7e
2021-08-01 12:27:33 +02:00
Bartosz Dziewoński 78cb03c471 Test cases for comments posted in close succession
Adding test cases in a separate commit to make it easier to review how
the test results change.

As expected, in every case, no notifications are generated right now.

Bug: T285528
Change-Id: I25308754112c521d2db8c54ef0c82373456d9e31
2021-08-01 12:27:33 +02:00
jenkins-bot a728a5d942 Merge "Don't refer directly to PHP dom extension classes; avoid nonstandard behavior" 2021-08-01 10:09:54 +00:00
jenkins-bot 09a79060c6 Merge "Use DOMCompat::newDocument() to create a new Document" 2021-08-01 09:31:36 +00:00
C. Scott Ananian 25272e7a4a Don't refer directly to PHP dom extension classes; avoid nonstandard behavior
These changes ensure that DiscussionTools is independent of DOM
library choice, and will not break if/when Parsoid switches to an
alternate (more standards-compliant) DOM library.

We run `phan` against the Dodo standards-compliant DOM library,
so this ends up flagging uses of non-standard PHP extensions to
the DOM.  These will be suppressed for now with a "Nonstandard DOM"
comment that can be grepped for, since they will eventually
will need to be rewritten or worked around.

Most frequent issues:

* Node::nodeValue and Node::textContent and Element::getAttribute()
can return null in a spec-compliant implementation.  Add `?? ''` to
make spec-compliant results consistent w/ what PHP returns.

* DOMXPath doesn't accept anything except DOMDocument.  These uses
should be replaced with DOMCompat::querySelectorAll() or similar
(which end up using DOMXPath under the covers for DOMDocument any way,
but are implemented more efficiently in a spec-compliant
implementation).

* A couple of times we have code like:
  `while ($node->firstChild!==null) { $node = $node->firstChild; }`
and phan's analysis isn't strong enough to determine that $node is still
non-null after the while.  This same issue should appear with DOMDocument
but phan doesn't complain for some reason.

One apparently legit issue:

* Node::insertBefore() is once called in a funny way which leans on
the fact that the second option is optional in PHP.  This seems to be
a workaround for an ancient PHP bug, and can probably be safely
removed.

Bug: T287611
Bug: T217867
Change-Id: I3c4f41c3819770f85d68157c9f690d650b7266a3
2021-07-30 18:15:40 -04:00
C. Scott Ananian 5203d30ea6 Use DOMCompat::newDocument() to create a new Document
For compatibility with Parsoid's document abstraction (Parsoid may
switch to an alternate DOM library in the future), don't explicitly
create a new document object using `new DOMDocument`; instead use
the Parsoid wrapper `DOMCompat::newDocument()`.  This ensures that
the Document object created will be compatible with Parsoid.

There are a number of other subtle dependencies on the PHP `dom`
extension in DiscussionTools, like explicit `instanceof` tests; those
will be tweaked in a follow-up patch
(I3c4f41c3819770f85d68157c9f690d650b7266a3) since they do not affect
correctness so long as Parsoid is aliasing Document to a subclass of
the built-in DOMDocument.  Similarly, the Phan warnings we suppress
do not cause runtime errors (because of the fixes included in
c5265341afd9efde6b54ba56dc009aab88eff83c) but phan will be happier
once the follow-up patch lands and aligns all the DOM types.

Bug: T287611
Depends-On: If0671255779571a91d3472a9d90d0f2d69dd1f7d
Change-Id: Ib98bd5b76de7a0d32a29840d1ce04379c72ef486
2021-07-30 18:15:11 -04:00
Bartosz Dziewoński cfbf437d9d Allow the new topic tool to handle URLs like action=edit&section=new
Depends-On: Ib9302e2fda7dadf1edc43c0107db7234eb4bdf7a
Depends-On: Ic7dd677ea219938969f60bab91387c2e03ebdbe6
Bug: T282204
Change-Id: I2e7b2682da7beb3c1c469bb784a9a8ec3998aeb9
2021-07-30 09:25:21 +02:00
Translation updater bot 09d872e0a5 Localisation updates from https://translatewiki.net.
Change-Id: I91b8e0cb320ef8376b13eb0cd78f9844950bae8e
2021-07-30 08:27:37 +02:00
Translation updater bot 69f86f7555 Localisation updates from https://translatewiki.net.
Change-Id: Iea7d53db93514a37b93c1986cdc70b9ba9fc1608
2021-07-29 08:44:52 +02:00