Commit graph

34 commits

Author SHA1 Message Date
jenkins-bot 03f8d2b916 Merge "Use statslib instead of statsd in DirectParsoidClient" 2024-10-21 16:59:40 +00:00
Umherirrender 0463bec879 Use namespaced classes
Changes to the use statements done automatically via script

Change-Id: Ic6450685433e240a4e93ce2beec381da16587b15
2024-10-20 14:01:32 +02:00
Yiannis Giannelos bfc4edbbc5 Use statslib instead of statsd in DirectParsoidClient
Depends-On: I7d4ca748c106dfd560dae31294decfb2b181e2db
Depends-On: Ib14a1ee44b81476447717bc6aa00b54de1dca995
Change-Id: I0d8eb6cacd761fa4959419b10d59046e61c714ff
2024-10-18 22:36:40 +00:00
C. Scott Ananian 90a0a76999 Remove use of deprecated Html*Helper::init() methods
HtmlOutputRendererHelper::init() and HtmlInputTransformHelper::init()
have been deprecated.

This is a replay of Id63d93db801d0bfb3fdb4c69bf7dfeea4e68ea8f and
I8b5cd59f839446709ffd0ce1b78c1bba40195ae0, which got merged prematurely
before their Depends-On was merged.

Depends-On: I1e1213597c6be012f2bc024c2b370c968ff3b472
Change-Id: Ie762dc34523eed79bc537143394b04e64f004b53
2024-07-19 03:00:38 -04:00
Jdlrobson 47442144d5 Revert "Remove use of deprecated HtmlOutputRendererHelper::init(..."
Revert submission 1039794-split-render-id

Reason for revert: Depends-On has not been merged yet so this
is causing CI issues.
Reverted changes: /r/q/submissionid:1039794-split-render-id

Change-Id: Iac6316cf7010b5ea92672e9ad6f09e8ee57e066b
2024-07-02 22:42:31 +00:00
Jdlrobson eb3b47be84 Revert "Remove use of deprecated HtmlInputTransformHelper::init(..."
Revert submission 1039794-split-render-id

Reason for revert: Depends-On has not been merged yet so this
is causing CI issues.
Reverted changes: /r/q/submissionid:1039794-split-render-id

Change-Id: Ifcb43e8e3dd845c146498562b398affe2936593f
2024-07-02 22:41:41 +00:00
Divec e2934f2ebb Merge changes from topic "split-render-id"
* changes:
  Remove use of deprecated HtmlInputTransformHelper::init() method
  Remove use of deprecated HtmlOutputRendererHelper::init() method
2024-07-02 18:26:30 +00:00
Umherirrender b985813c56 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Ia08d43b3973a12b8e0628c8552bee1c4b702f249
2024-06-10 22:36:31 +02:00
C. Scott Ananian 6bb86cbaaf Remove use of deprecated HtmlInputTransformHelper::init() method
Depends-On: I1e1213597c6be012f2bc024c2b370c968ff3b472
Change-Id: I8b5cd59f839446709ffd0ce1b78c1bba40195ae0
2024-06-07 21:40:10 +00:00
C. Scott Ananian 443e67c5c1 Remove use of deprecated HtmlOutputRendererHelper::init() method
Depends-On: I1e1213597c6be012f2bc024c2b370c968ff3b472
Change-Id: Id63d93db801d0bfb3fdb4c69bf7dfeea4e68ea8f
2024-06-05 12:22:29 -04:00
jenkins-bot 932df6759e Merge "Add type declarations and remove redundant PHPDoc tags" 2024-06-04 18:24:54 +00:00
thiemowmde 1d449787ef Add type declarations and remove redundant PHPDoc tags
Most of this code was already typed, but not everything. Using
language-level type declarations allows us to remove extra PHPDoc
blocks that just repeat the same information.

I'm also using the more narrow UserIdentity instead of User in a
few places where this is possible.

Change-Id: I7661824fcb34180af1a4fd3030fcd6c0b7d34089
2024-06-04 16:55:00 +00:00
daniel ecb7693e1c DirectParsoidClient: don't call setOriginal directly
Pass renderId and revisionId as part of the (fake) body to
HtmlInputTransformHelper::init, instead of calling setOriginal()
directly. This avoids mis-counting these requests as not providing a
renderid in statsd.

