Assume Entity has fields A and B, each with FAPE forms. Fields A and B are initially set to A_old and B_old.

The following sequence of events causes a race condition setting stale data to other fields under ajax form submission, but not under standard non-ajax form submission:

1. User opens FAPE form for field A
2. User opens FAPE form for field B, either in another window, or on another form dynamically rendered on same page
3. User sets field A to A_new and submits
4. Without a page reload, user sets field B to B_new and submits

EXPECTED:
A = A_new
B = B_new

ACTUAL:
A = A_old
B = B_new

WHY IS THIS BEHAVIOR ON AJAX ONLY?
Because in non-ajax submission, the page callback reloads the entity prior to calling the validation and submission callbacks. In AJAX submission, the page callback is bypassed in favor of system/ajax, so this doesn't happen and the entity gets stale data on other fields.

FIX
Reload the entity at the beginning of the validation callback. This should be basically free for non-ajax, since the entity is statically cached by then anyway (in the page callback).

I'll post a patch and try it out myself for a little while to make sure there aren't any side-effects.

Comments

captainack created an issue. See original summary.

captainack’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1014 bytes

I tested under ajax and non-ajax and it looks like there are no side-effects.

Status: Needs review » Needs work

The last submitted patch, 2: fape-2716935-ajax_stale_other_fields_fix-3.patch, failed testing.

captainack’s picture

Status: Needs work » Needs review

Silly testbot...