Projet

Général

Profil

0002-forms-prevent-autosave-from-overwriting-magictoken-s.patch

Benjamin Dauvergne, 27 octobre 2021 09:11

Télécharger (1,19 ko)

Voir les différences:

Subject: [PATCH 2/3] forms: prevent autosave from overwriting magictoken's
 data (#58208)

autosave() needs to write into magictoken's data only when establishing
the draft formdata, after that it's not needed anymore. Preventing it to
further modify magictoken's data prevent race condition between AJAX
call to autosave and normal form's submission by users.
 wcs/forms/root.py | 4 ++++
 1 file changed, 4 insertions(+)
wcs/forms/root.py
1328 1328
        self.feed_current_data(magictoken)
1329 1329

  
1330 1330
        form_data = session.get_by_magictoken(magictoken, {})
1331
        # prevent autosave to write into session concurrently with user's
1332
        # submits, only do it when initializing the draft formdata.
1333
        if form_data.get('draft_formdata_id'):
1334
            form_data = form_data.copy()
1331 1335
        if not form_data:
1332 1336
            return result_error('missing data')
1333 1337

  
1334
-