Commit graph

255 commits

Author SHA1 Message Date
Thalia ec8048131d Replace uses of UserNameUtils::isTemp with UserIdentityUtils::isTemp
Where a UserIdentity is available, use UserIdentityUtils, which has
fewer dependencies.

Change-Id: I035bfbc7801f4ac77a8c6f0991f0fdf71b8fb429
2023-07-26 11:32:27 +01:00
Bartosz Dziewoński aa239a1ad1 Suppress the empty state in previews again
It wasn't appearing in normal previews thanks to some redundant checks
elsewhere, but it was appearing in our own internal previews using
ApiDiscussionToolsTrait::previewMessage(). It wasn't causing any
problems until change Iac3778a4a88a4def234be9d10b80d9796d35bceb, which
detects headings in the preview, and it was detecting the empty state
heading.

Follow-up to commits 8fb467896f and
ab40ef62c0, where I replaced a HTML
comment with ParserOutput extension data to indicate this, and then
accidentally removed the cleanup code from removeInteractiveTools()
with no replacement.

Change-Id: I4b650f82c711d65e200758e981ce338202deeaa6
2023-06-22 10:31:29 +02:00
Bartosz Dziewoński b405fd9b40 Make topic subscriptions unavailable to temp users
Bug: T332432
Change-Id: Icf91f0900ef3435cf3e9eedcf983e61ad9aeea69
2023-06-13 01:05:55 +02:00
jenkins-bot b6ebb59c5f Merge "EchoHooks: Use symbols instead of string class names" 2023-06-09 20:59:21 +00:00
Ed Sanders 531ced9e31 EchoHooks: Use symbols instead of string class names
Change-Id: I3a4bba84d939f23653b719a271cecaa9395f0cd0
2023-06-09 22:33:27 +02:00
thiemowmde 0cf68818a8 Add various, more specific type hints
* Add @var comments to untyped getService() calls so IDEs and tools
  are able to understand where the callers are.
* Use the more specific IReadableDatabase where possible.
* Fix missing import.

Change-Id: I9c1153cb9fe872227753628a947f40bd5ee447fa
2023-06-09 13:44:42 +02:00
jenkins-bot f9580e6817 Merge "Use namespaced Echo classes" 2023-06-08 13:25:14 +00:00
Siddharth VP 03fcb20810 Use namespaced Echo classes
Change-Id: Id1673cb6ec0ae5f9177db28414d46d216fcabb45
2023-06-08 13:46:31 +05:30
Ed Sanders 0672f4c74a Remove DiscussionToolsEnableMobile
This existed to do a staged rollout to WMF wikis.

Bug: T322497
Change-Id: I4562c166f3f07bce972f9d599de211147d2dc631
2023-06-06 13:25:21 +01:00
Ed Sanders 99f132f05e Remove most DiscussionTools feature configs
Only visual enhancements are yet to be made available everywhere.

Bug: T322497
Change-Id: Ia8a7673f23d1ee31bb7e53d8e75f982d1e48d1ec
2023-06-06 13:25:19 +01:00
Ed Sanders 3b4673bfad Drop the DiscussionToolsEnable feature flag
This existed to do a staged rollout to WMF wikis, which was
finished in March 2021 (T276497).

Bug: T322497
Change-Id: I8851f0243e6920d93f3eb1870d1604bf201ed5a4
2023-06-06 13:08:35 +01:00
Ed Sanders dda86f8ebf Always use the strict equality flag when using in_array
Change-Id: Ia09f5aadc3bbf64645ba174f047e53db49e07925
2023-06-06 13:08:00 +01:00
jenkins-bot a1d0e3a9d3 Merge "Create HookRunner class and the hook handler interface" 2023-06-05 22:12:23 +00:00
Umherirrender 378769a974 Create HookRunner class and the hook handler interface
Bug: T273303
Change-Id: I6d00848f07fc7d17f3dc7f44b7b6b61553219558
2023-06-04 20:12:56 +02:00
Bartosz Dziewoński e65b49ec43 Don't try to set preferences for temporary accounts
Bug: T337784
Change-Id: I34d35673e5d2651e1da10ba0e7946a0bd54312ea
2023-06-02 20:11:52 +02:00
Bartosz Dziewoński fda08f7b54 Remove the new topic tool hint
This temporary message has been shown for long enough.

