Commit graph

854 commits

Author SHA1 Message Date
jenkins-bot b95faa7978 Merge "Remove __DTLATESTCOMMENTPAGE__ comment from output" 2023-02-02 17:52:23 +00:00
Ed Sanders 3c04944a86 Remove __DTLATESTCOMMENTPAGE__ comment from output
Other DT markers are removed because we return the body text, but
in this case we return subtitle text to be inserted elsewhere.

Instead pass $text by reference so it can be modified directly.

Change-Id: I9fe4194681cd3737661dca3c8a16e30a6001bd73
2023-02-02 12:51:11 +00:00
Bartosz Dziewoński 3624d89c8b Don't add custom attributes in unwrapParsoidSections()
This code was unnecessarily copied from VE. It's not needed for
anything in this extension, and it causes the headings to be treated
as modified by selser, which in turn causes dirty diffs.

Bug: T328268
Change-Id: Ibdbed430f2ff28d0ea2e67644075c1621d9fae53
2023-01-31 01:32:02 +01:00
C. Scott Ananian 086ce6550f Don't rely on ParserOutput::getTOCHTML() to determine if ToC is present
ParserOutput::getTOCHTML() is being deprecated, and all skins are now
generating the TOC from the TOCData returned by
ParserOutput::getTOCData().  The SHOW_TOC flag was introduced in core
to determine if the TOC should be shown, but Vector-2022 *may* begin to
use other heuristics to determine whether to show the TOC (T315862).
We're conservatively going to process the TOC as long as there is
TOC present to process.

Bug: T328072
Change-Id: I38b439c6752157dbee9b09c9f5443a740dbaabf4
2023-01-27 09:58:47 +00:00
Bartosz Dziewoński c9deff179f ApiDiscussionToolsEdit: Unwrap Parsoid sections before parsing
Otherwise, when a transclusion covers a section boundary, both whole
sections are considered to be transcluded.

We already use this method everywhere else (by way of
HookUtils::parseRevisionParsoidHtml), and VisualEditor also applies
the same transformation (mw.libs.ve.unwrapParsoidSections) before
opening the page for editing.

Bug: T327704
Change-Id: I9d8288e2740d816edb9cbc01d7e5642d52c610d3
2023-01-26 19:26:14 +00:00
jenkins-bot 1f342306b4 Merge "Update exception handling for new code conventions" 2023-01-23 15:32:40 +00:00
jenkins-bot b857a61c75 Merge "SpecialFindComment: Use new FormSpecialPage helpers" 2023-01-23 15:27:59 +00:00
Bartosz Dziewoński 48fd5e09bb Remove 'DiscussionToolsLegacyHeadingMarkup' config option
Bug: T314714
Change-Id: Ie268d1282f81c81c5a18d5858dcf7023515101b7
2023-01-22 19:24:36 +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
jenkins-bot b7405bb006 Merge "Update generating DiscussionTools TOC additions after parser changes" 2023-01-19 21:37:04 +00:00
Bartosz Dziewoński 228ad6f457 Update generating DiscussionTools TOC additions after parser changes
Depends-On: I8329864535f0b1dd5f9163868a08d6cb1ffcb78f
Depends-On: I1b267d23cf49d147c5379b914531303744481b68
Bug: T326677
Change-Id: Id59b946f4a3618a75dfaaef8a0043423b768b21c
2023-01-19 13:29:16 -05:00
jenkins-bot 8facd83609 Merge "Improve handling for comment separators" 2023-01-17 11:48:43 +00:00
jenkins-bot 8b8dba6124 Merge "Test ServiceWiring.php" 2023-01-17 05:53:07 +00:00
Umherirrender ecac4c3bd1 LanguageData: Use special page alias with spaces
The alias stored in the language files is with underscores,
but the value is compared in CommentParser against text with spaces

Affected languages: bjn, hu, id, jv, kaa, tl, tpi, vi, war

Bug: T327021
Change-Id: I8626627d10a240973e631e24508937a9eee9fb14
2023-01-16 22:27:23 +01: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
Dreamy Jazz 68ae9555f1 Test ServiceWiring.php
Test ServiceWiring.php using tests copied from CentralAuth. Because
phpunit does not support marking a file as covered, the ServiceWiring
file is ignored for code coverage as the tests fully cover the file.

Change-Id: I7da8d74fec84a5aa9c77bc0678ad8f55b550893a
2023-01-13 12:01:38 +00:00
jenkins-bot 63e6f270f3 Merge "Enable visual enhancements on all talk namespaces" 2023-01-12 00:25:07 +00:00
Ed Sanders 5c5073b5ba Enable visual enhancements on all talk namespaces
Bug: T325417
Change-Id: I099a7d03f059f08595dec43ff0205fd5ba765885
2023-01-11 18:35:51 +00:00
jenkins-bot 029d8d6d66 Merge "Track callers of parseRevisionParsoidHtml." 2023-01-11 18:23:50 +00:00
daniel b15aecc68c Track callers of parseRevisionParsoidHtml.
We are seeing a lot of parser cache writes coming from
parseRevisionParsoidHtml. We should find out what is causing them.

