Commit graph

15 commits

Author SHA1 Message Date
Bartosz Dziewoński b8a28d6cfc ApiDiscussionToolsCompare: Show nice error for deleted revisions
Bug: T362814
Change-Id: Iecc3e3737fcc82a79e699fe0bc00f373ecabf0c2
2024-04-26 03:54:31 +02:00
Bartosz Dziewoński f3e96a72fa ApiDiscussionToolsCompare: Deduplicate 'from'/'to' param handling
Change-Id: I0351228f50e9ea5a599d11b37f684b8e66553a83
2024-04-26 03:54:05 +02:00
gerritbot dfb413ed81 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I688fe73f46ecc2bbd8f4c59fc42b8e85fadf7689
2023-08-19 04:14:36 +00:00
Arlo Breault 3d9585acbe Handle Parsoid resource limit exceeded exceptions
Parsoid can be expected to throw limit exceeded exceptions so a more
graceful response should be provided.

Bug: T325298
Change-Id: I6bedc7639a68311d5247331d5e53f88c004ebc5e
2023-08-11 18:06:26 -04: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 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 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 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 433e57394c Use PHP 7.4 property types
Change-Id: I788db64f0c0c00894d77256b7f016d44eda4bbb1
2022-10-28 21:56:38 +02:00
Bartosz Dziewoński a46af344dc Use RevisionLookup methods instead of ApiParsoidTrait methods
Part of my secret plan to delete ApiParsoidTrait.

* Inject RevisionLookup into ApiVisualEditor
* Use RevisionLookup::getRevisionById instead of ApiParsoidTrait::getValidRevision
* Use RevisionLookup::getRevisionByTitle instead of ApiParsoidTrait::getLatestRevision
* Use standard MediaWiki error messages

Change-Id: I7244ee4916fb011fad5faa1d9f837e83f6ac2dc1
2022-10-09 18:17:32 +00:00
Bartosz Dziewoński 2679fa3b04 Replace VisualEditor ParsoidHelper with ParsoidClient
Depends-On: I21c4a8cd86f8d085e75a601ed6d2509dedd75d42
Change-Id: I9533d7c05047c2d873c8c6ee5944df965e3b379d
2022-09-19 18:00:14 +02:00
Bartosz Dziewoński dc07d802a9 Inject services into API classes
This replaces the remaining uses of MediaWikiServices::getInstance()
in API classes.

Change-Id: I5f602a7e7b5a21a7d40023571018604528ea8edb
2022-09-03 00:23:41 +02:00
Reedy 400d6227b8 Use namespaced VisualEditor traits and classes
Change-Id: I06eefd96068675607ed66a8a307d86c24d21f916
2022-03-29 20:32:44 +01:00
Bartosz Dziewoński 8e44b43df0 Split off ThreadItemSet from CommentParser
Goal:
-----
Finishing the work from Iadb7757debe000025e52770ca51ebcf24ca8ee66
by changing CommentParser::parse() to return a data object, instead of
the whole parser.

Changes:
--------
ThreadItemSet.php:
ThreadItemSet.js:
* New data class to access the results of parsing a discussion. Most
  methods and properties are moved from CommentParser with no changes.

CommentParser.php:
Parser.js:
* parse() returns a new ThreadItemSet.
* Remove methods moved to ThreadItemSet.
* Placeholder headings are generated slightly differently, as we process
  things in a different order.
* Grouping threads and computing IDs/names is no longer lazy. We always
  needed IDs/names anyway.
* computeId() explicitly uses a ThreadItemSet to check the existing IDs
  when de-duplicating.

controller.js:
* Move the code for turning some nodes annotated by CommentFormatter
  into a ThreadItemSet (previously a Parser) from controller#init to
  ThreadItemSet.static.newFromAnnotatedNodes, and rewrite it to handle
  assigning parents/replies and recalculating legacy IDs more nicely.
* mw.dt.pageThreads is now a ThreadItemSet.

Change-Id: I49bfe019aa460651447fd383f73eafa9d7180a92
2022-02-21 16:22:32 +00:00
Ed Sanders aa03dc971e Add discussiontoolscompare API
For two given revisions, this API tells us which comments have
been added and which have been removed.

Can be used to highlight new comments, or check if the page
has been updated since we first loaded it.

Bug: T281624
Bug: T300504
Change-Id: Ia4d95ffe3b7cf2317cd8e7c0f034e09f64777ef3
2022-02-08 15:53:27 +00:00