Page MenuHomePhabricator

Race condition with title saving
Closed, ResolvedPublic

Description

Steps to reproduce:

  1. Set up an abusefilter rule that warns about titles of length one char
  2. Start translating new page
  3. Name the target title as "op" and let autosave kick in
  4. Now do the following sequence: backspace, ctrl+s, k, ctrl+s, backspace, ctrl+s, k, ctrl+s

Observed: I get title too short warning even though the title is two characters long
Expected: no warning

Additional info:
Looking at the 5 save requests this generates I see these as the saved titles:

  1. op (the initial autosave)
  2. op (expected o)
  3. op (expected ok)
  4. op (expected o)
  5. o (expected ok)

Event Timeline

The storage module saves title by taking value from mw.cx.targetTitle. But when and how that mw.cx.targetTitle is updated?

from ext.cx.translation.js

                this.$title.on( 'blur keyup', $.debounce( 500, function () {
			var title = cxTranslation.$title.text();

			if ( title !== mw.cx.targetTitle ) {
				mw.cx.targetTitle = cxTranslation.$title.text();
				validator.validateTargetTitle();
				mw.hook( 'mw.cx.translation.title.change' ).fire();
			}
		}  )

So, the update is not live. That is the reason for your observation. I think we need to debounce the validation, but not the update to mw.cx.targetTitle i

Change 274056 had a related patch set uploaded (by Santhosh):
Update mw.cx.targetTitle immediately after title change

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

santhosh triaged this task as Medium priority.
santhosh added a project: LE-CX8-Sprint 3.
santhosh moved this task from Backlog to In Review on the LE-CX8-Sprint 3 board.

Change 274056 merged by jenkins-bot:
Update mw.cx.targetTitle immediately after title change

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

Arrbee raised the priority of this task from Medium to High.
Arrbee moved this task from QA to Done on the LE-CX8-Sprint 3 board.