Bug on entry update when form contains upload file fields

To reproduce the issue, follow the next steps on a clean GF installation.

  1. Create a new form which contains some file upload fields and some other fields. Let’s say we have 5 file upload fields and 5 dropdown fields.

  2. Embed the form inside a page and make some (e.g. 10) submissions. On each submission, you must populate each one upload field with files with different filenames.

When a form submission is made, 2 records for each upload file field are inserted in wp_gf_entry_meta table.

The first one contains the field ID as meta_key and full file URI (e.g. hppts://wwww.site.com/wp-content/uploads/gravity_forms/4-b8a7cb16e86fa7f24c8243cd489cfa2f/2022/03/file-330112313.pdf) as meta_value.

The second one contains a random 128 char string as meta_key (e.g. 695cg9347gh … gj308y4ecbcf) and a serialized string containing file path information (e.g. a:3:{s:4:“path”;s:90:"/var/www/html/wp-content/uploads/gravity_forms/4-b8a7cb16e86fa7f24c8243cd489cfa2f/2022/03/";s:3:“url”;s:96:“hppts://wwww.site.com/wp-content/uploads/gravity_forms/4-b8a7cb16e86fa7f24c8243cd489cfa2f/2022/03/”;s:9:“file_name”;s:17:“img-330112610.pdf”;}) as meta_value. Notice that this one sometimes begins with numeric characters, something like 5df4fgw4e… or 12fyi6n4hd7fw…

NOW comes the tricky part.

For each submission you earlier made, edit the form entries (from WordPress backend) and set each one of the dropdown fields to a value.

Save (Update) entry.

In some cases, the entry won’t save the changes.

Here is what happens.

Instead of inserting a record in wp_gf_entry_meta table with the field ID as meta_key and field’s updated value as meta_value, it updates the meta_value of one of the records with the random 128 chars string as meta_key, giving its meta_value the field’s value.

So in this case, when we update dropdown field with field ID = 8 the record before update was

meta_key = 8cg9347gh … gj308y4ecbcf (128 random chars)

meta_value = a:3:{s:4:“path”;s:90:"/var/www/html/wp-content/uploads/gravity_forms/4-b8a7cb16e86fa7f24c8243cd489cfa2f/2022/03/";s:3:“url”;s:96:“hppts://wwww.site.com/wp-content/uploads/gravity_forms/4-b8a7cb16e86fa7f24c8243cd489cfa2f/2022/03/”;s:9:“file_name”;s:17:“img-330112610.pdf”;}

and after update is

meta_key = 8cg9347gh … gj308y4ecbcf (same 128 random chars)

meta_value = (field’s value)

There is no entry with meta_key = 8 or it is never updated if it was set at initial submission.

This happens when the field id of the field you are updating is the beginning of a file upload field meta_key of the same entry, and this can only be happened for the entries with the 128 random chars meta_key.

The issue causes the problem that specific fields in specific entries can never be updated.

I have your support ticket so we won’t address the issue here, however, I will leave this open in case anyone else is interested in the issue. Thank you.

Turns out that bug exists for php branch 7.4 only, not in php 8…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.