Commit graph

1618 commits

Author SHA1 Message Date
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
jenkins-bot a51132998c Merge "Fix notifications when new comment is under subheading" 2021-07-28 16:59:10 +00:00
jenkins-bot 405497594b Merge "Add PHPUnit integration tests for EventDispatcher" 2021-07-28 16:59:07 +00:00
jenkins-bot e9ff4695ad Merge "Change updating page content after saving to avoid losing footers" 2021-07-28 16:59:05 +00:00
Translation updater bot 3ccfa56d8f Localisation updates from https://translatewiki.net.
Change-Id: I07a3e6d2260ee25a08d0d5433e1a726a15624194
2021-07-26 08:12:04 +02:00
Bartosz Dziewoński d0e4aeaecb Fix notifications when new comment is under subheading
The user interface only allows you to subscribe to level 2 headings.
But we would generate events for whatever heading was the closest,
If it was e.g. level 3, no one would receive that notification.

Now we generate events for the closest level 2 heading, or we don't
generate the event at all if there isn't one (if the only headings are
of level 3 and below, or level 1, or if the comment is added before
the first heading on the page).

Bug: T286736
Change-Id: Iae99853070e353ab81c9cc29ef1d53c877adfc66
2021-07-24 05:28:10 +02:00
Bartosz Dziewoński 801b57b0f4 Add PHPUnit integration tests for EventDispatcher
Bug: T286608
Change-Id: I711483be80d455f4439e96d37844ee4552619a92
2021-07-24 05:28:04 +02:00
Bartosz Dziewoński 4ebf05d802 Recognize links to add a new topic that use Special:NewSection
Bug: T277371
Change-Id: I40a13d8bf87bcd3ecea1427b444b6b7b621213c4
2021-07-22 22:25:11 +02:00
Bartosz Dziewoński 4e8e1bda67 Change updating page content after saving to avoid losing footers
This is the same method as used by VisualEditor
(ve.init.mw.DesktopArticleTarget.prototype.replacePageContent).

Bug: T275698
Change-Id: Idcf7c79b8d5565b0ae36c6e9d42b66662c1acc8d
2021-07-22 21:43:10 +02:00
libraryupgrader b0884b177c build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0

npm:
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* glob-parent: 5.1.1 → 5.1.2
  * https://npmjs.com/advisories/1751 (CVE-2020-28469)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: I7a71e23da561599da417db3b3077b78d91173bbc
2021-07-22 16:29:04 +00:00
Translation updater bot aa19431689 Localisation updates from https://translatewiki.net.
Change-Id: Id49ff976340c4fddfb19be18a6500a88c72b2548
2021-07-22 08:13:08 +02:00
Bartosz Dziewoński 709a7e5c4a Do not teardown newtopictool interface if it was not setup
Bug: T287035
Change-Id: Ib7c6c564ff197e0c8c8cf79680513f9415d108f9
2021-07-20 22:32:25 +02:00
Translation updater bot fb066eda46 Localisation updates from https://translatewiki.net.
Change-Id: I2db2ddf62a091255ae019d35ea3e42b98e4ea7e6
2021-07-20 08:20:29 +02:00
Translation updater bot 6e9e08bb31 Localisation updates from https://translatewiki.net.
Change-Id: I9096cce0f728a4ba1434987d85aeae0bc908e5d2
2021-07-19 08:15:37 +02:00
Translation updater bot c83f98c972 Localisation updates from https://translatewiki.net.
Change-Id: I579cfcac4c6b1320701fbe0cb890050658cb7bc0
2021-07-15 08:12:10 +02:00
Translation updater bot f9dd078ded Localisation updates from https://translatewiki.net.
Change-Id: If319cf5a434ecc8ca6c1d69305650fb95991108f
2021-07-14 08:02:47 +02:00
jenkins-bot 52ffc8ce98 Merge "Remove comment highlight after user clicks anywhere on the page" 2021-07-13 17:26:39 +00:00
jenkins-bot 64f40718e2 Merge "Avoid exception when trying to highlight hidden comment" 2021-07-13 17:26:37 +00:00
jenkins-bot 062416771f Merge "Only show [subscribe] links on sections that contain at least one comment" 2021-07-13 16:25:31 +00:00
Translation updater bot 31e3e1f8a7 Localisation updates from https://translatewiki.net.
Change-Id: Id228cf0a64adefd1557dc8266ad333743127a7df
2021-07-13 08:11:37 +02:00
Bartosz Dziewoński b3a2941575 Remove comment highlight after user clicks anywhere on the page
Bug: T285430
Change-Id: I32fc04a440c807211c5e4f121e58757466ee55bf
2021-07-13 02:38:40 +02:00
Bartosz Dziewoński 4ebe4b29bb Only show [subscribe] links on sections that contain at least one comment
Bug: T285796
Change-Id: I48264d55464fa6bce56b47fc1075f5d348101676
2021-07-13 02:35:15 +02:00
Bartosz Dziewoński 650c7dd1d3 Avoid exception when trying to highlight hidden comment
(e.g. if the comment is inside a node with 'display: none')

Change-Id: I23a38fd877b1f9f1554962f7f08f7e2732d8f560
2021-07-13 00:00:30 +02:00
Translation updater bot ad0b879473 Localisation updates from https://translatewiki.net.
Change-Id: I9ae758b23834e6bef292b6e394b80e8a9264233d
2021-07-12 08:06:22 +02:00
Translation updater bot b8384190f1 Localisation updates from https://translatewiki.net.
Change-Id: I335fe805673a261c6bfe240fb3f0a45f0e453db7
2021-07-06 08:38:23 +02:00
Translation updater bot df4653f4df Localisation updates from https://translatewiki.net.
Change-Id: Id0db12580df7053bc6fd873388382a16e55c6e6b
2021-07-05 08:06:47 +02:00
Translation updater bot ac06fb4d6f Localisation updates from https://translatewiki.net.
Change-Id: I1d90959d9809e2c5194cc99f7e647447ef0f16e0
2021-07-02 08:31:06 +02:00
jenkins-bot 164e1328b9 Merge "Take over extra links to add a new topic added by gadgets/templates" 2021-07-01 17:21:16 +00:00