Change-Id: I929812e571d8bd5df1c833586f3ae35d43af63cf
2024-03-19 19:13:01 +00:00
Arlo Breault e054c3da90 Use metrics from SiteConfig to restore the Parsoid prefix
According to Ie85f2306e8b0f123b9fdd737faffdd85117015b1

Bug: T339365
Change-Id: I99c15876424a454309116fa1269d0a1a456e0d46
2023-08-30 20:28:23 -04:00
Bartosz Dziewoński ca64e7e407 ApiParsoidTrait/DirectParsoidClient: Simplify error handling
After catching the REST exception, just throw an API exception.
Remove the step inbetween where we built a response array.

Bonus:
* Remove tests that only tested this array building.
* Remove the unused 'code' from successful responses, and update
  documentation of return value shapes.
* Remove impossible check for `$ex instanceof LocalizedException`.
  After moving the code into one place, it's obvious that it can't
  happen, since LocalizedException doesn't inherit from HttpException.

Bug: T341613
Change-Id: I31370efeed9d5283b53eafca102b2f1efc811d27
2023-08-16 17:09:18 +02:00
thiemowmde ab2cbb3b70 Change almost all code to use Bcp47Code instead of Language
This patch makes the following assumptions:

1. There is no class outside of this codebase that implements the
ParsoidClient interface. According to CodeSearch this appears to be
correct.

2. It is fine to use the Bcp47Code instead of the internal MediaWiki
language code in the "Accept-Language" HTTP header. As far as I
understand this might even qualify as a bugfix.

Depends-On: If059674597e261039df7f4613a89cb08120c3262
Change-Id: Icd160da2d5555891b9a91a0cb966bd36a55f6fdd
2023-07-12 09:38:16 +02:00
thiemowmde 44621c6b92 Use more narrow Bcp47Code interface in DirectParsoidClient
Change-Id: I36f6e2f1ca8e3e3d7f98ecbec8b9d62790e579ba
2023-07-07 09:59:23 +02:00
Arlo Breault 7d5b964507 Bump requested Parsoid HTML version to 2.8.0
This will ensure that media have the mw-file-element classes so that the
styling changes in I70c61493fe492445702f036e5b24ef87fc3bdf43 apply.

Older 2.7.0 content still in storage is missing the classes and doesn't
render correctly.

Note that I545ed75ed3c87e88b5e776696754e23c05645f81 made sure that
editing of both versions was always compatible.

Bug: T337596
Depends-On: Ia70f819df79fbb12a5b1dd6a98bfe0b968808d18
Change-Id: I40ed887e03f983e0737e1ee7cba5a4012fea31db
2023-05-31 12:12:59 -04:00
Arlo Breault e7e5241802 Ensure a compatible Parsoid output version for direct client
Presumably VE will move in lock step with the Parsoid library but this
retains the ability to negotiate even at this level.

Change-Id: Ice3beabcb1a475f2de9ad61e0f234a9cc23f80bd
2023-05-31 12:08:28 -04:00
daniel 96292e770a Don't force the "view" flavor when using stashing!
Bug: T333402
Change-Id: I6fc598cb2309c442a0b5bfe665f6f96c1a6edf85
2023-04-06 12:17:11 +02:00
C. Scott Ananian 4d8345247a DirectParsoidClient: Remove backward-compatibility workaround
Depends-On: I982e0df706a633b05dcc02b5220b737c19adc401
Change-Id: I316c4f9ddd4483eacb6c88181f0c5edd785cffe5
2023-03-14 21:38:46 +01:00
C. Scott Ananian 10cb01cdd1 Update DirectParsoidClient to match BCP-47 changes in core
We're trying to avoid passing raw strings around, since they can be
ambiguous specifiers of language.  This patch makes VE compatible
with I982e0df706a633b05dcc02b5220b737c19adc401, with a backward
compatibility workaround which can be removed after
I982e0df706a633b05dcc02b5220b737c19adc401 merges.

The new code also uses slightly more methods of the Language object,
which need to be mocked in a unit test.

Change-Id: I830867d58f8962d6a57be16ce3735e8384f9ac1c
2023-03-08 21:19:21 +00:00
Derick Alangi deecb3cdcb Use helper classes from the new namespace
Helper classes have been moved to a dedicated namespace
of their own, this patch references the new namespace.

