Page MenuHomePhabricator

Translated sections are saved when restored, even without a change
Closed, ResolvedPublic

Description

When a translation is restored, all the sections that are restored are getting saved. They should get saved only when there is a change.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 26 2018, 12:41 PM
Pginer-WMF triaged this task as High priority.Apr 26 2018, 3:48 PM
Pginer-WMF moved this task from Backlog to Priority backlog on the Language-2018-Apr-June board.
Pginer-WMF moved this task from Needs Triage to Bugs on the ContentTranslation board.

Is this happening on CX1, CX2, or both? May this be related to T192065 in some way?

Is this happening on CX1, CX2, or both?

This is happening in both CX1 and CX2.

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

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

Is this happening on CX1, CX2, or both?

This is happening in both CX1 and CX2.

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

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

@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.

Etonkovidova closed this task as Resolved.Jun 14 2018, 1:04 AM

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.

@Pginer-WMF what about this issue in CX1? See my previous comments.

@Pginer-WMF what about this issue in CX1? See my previous comments.

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.

Vvjjkkii renamed this task from Translated sections are saved when restored, even without a change to q5daaaaaaa.Jul 1 2018, 1:13 AM
Vvjjkkii reopened this task as Open.
Vvjjkkii removed Petar.petkovic as the assignee of this task.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed subscribers: gerritbot, Aklapper.
AntiCompositeNumber renamed this task from q5daaaaaaa to Translated sections are saved when restored, even without a change.Jul 1 2018, 12:07 PM
AntiCompositeNumber closed this task as Resolved.
AntiCompositeNumber assigned this task to Petar.petkovic.
AntiCompositeNumber updated the task description. (Show Details)