Potential data loss on large forms
Overview
On large forms, fields may be dropped before form processing potentially resulting in data loss.
If the number of fields in the form submission exceeds the max_input_vars
php setting (1000 by default) then $_POST
is truncated. The problem was noticed with the 'Update multiple contacts' action and a profile with 13 fields - see https://civicrm.stackexchange.com/questions/39588/update-multiple-contacts-failing
Reproduction steps
- Check that
max_input_vars
has the default of 1000 - Create a custom field set with 12 fields and a profile with them all.
- Search for contacts, select 100, then the 'update multiple contacts' action and the profile just created
- Add some data & save.
Current behaviour
Note that the last records are not updated correctly. Depending on the field type, existing data may be removed by the update, not just that new data fails to save.
Then add max_input_vars = 2000
to php.ini, restart php/apache (depending on your config) and repeat. Should be ok.
Expected behaviour
All data should be processed correctly.
Environment information
- CiviCRM: Master
- PHP: 7.3
- CMS: Drupal 7.80.
Comments
When this occurs an E_WARNING is issued by php according to the documentation. It may be possible to capture that and respond appropriately.
Alternatively, forms (or those that might be big ones) could include a field with the expected number of fields and processing would check the actual number of fields against the expected number.
Somehow we should avoid processing forms where the incoming fields have been truncated.