This mostly reverts:
* d0eec56f6d
* f24a73a05a
* bd40523843

Bug: T322495
Change-Id: Ic1762e170547fba8b5fda225eff21e515ace512d
2023-05-24 20:15:49 +02:00
thiemowmde 8bbbf39bbd Make use of named MainConfigNames::… constants
Also merge setMwGlobals() calls because they are really expensive.

Also utilize the more readable str_contains() and related.

Change-Id: Iebde6aa17c2e366f0c0a98fe13a454f6a06c299b
2023-05-19 12:12:32 +02:00
jenkins-bot 25b3366070 Merge "Add talk page empty state for temporary accounts' user talk pages" 2023-05-16 17:51:54 +00:00
Bartosz Dziewoński e3441be186 Add talk page empty state for temporary accounts' user talk pages
Depends-On: I2ea656a8a1704a495f1a94fede1a8829ba7325a1
Bug: T335590
Change-Id: Ibe1ea316f5da450b4478bf466ec12bbca9a91cd2
2023-05-16 17:00:03 +00:00
David Lynch 71d2e76d7f Update a/b test code for visual enhancements a/b test
Strip it out from applying to logged out users and make the test work
for multiple features

Bug: T333715
Change-Id: Id15a8a99c2ea8e6fc14fc83baf2ed6ebaaf754c8
2023-05-08 01:30:21 -05:00
Bartosz Dziewoński 0d21df43dc Allow maintenance script to work even when DiscussionToolsEnablePermalinksBackend is off
Bug: T334258
Change-Id: I40e09b2f8561eeac1744bbbc48e3973e519bd9ea
2023-04-14 19:36:18 +02:00
Bartosz Dziewoński 316e741868 Support topic subscriptions when JavaScript is disabled
Unsubscribing was already available from Special:TopicSubscriptions
when JavaScript is disabled.

* Add links to subscribe/unsubscribe in CommentFormatter
* Update links in skin navigation
* Add support for subscribing in the actions

Bug: T321431
Change-Id: If3c4bf7df309d0d98237c3b7b9c129cc2f72cda3
2023-04-10 21:30:19 +02:00
Bartosz Dziewoński 6a7d949703 Remove integration with removed MobileFrontend talk page tools
* Remove the hook we used to disable that feature
* Remove CSS that only applied when it was enabled
* Update code comments that referred to it

Bug: T319145
Change-Id: If21a04f6a087289d8249a786f7c991e5e12c9bed
2023-04-04 17:17:49 +02:00
Ed Sanders 92f5cfd821 Support suppressing comment detection in pages or sections
This can be done within sections using CSS:
* mw-notalk

Or at a page level using a magic word:
* __NOTALK__

"notalk" suppresses all comment detection, treating the content as
not containing any comments even if there are signatures present.

Bug: T295553
Bug: T249293
Change-Id: Ic1d7294bafcf7071e16838e70684ecadd7bc6fd3
2023-04-03 18:36:34 +02:00
Ed Sanders 856b90fa3e Support hiding reply links in archived pages or sections
This can be done within sections using CSS:
* mw-archivedtalk

Or at a page level using a magic word:
* __ARCHIVEDTALK__

"archivedtalk" still detects the comments, but disables features
as appropriate for an archived conversion, i.e. the reply tool.

