When a translation is restored, all the sections that are restored are getting saved. They should get saved only when there is a change.
Description
Details
Project | Branch | Lines +/- | Subject | |
---|---|---|---|---|
mediawiki/extensions/ContentTranslation | master | +11 -4 | CX2: Don't save sections while restoring a draft |
Related Objects
- Mentioned In
- T221840: Content saved after restoring without user modification
T207699: Autosave can be triggered for loaded drafts without user change
T200356: CX2: Prevent autosaving to mark the translation as “in-progress” after publishing if there are no further changes
T177740: CX1: restored in-progress article does not finish loading - Mentioned Here
- T192065: Starting a new translation is loading contents from a previously deleted one
Event Timeline
git bisect outputs:
b625f8e883678698ff73083e9f8b08113e59ef31 is the first bad commit commit b625f8e883678698ff73083e9f8b08113e59ef31 Date: Mon Apr 23 12:27:33 2018 +0530 Add helpful methods in ve.dm.CXSectionNode and refactor getSectionId, getSectionNumber, isTargetSection are some methods we will need often to work with section data models. Add them The onUpdate event handler refactored to use ve.debounce instead of setTimeout. Change-Id: Iae1cac8ff30d4890dd8865cad004b8e48c3faa5e
Change 435161 had a related patch set uploaded (by Petar.petkovic; owner: Petar.petkovic):
[mediawiki/extensions/ContentTranslation@master] CX2: Don't save sections while restoring a draft
Although it is true that problem with saving sections when translation draft is restored is appearing on both CX1 and CX2, the causes cannot be the same. Patch 435161 only deals with CX2.
Loading the saved draft in CX1, while draft has three saved sections, gives following logs (without any action on user behalf):
[CX][MT] Prefetching MT for section mwBA [CX] event: mw.cx.source.ready [CX] event: mw.cx.progress [CX] event: mw.cx.progress [CX] event: mw.cx.translation.change [CX] event: mw.cx.translation.focus [CX] event: mw.cx.progress [CX] event: mw.cx.translation.change [CX] event: mw.cx.translation.focus [CX] event: mw.cx.progress [CX] event: mw.cx.translation.change [CX] event: mw.cx.translation.focus 2x [CX][MT] Initialized MT for section 42a9426b1fb53bf5fc7515a0102a4d with provider source-mt 2x [CX][MT] Initialized MT for section cd5f941d79ebb448aa0f3f7978dccc with provider source-mt 2x [CX][MT] Initialized MT for section d15a8b0227f9209fea9079e3c1304f with provider source-mt
Without looking at the code that fires these events, some parts look strange, but can be justified.
mw.cx.progress fires first, followed by mw.cx.progress, mw.cx.translation.change and mw.cx.translation.focus for each saved section. What looks strange is that 'change' event is fired, but that is possibly section going from empty to being populated with saved section.
Next strange thing is that three messages Initialized MT for section {hash} with provider source-mt are logged twice.
But, then, without any action whatsoever, after 15 seconds we get:
[CX] Save request initiated by: change 2x [CX] Section 42a9426b1fb53bf5fc7515a0102a4d saved. 2x [CX] Section cd5f941d79ebb448aa0f3f7978dccc saved. 2x [CX] Section d15a8b0227f9209fea9079e3c1304f saved.
So, regular auto-save process is triggered and reported to be initiated by 'change' event. Three loaded sections are saved again, even though they never changed, and this action is logged twice.
Again, first batch of logged messages is maybe justified, but saving unchanged sections after 15 seconds isn't.
Change 435161 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] CX2: Don't save sections while restoring a draft
@Etonkovidova, I have discovered these problems in CX1 and CX2 by looking at the console with &debug=1, which makes detailed messages like "Section X saved" display in the console.
Also, more reliable way to detemine if problems are gone after this patch (only in CX2) is by looking at network requests in "Network" tab in DevTools. Before this patch, there was additional cxsave request after the page is fully loaded.
Hope that helps with doing QA.
Thx, @Petar.petkovic - I checked with &debug=1 - there was no extra cxsave
The Console properly shows the following when a saved translation is loaded:
[CX] Fetching Source page... [CX] Checking existing translation... [CX] Fetching existing translation for id: 54 [CX] Initializing translation tool system [CX] Translation initialized successfully
After some actions-translating and deleting some sections, all action will be recorded:
[CX] Saving source content of section 0 [CX] Section 0 saved. [CX] Saving source content of section 1 [CX] Saving source content of section 2 [CX] Section 1 saved. [CX] Section 2 saved.
If the consequences of the issue in CX1 are just a sub-optimal use of resources, we can consider that moving to version 1 will be the fix for it when that happens. If this is contributing to bigger issues, we can explore some specific solution for CX1.