Depends-On: Ieeb7a0a706a4cb38778f312bfbfe781a1f366d14
Change-Id: I5a2792a3536f6d953905561410f0e4966254ccbe
2023-01-16 14:22:38 +01:00
daniel 3a50a092d9 Catch HttpException early
Catch HttpException from REST helpers, even when they are triggered
already during initialization. This will happen e.g. when the request is
asking for a render key for which the stashed rendering has expired.

Bug: T325310
Change-Id: I9e622b5bb253f5e40fe2b50ff08471beddac9acf
2022-12-15 18:12:37 +00:00
daniel f36572432b Use PageRestHelperFactory
This isolates this extension from knowledge about the constructor
signature of the helper classes. Constructore signatures are not stable
interfaces.

Needed-By: Ie430acd0753880d88370bb9f22bb40a0f9ded917
Depends-On: I10af85b2da96568cfffd03867d1cb299645fb371
Change-Id: If1914dbfbefc3501b4d4cef4beb1fae307c36455
2022-11-19 21:21:11 +00:00
daniel bb66502100 Use setters to initialize helpers
Use setters instead of constructing fake request data.

Depends-On: I18c8bc6f5aa7c204f0faa56919bfe64026761bd4
Change-Id: I8d778c6e5d0b21f8615e3f330f63675cf51eee94
2022-11-04 13:18:56 +00:00
msantos 72b4f8cdbb Rename HTMLTransform related classes
* Rename imported classes in VE that will be renamed in core
* Re-enable tests that would fail when the core patch is merged

Depends-On: I506f3303ae8f9e4db17299211366bef1558f142c
Change-Id: I59ebeb24fa0de5f10d1501cc0830c7e4805e1003
2022-11-04 11:43:36 +00:00
jenkins-bot 4191ac2a20 Merge "Add HtmlTransformFactory as depdendency for HtmlOutputRendererHelper" 2022-11-01 19:48:39 +00:00
Arlo Breault c1afc62040 Bump requested Parsoid HTML version to 2.6.0
Change-Id: I544d31ca6ea6186a4ddaf7ef25fdea899f454c58
2022-10-20 17:01:17 -04:00
Abijeet a9a4d9eab0 Add HtmlTransformFactory as depdendency for HtmlOutputRendererHelper
Bug: T317019
Depends-On: I5e11452f1c531a757e8d860f9c727b5810406bce
Change-Id: Ib4262e95cc333d008b083f74c88919441095f446
2022-10-14 15:47:31 +05:30
daniel 35cb550747 Local implementation of ParsoidClient (DirectParsoidClient)
* DirectParsoidClient makes use of parsoid directly for performing
transformations on both wikitext and/or HTML contents.

* Also, it's used to fetch HTML from parsoid's parser cache. Before,
this operation was done via RESTBase but now it's being fetched in
core's parsoid parser cache.

* This patch also enables VE clients to transform HTML to
Wikitext when switching from HTML to source mode on. It
makes use of the HtmlInputTransformHelper to perform this
transformation.

* Now, VE client can make use of core code for switching
between HTML to source mode and back without RESTBase.

Change-Id: I5c7cfcc4086d8da7905897194d8601aa07418b59
2022-10-11 18:34:06 +01:00
Bartosz Dziewoński 209aaf6943 ParsoidClient: Fix getPageHtml() $targetLanguage param inconsistencies
* DirectParsoidClient: Actually allow null to be provided.
  Previously we tried to call methods on it unconditionally.

* VRSParsoidClient: Require the param to be provided (even if null).
  No reason to diverge from the interface, which requires it.

Change-Id: Id9a450dc8b8eb3e82cf87718b96975e5a3c6180c
2022-09-26 22:52:31 +02:00
daniel 0d833c3de1 ParsoidClient: rename language parameter
The language parameter in the ParsoidClient is always the desired output
language.

Change-Id: I10bec964b16fb041d5acfc63f38511e545adafc4
2022-09-26 22:46:22 +02:00
daniel 0cd6c90d5a Extract RESTbase client code into VRSParsoidClient.
This makes the "direct" client and the VRS based client
implement the same interface, so the caller doesn't have to know
which one it is using.

It looks like ParsoidHelper will not be needed if we use this approach.

Change-Id: Ib1c1d7355951fc0765227dd01a9edfc554fc448d
2022-09-14 18:20:36 +01:00
Renamed from includes/VisualEditorParsoidClient.php (Browse further)