Commit graph

427 commits

Author SHA1 Message Date
Bartosz Dziewoński 695a966a41 Remove unused non-parser-cache mode
Change-Id: Ief9f4153898b09a1ce15ccfdc8656dfad4642269
2021-10-07 17:59:10 +02:00
Bartosz Dziewoński dbb8b00ec7 Remove parser cache splitting ('dtreply' option)
Bug: T280599
Change-Id: I08b52874d575619308b5b83a39acfb6353c5b7b5
2021-10-07 17:59:10 +02:00
Bartosz Dziewoński e3af0bc65b Replace marker comment with limit report data
We always do our processing in the parser now, so we don't need the
marker comment to detect whether we've already processed the page.

Bonus: include the time taken by our processing in the limit report.

Bug: T291831
Change-Id: Ife7ddffbad1b1495b004739212002a98fdebe6c0
2021-10-07 17:59:10 +02:00
Bartosz Dziewoński a0dc12ab56 Add Special:TopicSubscriptions
Bug: T273342
Change-Id: If96a0df1efbf5cadfb6bf2bf8f7ad5c9c90ea142
2021-10-06 20:06:01 +00:00
Bartosz Dziewoński c1f4668806 Change CommentParser and ImmutableRange to use offsets in codepoints instead of bytes
The PHP DOM extension measures lengths and offsets in Unicode codepoints.
Our PHP code used UTF-8 bytes, causing some offsets to be slightly off.
Now it mostly uses Unicode codepoints as well (we're forced to use bytes
in a few places, because preg_match returns offsets in bytes).

In practice, this had no visible effect to the user. It caused the
markers `<span data-mw-comment-end="..."></span>` to be placed at
the end of their container instead of the correct position when the
timestamp contained multibyte characters (e.g. "ź" in Polish); but
the correct position is usually at the end of the container anyway.

In the test cases, the only difference is placing these markers before
a trailing line break inside `<p>...</p>` tags rather than before it.

The patch also accidentally fixes another bug, where element nodes
with no children (mostly <img>) were incorrectly excluded when calling
cloneContents(), because they were treated as if they were text nodes.

Change-Id: Iccdccf1078598f4b62cab96225e9c85a4c0e93ee
2021-09-27 19:04:16 +00:00
Alexander Vorwerk b73f4b1a70 Replace usage of deprecated PageProps::getInstance()
Bug: T289544
Change-Id: Ib4d86c298508b3dc56c44a4fa7314218f8a0d930
2021-09-26 00:48:51 +00:00
jenkins-bot abd6c2fedd Merge "Enhance Echo user talk edit and mention notifications" 2021-09-24 02:17:57 +00:00
jenkins-bot 15747aba3a Merge "CommentParser: Remove outdated legacy ID algorithm" 2021-09-21 16:50:37 +00:00
jenkins-bot d25975209f Merge "Deduplicate logic for subscribable headings" 2021-09-21 16:50:29 +00:00
jenkins-bot 02a214d928 Merge "Put all checks for enabling the empty state for talk pages in one place" 2021-09-21 15:43:11 +00:00
Bartosz Dziewoński 4a824abd0d Apply page transformations only when viewing pages
Follow-up to e634701460. We didn't need
this previously, because we relied on the ArticleParserOptions hook
only being called when viewing pages.

Context from code reviews a year ago:
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/641837/comment/15ee0218_e4ab602f/
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/641837/comment/b62d4327_5ebc2e02/

Bug: T291459
Bug: T291460
Change-Id: I64f0be170719d874f5460934462917f4f13af6c1
2021-09-21 10:19:42 +02:00
jenkins-bot c50b1630d1 Merge "Add API to get the status of topic subscriptions on a page" 2021-09-21 04:43:03 +00:00
Bartosz Dziewoński ca17555a67 Put all checks for enabling the empty state for talk pages in one place
They were spread across several places, and some of them were checking
different things, causing us to show the view mode on some
action=edit&redlink=1 links but without showing our empty state.

Bug: T291085
Change-Id: Id1864e58c47dbd22abb41d48e31f81318d9f94f9
2021-09-20 23:15:00 +02:00
jenkins-bot 152a663fb6 Merge "Always apply DiscussionTools page transformations" 2021-09-20 17:30:43 +00:00
Bartosz Dziewoński 435b0c65c7 Enhance Echo user talk edit and mention notifications
If the user talk edit or mention coincides with exactly one new comment:
* Change the primary link to be a direct link to the comment
* Add a text snippet to notifications that don't already include one
  (user talk edits that are not new sections).

This is done for all such notifications, regardless of whether anyone
has topic subscriptions enabled.

