Commit graph

212 commits

Author SHA1 Message Date
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
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 af7097f02f Enable collapsible content in mobile talk page lede content
Bug: T323639
Change-Id: I3cfc8e7337172b44156a7f3bed9ff134c0851475
2023-01-03 18:16:15 +00: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 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
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
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
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
Ed Sanders b132522fa9 Make "Add topic" button sticky
Bug: T316175
Change-Id: Ie5198e902ec3fa7a7eba56cef6c6f0ef71ef7314
2022-11-16 12:23:34 +00:00
Ed Sanders 79521f89cf Add button to reveal lede section on mobile
Bug: T312309
Depends-On: I9c3035c9dbe7545a05efb2286dffe0145d3557b4
Change-Id: I9d74914ddbcc9def74e85106a68574a807b0b731
2022-11-10 22:10:04 +00:00
jenkins-bot c0e757c716 Merge "ABtest for mobile, logged out users" 2022-11-08 18:41:38 +00:00
jenkins-bot 811c32c518 Merge "ABtest for mobile, logged in users" 2022-11-08 18:41:23 +00:00
Ed Sanders d6160c76fa Topic subscription feature is unavailable if Echo is not installed
Bug: T322498
Change-Id: I072e9363fceb4beae820b7742dec4249b4f58905
2022-11-07 12:28:45 +00:00
jenkins-bot 0d24c4881a Merge "Revert "Add config to separate out visualenhancements on mobile"" 2022-11-02 09:17:53 +00:00
Bartosz Dziewoński c53b44d1bc Revert "Add config to separate out visualenhancements on mobile"
No longer needed.

This reverts commit d5161bf086.

Bug: T318868
Change-Id: I909266903271cecba050d171a3ec66ef0a12b8a9
2022-11-01 21:09:37 +00:00
David Lynch 9021a45966 ABtest for mobile, logged out users
Bug: T320993
Change-Id: I3530c540ec20f8806abcd7010b4d4933d1b53cfc
2022-10-31 16:23:59 -05:00
David Lynch 2b0d2deb4a ABtest for mobile, logged in users
Bug: T320993
Change-Id: I46597f2846811c52cbaba1a1db31bff575a41246
2022-10-31 16:23:46 -05:00
Bartosz Dziewoński 433e57394c Use PHP 7.4 property types
Change-Id: I788db64f0c0c00894d77256b7f016d44eda4bbb1
2022-10-28 21:56:38 +02:00
Bartosz Dziewoński 8c9a7c451e Retry without RESTBase when the page/revision seems to be missing
Bug: T315688
Change-Id: I2ec0fa20cc1ee36fc521441ac00c5515dc66a37c
2022-10-20 23:06:16 +00:00
jenkins-bot 66780457e4 Merge "Add 'wpTextbox1' to parameters that disable new topic tool" 2022-10-18 15:47:21 +00:00
jenkins-bot d7cf6adb0a Merge "Log page/revision IDs when the page/revision seems to be missing" 2022-10-14 16:34:45 +00:00
jenkins-bot 19e64cd8ee Merge "Use ParsoidOutputAccess when RESTBase is not set up (WMF private wikis)" 2022-10-14 16:34:15 +00:00
Ed Sanders cdad0cc260 Fix '?dtenable=1' on mobile
isFeatureEnabledForOutput already checks if the mobile flag is enabled,
but it also respects the dtenable=1 override.

Change-Id: I95035281bf301b22c1a9ef4c06ec54cdd0cbc85c
2022-10-12 23:53:12 +00:00
Bartosz Dziewoński 6276b6ead5 Log page/revision IDs when the page/revision seems to be missing
Bug: T315688
Change-Id: Icb77d62776f26f2daf3be7559f37eea4c6ab6b69
2022-10-09 20:21:59 +02:00
Bartosz Dziewoński 4588ae7d7c Use ParsoidOutputAccess when RESTBase is not set up (WMF private wikis)
This path will also be used on most non-WMF wikis, but that's alright.

Bug: T315689
Change-Id: I20de2e2391e45b7ccc9233d6d8306ad47462605f
2022-10-09 20:20:17 +02:00
Daimona Eaytoy 50874ab4b7 Fix call to wfMessage
Follow-up to I8cf8b6960533718646189263acabc852ea976416, where the ...
was unintendedly removed.

Also switch to a suppression, because the type should be documented in
ParsoidClient, rather than enforced in callers. We will remove the
suppression once the documentation is updated.

Change-Id: I3ee2534959c8375d29f43e8391894f0a2002ae1c
2022-10-09 13:56:03 +02:00
libraryupgrader 154e47a7a5
build: Updating dependencies
composer:
* mediawiki/mediawiki-phan-config: 0.11.1 → 0.12.0

npm:
* grunt: 1.5.2 → 1.5.3
* grunt-banana-checker: 0.9.0 → 0.10.0

Change-Id: I8cf8b6960533718646189263acabc852ea976416
2022-10-09 10:55:34 +03:00
Bartosz Dziewoński cf4b6015a3 Add 'wpTextbox1' to parameters that disable new topic tool
Bug: T316333
Change-Id: Id73af455df97b26334bf8a450bc6d0ac95deb9bd
2022-10-08 20:49:34 +02:00
David Lynch d5161bf086 Add config to separate out visualenhancements on mobile
Follow-up to d0126ce6de which made them
default-on for all mobile. These two taken together mean that the
mobile visual enhancement features now *only* depend on this config,
rather than on whether the individual features are enabled on desktop.

Bug: T318871
Change-Id: If767753e6d33f19bbc540d4e74273e478198388c
2022-09-28 17:12:48 -05:00
jenkins-bot 3436684b2c Merge "Only hold on to a Config instead of ConfigFactory when injecting" 2022-09-28 14:22:46 +00:00