Bug: T295553
Bug: T249293
Change-Id: Ic47693e9a2f53f92563ccdd50203fb55c12d0493
2023-04-03 18:34:57 +02:00
jenkins-bot 9e51f11b8c Merge "Add new topics subscription button in Minerva" 2023-03-27 23:04:55 +00:00
Ed Sanders e6a255215f Add new topics subscription button in Minerva
Bug: T332730
Change-Id: Ib6915319eeae4aa32c875decd51e7fd8db4dbd16
2023-03-27 23:28:38 +01:00
jenkins-bot d08871fdae Merge "Centralize EditAttemptStep logging code in WikimediaEvents" 2023-03-27 15:30:43 +00:00
jenkins-bot 7106233d59 Merge "Only show the mobile add topic button on view pages" 2023-03-24 00:37:12 +00:00
David Lynch 0cf9c41b18 Only show the mobile add topic button on view pages
Bug: T332897
Change-Id: Id63c391a286356d9007f9a7a0b6eec75747ee6c3
2023-03-23 10:19:10 -05:00
Ed Sanders 80dd6e2d7c Add new topic subscription button to page actions
Bug: T263821
Change-Id: Iab7f7d5fd1f7c229c2e0cda9369676cfd401a24e
2023-03-20 14:51:10 +00:00
Ed Sanders 2bae1864bd New topic notifications
Bug: T263821
Change-Id: Ied465e732122a1ee39ab4510f73aca11ef556c35
2023-03-20 14:41:53 +00:00
Ed Sanders 4367595bfd EventDispatcher: Generate dt-added-topic events
Change-Id: I98b67e016995866558274809743fa21ed23ee063
2023-03-20 14:41:21 +00:00
Bartosz Dziewoński dcecf76ff1 Centralize EditAttemptStep logging code in WikimediaEvents
PHP logging code is not moved.

* Use the new mw.track() handlers from WikimediaEvents
* Ensure that 'integration' and 'editor_interface' are set on init
  events, since they're not hard-coded in the handler any more
* Remove the setting of 'editingStatsId' tracking parameter,
  now happens in WikimediaEvents (by way of VE ArticleTargetSaver)
* Remove code connecting ve.track to mw.track, now happens in VE

This must be merged together with WikimediaEvents change
Iace4d53a972396ca5b8713000570cc47c9986034 (but we can't use
Depends-On, because CI requires code here to be removed first).

Bug: T332438
Change-Id: I0ef0a96aafdf89a4ebe32131a85b18c25744bb2c
2023-03-18 13:26:10 +00:00
jenkins-bot 2185ac1ca3 Merge "Allow visualenhancements on pages with __NEWSECTIONLINK__" 2023-03-15 20:24:19 +00:00
jenkins-bot 49d3d44ce3 Merge "Use setExtensionData() instead of marker comments where possible (2/3)" 2023-03-15 15:49:38 +00:00
Ed Sanders 12e8d1a17d Allow visualenhancements on pages with __NEWSECTIONLINK__
Exclude the main namespace unless it allows signatures.

Allow this feature to be disabled via config so
we can do a slow rollout.

Bug: T331635
Change-Id: If46bff5620c5245d5b82653ee96282532fd00c28
2023-03-13 15:32:23 +00:00
jenkins-bot 663170fb2d Merge "Support '&preload=...' etc. in new topic tool when '&dtpreload=1' is set" 2023-03-08 20:55:32 +00:00
jenkins-bot 45fe4c3bec Merge "Disable on LiquidThreads pages" 2023-02-24 00:11:35 +00:00
Bartosz Dziewoński 5af3e90fec Support '&preload=...' etc. in new topic tool when '&dtpreload=1' is set
To avoid affecting existing preload forms, the new topic tool is only
used when the 'dtpreload' query parameter is also set.

Bug: T269310
Change-Id: I4ee024cc4760542790319f302f42b1b2389ac897
2023-02-15 16:39:38 +01:00
Bartosz Dziewoński e6681772da Avoid unneeded queries in isAvailableForTitle()
Don't check the 'newsectionlink' property if we don't need it.

Also improve comments.

Change-Id: I50a84ba5e21ffd22859e770329522babf6e729c8
2023-02-14 16:53:48 +00:00
Bartosz Dziewoński 445b8caca0 persistRevisionThreadItems: Avoid listing non-discussion pages
Bug: T329627
Change-Id: I52a9f5dfa583d8dc2e0a315844a2a40e538f6a8c
2023-02-14 17:53:27 +01:00
Bartosz Dziewoński 93f8d338c8 Disable on LiquidThreads pages
Bug: T329423
Change-Id: Id8995e4d35083b740806499c545d1b308a9a1722
2023-02-14 00:50:07 +01:00
Bartosz Dziewoński 5d3d3cf687 Use setExtensionData() instead of marker comments where possible (2/3)
We started using marker comments (HTML comments with special content
inserted into the page) for the reply buttons back in the day, because
we needed to indicate their location in the HTML. Later we used the
same idea for things which aren't actually tied to a specific location
in the HTML, such as boolean data like __DTEMPTYTALKPAGE__. There is a
better way to do this.