Bug: T281590
Bug: T253082
Change-Id: I98fbca8e57845cd7c82ad533c393db953e4e5643
2021-09-20 15:05:42 +02:00
David Lynch 46b6d76433 Enable email delivery for our notifications for new users by default
We're using the same approach as Echo is for its new-users-only settings

Bug: T287547
Change-Id: I1d8fff364da919caaf86af94cf5f0c6e40b67ff9
2021-09-15 23:54:30 -05:00
Alexander Vorwerk 97a702cbc7 CommentParser: use IPUtils instead of the deprecated IP class
Bug: T291008
Change-Id: I0207940a642a32f2ca997b78387c9ff0af101599
2021-09-14 22:19:05 +02:00
libraryupgrader 26b69d2c70 build: Updating composer dependencies
* mediawiki/mediawiki-phan-config: 0.10.6 → 0.11.0
* php-parallel-lint/php-parallel-lint: 1.3.0 → 1.3.1

Change-Id: I76996ed939d706739d2094077c64eeca6f51126a
2021-09-08 23:14:53 +00:00
Bartosz Dziewoński e634701460 Always apply DiscussionTools page transformations
Bug: T273072
Bug: T280599
Change-Id: I0b39ef2f9ede15905951a54c043dd228bd5ace9f
2021-09-08 00:16:30 +02:00
Bartosz Dziewoński 0ae97ef550 Deduplicate logic for subscribable headings
Change-Id: I1cd96cf0bcce2101455702f1350d8a4336c60790
2021-09-07 21:38:35 +00:00
Bartosz Dziewoński 8bb36bd782 Add API to get the status of topic subscriptions on a page
(Split off from Ic0fabda0de4ebbc5e424f49641e6b03ebb4b7e6a)

Bug: T290185
Change-Id: Iacc0f92bedfcb49e8a05d98af4d8170d08b1c8de
2021-09-07 21:38:09 +00:00
Bartosz Dziewoński ce899aaadd Inject services in hook handlers where possible
Change-Id: Ie5c36cabd90412d2299b00d2b0c3c3bdf9ffc6d6
2021-09-07 22:51:35 +02:00
Bartosz Dziewoński c70a203111 Inject ConfigFactory in API modules
…plus minor tweaks.

Change-Id: I80ded8bac836f4a49d61c51c4d17b48687628986
2021-09-07 18:36:12 +02:00
Bartosz Dziewoński 9819df3288 CommentParser: Remove outdated legacy ID algorithm
Last changed in March (4a0802065c),
was only needed for about 2 weeks for compatibility with cached data.

Change-Id: I510238cb86a7b4d7ae5e8636716d1e9ca2d0e402
2021-09-07 17:41:30 +02:00
Bartosz Dziewoński 23d2255111 HookUtils: Remove unused variable
Change-Id: I3f8aec349a5845b3ea4d08d3257937467497f2a2
2021-09-03 19:13:34 +00:00
Bartosz Dziewoński 317c608eda ThreadItem: Remove redundant check
CommentItem::getAuthor() used to return null in the past.

Change-Id: I66f4e83b51b6efef7441d4b963f6db09571d9393
2021-09-03 19:13:21 +00:00
Bartosz Dziewoński 9273611a08 Remove unused 'use' definitions
I guess that at some point this class was meant to convert some
timestamps, but it does not (it returns them as strings in the
database format).

Change-Id: I33ee5e8807ee686b77819ef16f43509326c60762
2021-08-31 22:03:51 +02:00
jenkins-bot c68d0aeec1 Merge "Empty states for anon/IP user talk pages" 2021-08-26 20:20:20 +00:00
David Lynch 21600231d9 Empty states for anon/IP user talk pages
Bug: T287779
Bug: T288556
Change-Id: I9d01d1ac04c0cc443c4cbfe94d301db16f5b1ef6
2021-08-26 22:11:13 +02:00
Bartosz Dziewoński 4bbbdc9703 EventDispatcher: Try really, really hard to read from master
Follow-up to 37d6825c14.

Bug: T289717
Depends-On: I2a614915c7d9ffbc4f466204b2684478fb52f30e
Change-Id: Id2e040a19e457a2a8f4121b04ebd43bf6ea64181
2021-08-25 21:38:10 +02:00
jenkins-bot b1eb884966 Merge "Improve discussiontoolssubscribe API documentation" 2021-08-24 02:42:17 +00:00
jenkins-bot 5d9d28b280 Merge "ApiDiscussionToolsSubscribe: Remove redundant checks" 2021-08-24 02:41:26 +00:00
Bartosz Dziewoński 6dd90eda4a Improve discussiontoolssubscribe API documentation
Bug: T280314
Change-Id: I0987faac2cd8c5276a37869212fa968f0d642c09
2021-08-23 18:40:00 +00:00
Bartosz Dziewoński bb5054435f ApiDiscussionToolsSubscribe: Remove redundant checks
$user is guaranteed to be a User object.