Change-Id: I25440e0d759e19cc9769404beb6911c64d37d3e3
2023-01-11 19:01:45 +01:00
Bartosz Dziewoński f7104b350f SpecialFindComment: Use new FormSpecialPage helpers
Depends-On: I14c0ebc017aa7387d03dac1ee0021d52d8ba3d0e
Change-Id: I023a701091afa06ef545e18f672e95ea6ee9b575
2023-01-11 04:30:29 +00:00
jenkins-bot d81886c5ce Merge "Enable collapsible content in mobile talk page lede content" 2023-01-10 16:37:11 +00:00
Bartosz Dziewoński 3a9997d6ea Improve handling for comment separators
* Detect comment separators at the end of comments too
* Consider TemplateStyles associated with ignored templates

This unexpectedly improves a lot of cases other than T313097 too,
mostly where <br> or {{outdent}} was used within a paragraph:
splitting comments that were previously jumbled together, or restoring
content that was previously ignored for apps / notifications.

Bug: T313097
Change-Id: I9b2ef6b760f2ffd97141ad7000f70919aeab7803
2023-01-10 01:59:52 +00:00
Bartosz Dziewoński af7097f02f Enable collapsible content in mobile talk page lede content
Bug: T323639
Change-Id: I3cfc8e7337172b44156a7f3bed9ff134c0851475
2023-01-03 18:16:15 +00:00
Tim Starling ef7213a3d3 Clean up ApiDiscussionToolsPageInfo hack
Treat non-talk pages as empty ContentThreadItemSet objects, instead of
returning early from execute().

Exclude non-talk pages even if only the rev_id is specified.

If both rev_id and title are specified, use the title from the
database.

Bug: T325477
Bug: T325598
Change-Id: I3947ac94bb7c9a3d24b73c95f0df2cf847c955f2
2022-12-21 00:57:34 +00:00
Amir Sarabadani 00f5ba5db4 Emergency: discussiontoolspageinfo return empty response in non-talk ns
Bug: T325477
Change-Id: Ia7c8cca8051c800646c0f403065589f682d1ff17
2022-12-19 08:57:43 +01:00
jenkins-bot 05e717f3ef Merge "VisualEnhancements: in some languages put an arrow by the reply button" 2022-12-13 19:47:12 +00:00
daniel a6a12730fc Don't write to parser cache from maintenance script
The parser cache for parsoid output isn't yet ready for full load.
Don't flood it when running batch operations.

Change-Id: I77f3de30b0500f0e5c593f4d31dceef7720f848e
2022-12-13 16:26:03 +00:00
David Lynch c706562ce9 VisualEnhancements: in some languages put an arrow by the reply button
New config: DiscussionTools_visualenhancements_reply_icon_languages

Config is set up with a provide_default merge strategy so we can remove
items from it quickly if need be.

Bug: T323537
Change-Id: Ib748897a2162bb233000f7364e30b268932f4c4a
2022-12-13 00:11:08 -06:00
Ed Sanders c2dc05b085 Add 'collapsible-headings-collapsed' body class
Used by MobileFrontend in I78cfb22fbe7d to prevent sections from
auto-expanding.

Bug: T321618
Bug: T322628
Change-Id: I6dafd5b9cb170bfa57f185849db6450162173399
2022-12-07 16:51:22 +00:00
daniel 683edf3947 Track parsoid render reason.
Call ParserOptions::setRenderReason to allow us to track why we render
and in particular, why we write to the parser cache.

Change-Id: If42f802f4cf2da39b06cbb8a30c4dc7d9a663001
2022-12-05 20:54:55 +01:00
jenkins-bot 984f804f17 Merge "Don't collapse the lede section when it has comments" 2022-12-05 19:04:37 +00:00
jenkins-bot 8a6bc91f46 Merge "Consider MediaWiki:Talkpageheader message when adding "Learn more" button" 2022-12-05 19:04:35 +00:00
Bartosz Dziewoński a2a06d0316 Reverse default sorting on Special:TopicSubscriptions
Bug: T324245
Change-Id: I87c43bda9a40fdf66c3f4f2d8bc66e211107a557
2022-12-01 22:18:18 +01:00
David Lynch 51ed8a21f6 Avoid error building threaditemshtml if there's an empty final section
If the final content on a page is a heading, there would be an error as
we tried to access nextSibling on a non-existent node.

Also tidies up the case where there's an empty section that's not the
final section. It would have `othercontent` set to an empty string,
which was pointless -- the empty `replies` field is sufficient.

Bug: T321317
Change-Id: Ia58e97214e715c1f6b02c2e045d13f2df7393b80
2022-12-01 11:44:28 -06:00
Bartosz Dziewoński b4475801fd Don't collapse the lede section when it has comments
Bug: T324139
Change-Id: I14e1dae0fef4177f5a6a223bc9b663e99c9f741c
2022-11-30 20:25:22 +01:00
Bartosz Dziewoński e72f58ca78 Remove some redundant PHPDoc comments
Inspired by this Wikitech-l discussion:
https://lists.wikimedia.org/hyperkitty/list/wikitech-l@lists.wikimedia.org/thread/NWXPNHRNLEVXHSWX33H473OAWQP6CDOA/

