We have identified a following critical bug during our Czech Drupal translation sprint: Simply put - some string you translate will not save when you click Save changes button.

How to reproduce:
1) Open l.d.o in two different browser sessions (possibly under two different users), make a filter choice and make sure both filters are the same in both windows.
2) In both windows, go to a last page of the selection. You should be at page X.
3) In Window 1, go to previous page. You should be at page X-1.
4) In Window 1, translate last few strings and Save changes.
5) In Window 2, translate first string and Save changes. ->This string will not be saved

Why? Because the first string actually internally changed it's position to a different page after you save few strings in Window 1. I think this is a general problem with Drupal forms - when you submit a form and that form is not present on the page that loads after the submit, no submit hook is run.

CommentFileSizeAuthor
#9 base_data_change_can-787068-9.patch4.33 KBSebCorbin

Comments

gábor hojtsy’s picture

This seems to be a side effect of how the form API works. Drupal checks whether the submitted form is valid, and it regenerates the base form structure for that. So if the underlying data changes, the form structure will change., and your data will not be accepted. We could maybe look into testing how form caching interacts with this validation/submission process, so we maybe can eliminate the form regeneration.

gábor hojtsy’s picture

Title: Suggestions not being saved » Base data change can invalidate form

Retitled to be more specific as we now understand the problem.

gábor hojtsy’s picture

#806758: Items come back without suggestion was submitted as a duplicate and has some similar details.

frans’s picture

So translate sprints with l.d.o. are a no-go until this is solved!
Can it be solved by using indivdual forms per item instead of a page form? The position of a item is then not relevant anymore. I also feel that the proccess then is more natural... I don't like the way it works now, I hate to save twice. One time when you leave the field and then the whole page.

gábor hojtsy’s picture

You can still just use per-project filtering where there is much less chance of a form issue (but there is some).

palik’s picture

i created http://drupal.org/node/1299954 and it may be duplicate, but I'm not sure, check the symptoms and repair this please :)

SebCorbin’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
Issue summary: View changes

It may be that we have still this issue on the 7.x-1.x branch, any way, the 6.x version is discontinued

SebCorbin’s picture

Title: Base data change can invalidate form » Translate form re-building should not rely on pagination
Status: Active » Needs review
StatusFileSize
new4.33 KB

The main problem is that the form is relying on pager to get the strings, when a form is submitted, the query is executed again to retrieve the sids.

That can cause race condition when another person (or another page) is submitted and has a lower page number.

I've attached a patch that fetch the sids submitted from $form_state['input'] (that I'm not proud of), but solves the problem. Given we have a limit of 50 strings per page, I've overcome the potential DDOS (even if it is authenticated form) by only allowing a chunk of 50 sids to be input by user.

  • Gábor Hojtsy committed 739d3ff on 7.x-1.x
    Issue #787068 by SebCorbin: Translate form re-building should not rely...
gábor hojtsy’s picture

Status: Needs review » Needs work
+++ b/l10n_community/translate.inc
@@ -309,32 +308,41 @@ function l10n_community_translate_page($langcode) {
+  if (!empty($form_state['input']['strings'])) {
+    $sids = array_keys($form_state['input']['strings']);
+    $strings = l10n_community_get_strings($langcode, $filters, $filters['limit'], $sids);
+  }

So while the limit param is validated, the string list may still be any length no? It would be great to chunk this with the limit or refuse the form if its over 50 (or over the limit that was validated) or something along those lines.

I am a bit wary to make this live honestly :/

  • SebCorbin committed b56a3d9 on 7.x-1.x
    Follow-up Issue #787068: prevent too large input
    
SebCorbin’s picture

Status: Needs work » Reviewed & tested by the community

Pushed a array_slice given the maximum limit we allow in the filter form.

The french team successfully tested this patch on staging.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Deployed to live. Thanks for the quick fix. :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.