Also, while we're here:
* Remove an unnecessary TODO. There's no need for a more specific
  error message, this one is just fine, other extensions use it too.
* Replace isAnon() with !isRegistered(). It'll probably be deprecated
  soon, because the new UserIdentity interface doesn't include it.

Change-Id: Ifbe98f4eccef79deee6bdb54c1bccf49807a9563
2021-08-23 20:39:18 +02:00
Bartosz Dziewoński 3e19fce67a Load styles in ParserOutput too
We load them in OutputPage, because we need that to handle the
query parameter 'dtenable=1', but do it here as well just in case
the pages are somehow shown without involving OutputPage.

Per code review:
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/713681/1/includes/Hooks/ParserHooks.php#90

Change-Id: I3f287a9e146de7fd4d37c47dfa47eeb03eeb8cf1
2021-08-20 18:49:04 +02:00
jenkins-bot ccd2769b17 Merge "Remove remnants of the cookie hack for loading unavailable tools" 2021-08-19 16:32:10 +00:00
jenkins-bot 52ff6ef77e Merge "HookUtils: Simplify check for your own talk page" 2021-08-19 16:32:07 +00:00
jenkins-bot e2ef5764da Merge "Minor cleanups in topic subscription code" 2021-08-19 16:32:04 +00:00
Bartosz Dziewoński c8fa10770a Remove remnants of the cookie hack for loading unavailable tools
Follow-up to ee524d6bd6.

Change-Id: I1b4dc587e6b629b05ca0581dcd384a2bc7f01d2a
2021-08-18 20:45:02 +02:00
Bartosz Dziewoński 75d63bb056 Remove repetition in "Discussion pages" preferences
Bug: T289187
Change-Id: Id6c90546e4b57754e13b55f7c61610b51de87966
2021-08-18 20:20:34 +02:00
Bartosz Dziewoński 4aca61990a HookUtils: Simplify check for your own talk page
This approach is used in our new topic tool empty state code and is
much nicer. Also fix typo in a comment nearby.

Change-Id: I80755ef0960a172b0f370c36c1979a86498d6fa9
2021-08-17 22:22:15 +02:00
Bartosz Dziewoński bcd92a5d33 Minor cleanups in topic subscription code
For automatic topic subscriptions, I plan to introduce a third
subscription state to indicate them. This patch includes minor tweaks
I wanted to add while working on that:

* Introduce constants instead of numbers
* Remove a TODO that doesn't seem like a good idea any more
* Remove a `"length": 1` on sub_state that did not do anything
  (but it might have been meant to indicate that it was supposed
  to be a boolean, which would be wrong)

Bug: T284836
Change-Id: I6e6096968ad38510102287bccd349090b6ca4280
2021-08-17 22:22:15 +02:00
jenkins-bot 781992de2d Merge "Create a hidden revision tag for talk page comments" 2021-08-17 02:07:10 +00:00
jenkins-bot e090c455cc Merge "EventDispatcher: Fix ignoring level 3+ headings" 2021-08-16 22:08:42 +00:00
jenkins-bot 2cd97c4be5 Merge "Handle highlighting and scrolling to comments for bundled notifications" 2021-08-16 20:43:37 +00:00
Bartosz Dziewoński db28a3d3a7 Handle highlighting and scrolling to comments for bundled notifications
Notifications are bundled by section, so instead of linking to the
comment, link to the section.

Additionally, add a parameter to the URL listing all the comment IDs
from the bundle, and highlight them all and scroll to the topmost one.

Having to handle both URL fragments and URL query parameters makes
this code kind of a mess :(

Also, some unexpected changes became necessary:

* EventDispatcher.php: Store the section title in events using
  HeadingItem::getLinkableTitle() instead of ThreadItem::getText().
  The result is mostly the same, except in case of wacky markup like
  images or extension tags. We can more reliably use it to link to the
  section on the page, and we already use getLinkableTitle() when
  generating edit summaries in the reply tool for this reason.

* dt.init.less: Change the mix-blend-mode for the highlights from
  'multiply' to 'darken', so that multiple overlapping highlights do
  not look more opaque. This affects how the highlights look on
  non-white backgrounds and images (they're less blue, and on darker
  backgrounds entirely invisible), but it seems worth it.

Bug: T286620
Change-Id: I21bb5c003abc2747f0350d3f3af558dfb55693e9
2021-08-16 22:03:30 +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
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
vladshapik 613b0a9b27 Avoid using deprecated ParserOptions::getUser
Bug: T287858
Change-Id: I13ef6ef128a8316f699c6e038adf82d18bf81b96
2021-08-10 16:43:11 +03:00