Page MenuHomePhabricator

When VisualEditor saves an edit, it should use the same backend that the HTML was originally loaded from
Closed, ResolvedPublic

Description

The VisualEditor API can use two backends to access parsoid: DirectParsoidClient, or VCSParsoidClient, which talks to RESTbase.

When we switch VE on a wiki from using RESTbase to direct mode, edit sessions that started out using RESTbase as the backend need to continue using RESTbase, so they don't lose access to the stashed base state, which would cause the edit to fail.

To achieve this, the VE API needs to detect which backend the client had originally been loading data from, e.g. using a cookie or by inspeciting the etag submitted in the request body.

original Description

Currently, when VE is initialized, it will load HTML from a REST endpoint. In production, it would do this by hitting the /rest_v1/page/html/{title} andpoint, with redirect=false&stash=true, which is backed by RESTbase. This will fail if the backend is configured to not use RESTbase, because the submitted etag will not match.

@matmarex suggested in T320531#8313224

There are a few ways to fix this:

Set wmgVisualEditorAccessRestbaseDirectly = false [...], so that the client-side request is replaced by a server-side request (easiest fix for now, and we use this config on private production wikis; however it'd be better not to use this for public production wikis, since it makes the editor slower to load)

Make that URL be served by MediaWiki, not RESTBase (I don't know how to go about that)

Set $wgVisualEditorFullRestbaseURL to a different URL prefix that is served by MediaWiki and contains compatible APIs (I don't know if such URL prefix actually exists now)

Perhaps even simpler, we can just ignore the $wgVisualEditorFullRestbaseURL setting when in direct mode.

Event Timeline

Change 842365 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/extensions/VisualEditor@master] Don't try to contact RESTbase directly when in PHP direct mode.

https://gerrit.wikimedia.org/r/842365

abi_ renamed this task from When VisualEditor initializes, it shoudl load HTML from the same backend it will use for saving. to When VisualEditor initializes, it should load HTML from the same backend it will use for saving..Oct 13 2022, 11:58 AM

Change 842365 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Don't try to contact RESTbase directly when in PHP direct mode.

https://gerrit.wikimedia.org/r/842365

Change 842492 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/extensions/VisualEditor@master] AutoConfig should enable VRS, not disable it.

https://gerrit.wikimedia.org/r/842492

Change 842507 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/extensions/VisualEditor@master] Use VRSParsoidClient if AutoConfig is enabled.

https://gerrit.wikimedia.org/r/842507

Change 842507 abandoned by Daniel Kinzler:

[mediawiki/extensions/VisualEditor@master] Use VRSParsoidClient if AutoConfig is enabled.

Reason:

we prefer Ia4c6184dd75a653c3202ea160b6605335f36f6eb

https://gerrit.wikimedia.org/r/842507

Change 842492 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Remove AutoConfig setting

https://gerrit.wikimedia.org/r/842492

daniel renamed this task from When VisualEditor initializes, it should load HTML from the same backend it will use for saving. to When VisualEditor saves an edit, it should use the same backend that the HTML was originally loaded from.Oct 20 2022, 8:49 AM

Change 844465 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/extensions/VisualEditor@master] Pick ParsoidClient implementation based on etag.

https://gerrit.wikimedia.org/r/844465

Change 844465 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Pick ParsoidClient implementation based on etag.

https://gerrit.wikimedia.org/r/844465

daniel claimed this task.