To keep this simple for now, I am only removing redundant PHPDoc
comments on constructors, and only when all the documentation for
parameters completely duplicates type hints.

More could be done, but that can happen later when we have better
tooling. Redundant comments on constructors that take a dozen services
are by far the most annoying for me and I want them gone now.

Change-Id: I86cbf7d6e48035cfa06f780c8fb1b02e68709a0c
2022-11-29 18:47:18 +00:00
Bartosz Dziewoński 74fbe19838 Consider MediaWiki:Talkpageheader message when adding "Learn more" button
We also need to move the code to the other hook to avoid adding it twice now.

Bug: T324046
Change-Id: I186d15f6e6537b47b019c9707d7ae8ef080f4ae2
2022-11-29 18:46:40 +00:00
Bartosz Dziewoński be012ced04 Only match article path until first '?' when parsing links
Bug: T324028
Change-Id: I7aca1a8f20695b9ecd3f63f2d0a3f5684616655e
2022-11-29 17:16:03 +00:00
jenkins-bot ea54a8facc Merge "Use 'BeforePageDisplay' instead of 'OutputPageBeforeHTML' for once-per-page things" 2022-11-28 15:23:52 +00:00
Bartosz Dziewoński 8452f94cf9 Use 'BeforePageDisplay' instead of 'OutputPageBeforeHTML' for once-per-page things
Also fix a CSS selector to handle content added in multiple
'OutputPageBeforeHTML' hook calls.

Bug: T323376
Bug: T323833
Change-Id: I480d9bf544d61f0cb7bfd04cadfbf053e7e1b70e
2022-11-25 16:12:16 +00:00
jenkins-bot 36af2d1002 Merge "Allow replying to some comments with accidental complex transclusions" 2022-11-24 14:00:45 +00:00
jenkins-bot eb9631164d Merge "Place replies outside transclusions, disallow replying to transcluded comments" 2022-11-24 14:00:40 +00:00
Bartosz Dziewoński 7dd4855979 Fix Phan failure due to core changes in Action
Caused by I8188172aeb7ec775eeb2060a1e163112e9e5ed66.

Change-Id: Ieafc280c76b20e4efbe23cf3e2b193a4a6490b50
2022-11-23 11:27:54 +00:00
Bartosz Dziewoński 3042148bfe Dedupe ApiDiscussionToolsTrait::parseRevision and HookUtils::parseRevisionParsoidHtml
After recent changes (I101c1e84739a2ac1f562f2f7bdc4b8f53d9f3b23 and
Ifbde590ccb6bf3203a2f664cb0d8a73b8d507b78) these methods became
basically the same.

Change-Id: Iedc201e798a5a34713296b20b97ae6cc8b991b66
2022-11-21 21:01:19 +00:00
Derick Alangi 672ca86016 ApiDiscussionToolsTrait: PageInfo & Compare don't need HTML for editing
ApiDiscussionToolsPageInfo and ApiDiscussionToolsCompare in direct parsoid
or VRS modes tries to fetch HTML using VisualEditor thus stashing the
HTML gotten which we don't want, we only need it for viewing in these cases.

This seems like something that was/is already happening in RESTBase. So for
APIs in DiscussionTools that need the HTML for viewing, just get it from
parser cache and not stash it.

Bug: T323357
Change-Id: I101c1e84739a2ac1f562f2f7bdc4b8f53d9f3b23
2022-11-21 16:29:13 +01:00
Bartosz Dziewoński 9601fde487 HookUtils::parseRevisionParsoidHtml doesn't need HTML for editing
Bug: T323357
Change-Id: Ifbde590ccb6bf3203a2f664cb0d8a73b8d507b78
2022-11-21 13:37:16 +01:00
Bartosz Dziewoński e0be640c35 Don't add lede button if mobile DiscussionTools not enabled
Bug: T323341
Change-Id: I60d93a3e72918d303a45b2a75f4fa549aea8d917
2022-11-18 15:55:54 +01:00
David Lynch 714830f615 Don't run OutputPageBeforeHTML for the talkpageheader
Ideally this would just not run the hook for any interface messages, but
that condition isn't obviously available.

Bug: T316175
Change-Id: Ibd354eb7a0fb7a316dcbf09e64b80f2d9b4008c8
2022-11-17 21:15:51 -06:00
Bartosz Dziewoński 4cebf20e76 CommentFormatter: Fix condition for lede button to consider table of contents
(Also fix some related CSS that was accidentally moved in
Ie5198e902ec3fa7a7eba56cef6c6f0ef71ef7314)

Bug: T323241
Change-Id: I1fa67965a1b6b827c500a9de63f5b5295bee840d
2022-11-16 22:18:11 +01:00