This commit starts reading from ParserOutput::getExtensionData(),
which was generated by the previous commit, and should be present
in all cached ParserOutput objects by the time we merge this.

Bug: T328980
Change-Id: I9f7a907836b86f25567fd4b352464d62d76e20e4
(cherry picked from commit 0ac420ecbc)
2023-02-11 21:16:03 -06:00
DLynch fb08abe062 Revert "Use setExtensionData() instead of marker comments where possible (2/3)"
This reverts commit 0ac420ecbc.

Reason for revert: this was supposed to be merged later; revert it now and reapply in a bit

Change-Id: I33fb07856152c2401b3a071c143f27f1e9753287
2023-02-12 02:57:31 +00:00
Bartosz Dziewoński 0ac420ecbc Use setExtensionData() instead of marker comments where possible (2/3)
We started using marker comments (HTML comments with special content
inserted into the page) for the reply buttons back in the day, because
we needed to indicate their location in the HTML. Later we used the
same idea for things which aren't actually tied to a specific location
in the HTML, such as boolean data like __DTEMPTYTALKPAGE__. There is a
better way to do this.

This commit starts reading from ParserOutput::getExtensionData(),
which was generated by the previous commit, and should be present
in all cached ParserOutput objects by the time we merge this.

Bug: T328980
Change-Id: I4bf81ef3fd904f4d920d0756370c9bfa0a10a774
2023-02-11 19:33:20 +00:00
Bartosz Dziewoński fce317ace4 Move TOC metadata generation to a post-processing step
Instead of generating the TOC HTML additions immediately, store
the data we need using ParserOutput::setExtensionData(), and use
the OutputPageParserOutput hook to fetch it and generate the HTML.

We check that the stored data is present before using it to avoid
issues with cached ParserOutput objects.

Bug: T328122
Change-Id: I7d4988cd568f10b7995a4d744e0ec6e7ce081b0e
2023-02-07 02:39:11 +01:00
Bartosz Dziewoński 5ad0a7bfcb Add comments about unwrapping Parsoid sections
Follow-up to c9deff179f.

Change-Id: Ib32442020749103012ec508d870d40b7b96f05a0
2023-01-27 17:07:56 +01:00
Bartosz Dziewoński af68c835bb Update exception handling for new code conventions
Change code to match the documented consensus formed on T321683:
https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#Exception_handling

* Do not directly throw Exception, Error or MWException
* Document checked exceptions with @throws
* Do not document unchecked exceptions

For this extension, I think it makes sense to consider DOMException an
unchecked exception too (in addition to the usual LogicException and
RuntimeException).

Depends-On: Id07e301c3f20afa135e5469ee234a27354485652
Depends-On: I869af06896b9757af18488b916211c5a41a8c563
Depends-On: I42d9b7465d1406a22ef1b3f6d8de426c60c90e2c
Change-Id: Ic9d9efd031a87fa5a93143f714f0adb20f0dd956
2023-01-22 18:17:11 +00:00
daniel 47118f901a Reduce parsoid PC writes to randomized sample
We need to be careful about flooding the parser cache with parsoid
content. For this reason, we currently only write to PC for a certain
sample of edits. This logic is implemented in core in
ParsoidHandler::allowParserCacheWrite and controlled by the
TemporaryParsoidHandlerParserCacheWriteRatio setting.

DiscussionTools triggers parsoid PC writes when handling the
RevisionDataUpdates hook, so it should use the same sampling.

Change-Id: Ic33f57b10ae53f431a3c3484c4853e88bf80f47a
2023-01-13 20:52:05 +00:00