MDL-41819 attempt to work around max_input_vars

This change is based on patches by Paul Nicholls.