PHP versions 5.3.9 and higher contain a max_input_var setting which limits the number of input variables that may be returned by the form via $_POST. This has been documented elsewhere. Because the conditionals page uses ajax, these errors are logged, but are not displayed to the user. The default setting is 1000. If each conditional has only one clause, it consumes 6 input vars, causing failure at about 168 conditionals. This would happen sooner if conditionals have many clauses, as each additional clause consumes another 3 input vars.

It is also possible for a very large webform to consume all 1000 input vars, although this is much less likely.

Even though this is completely outside the scope of webform, it would be helpful if some indication of the problem was given.

Solution

1. On the conditionals page, preflight the number of input vars needed. This is possible because a limited number of different form elements are used and can be recursively counted in the form. This gives a warning that the problem may happen.

2. On both the conditionals page and the webform_client_form test to see if the previous $_POST seems to have been truncated. The form_build_id is one of the last items added to the form and if it is missing, then the form is presumed to have been truncated.

3. Provide administrator- or user-appropriate error messages.

4. Log the condition in the Drupal error log.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

  • DanChadwick committed e0d742d on 7.x-4.x
    Issue #2417757 by DanChadwick: Conditionals page or webform_client_form...
  • DanChadwick committed c19df69 on 8.x-4.x
    Issue #2417757 by DanChadwick: Conditionals page or webform_client_form...
DanChadwick’s picture

Title: Conditions page or webform itself may exceed PHP max_input_vars and stop functioning » Conditionals page or webform client form may exceed PHP max_input_vars and stop functioning
Status: Active » Fixed
FileSize
7.24 KB

Committed to 7.x-4.x and 8.x

joelpittet’s picture

Thanks this may help find some issues. Do you know what causes this kind of thing?

This is one common result I'm getting now:

POST truncated to 22 input vars. PHP max_input_vars is 10000. Increase
max_input_vars.

Where 22 doesn't look > 10000. Any idea how I can find where it's maxing out from?

DanChadwick’s picture

@joelpittet -- Hmmm. Seems to be something else is amiss.

This message is displayed when the form was posted ($form_state['input'] isn't empty) but the form_build_id is missing. When I wrote that error message, I was assuming that the overwhelmingly likely cause is that max_input_var is exceeded.

I'd look at what $_POST looks like, and why it doesn't contain form_build_id. Please let us know what you find. Somewhere between your browser and webform, you're losing the all-important form_build_id.

joelpittet’s picture

Thanks I get email log messages when this happens, so I just added $_POST and we'll see what comes of it.

joelpittet’s picture

POST truncated to 36 input vars. PHP max_input_vars is 10000. Increase
max_input_vars.


$_POST => Array
(
     [submitted] => Array
         (
             [name] => REDACTED
             [position] => REDACTED
             [business_name] => REDACTED
             [address] => Array
                 (
                     [street] =>REDACTED
                     [city] => REDACTED
                     [state_province] => REDACTED
                     [zip_code] => REDACTED
                 )

             [what_is_your_companys_website_address] => REDACTED
             [email] => REDACTED
             [phone] => REDACTED
             [sign_me_up_for_enews] => Array
                 (
                     [mailchimp_signup] => 1
                 )

             [are_you_the_primary_decision_maker_for_purchasing] => 1
             [type_of_business] => 2
             [how_did_you_hear_about_us] => Array
                 (
                     [N] => N
                     [X] => X
                     [A] => A
                     [C] => C
                 )

             [industry_magazine] => 4
             [how_many_XXXXX_appointments_do_you_typically_schedule_per_day]
=> 1

[do_you_currently_have_a_licensed_XXXXXXXXX_or_XXXXXXXXX_professional_on_staff]
=> Y
             [number_of_staff] => 1
             [XXXXX_only_products] => Yes

[what_type_of_services_do_you_currently_offer_eg_XXXXXs_XXXXXX_XXXXXXX_etc_]
=> XXXXXs
             [how_many_XXXXX_rooms_do_you_currently_have] => 1
             [how_many_years_has_your_business_been_open] => 2
             [what_is_your_time_frame_for_bringing_on_us] => 1
             [does_your_XXXXXXX_have_a_dedicated_retail_space] => Y
             [do_you_have_multiple_locations] => N
             [what_is_it_about_us_that_caught_your_attention] => Array
                 (
                     [B] => B
                     [C] => C
                 )

         )

     [details] => Array
         (
             [sid] =>
             [page_num] => 1
             [page_count] => 1
             [finished] => 0
         )

     [form_id] => webform_client_form_17817
     [op] => Submit
)

DanChadwick’s picture

Status: Fixed » Active

Sooooo. The question is now, what happened to the build_form_id and form_token?? Can you reproduce this, or is it happening only sporadically in a live environment?

Without the build_form_id and the form_token, the webform (or any Drupal form) will not submit.

I'm marking this active, although if the resolution isn't forthcoming, we should move this to a new issue.

joelpittet’s picture

Well the record is being saved... and it quite positive the submissions are legit from the content.

It's live enviornment and it seems not so sporatic as pretty much every error email log matches a submission.

DanChadwick’s picture

@joelpittet -- are you using any ajax -- perhaps a module that submits webforms by ajax? I found this problem with Opera: #2043181: Ajax form submit not work in Opera due to missing $_POST['form_build_id']

Your users are getting a "This form could not be submitted..." message. Since you can reproduce this at will, maybe you can figure out what is causing this. I can't reproduce it and I don't understand why the $_POST is missing the form_build_id.

If these forms are submitted from anonymous users, then they won't contain a form_token. Looking at your data, I'm guessing that this is the case. Still, drupal_prepare_form adds the hidden form_build_id, so it should have been sent to the browser (unless some other module removed it).

Does it happen every time?

I can change my test for ['op'], since that would be truncated too, typically

joelpittet’s picture

No ajax with webform that I know of...

Everything is heavily cached in a number of ways though... so that may be part of it. I have memcache for most bins, redis for the ones that do or could have big items in > 1MB and DB for form and update cache bins.

They are all anonymous user submissions at first glance and very consistent.

joelpittet’s picture

I think authcache forms is removing the form_build_id. Do you think not having that key would be part of the issue?

DanChadwick’s picture

Re #11 -- ding, ding, ding, we have a winner. I am preparing a patch that switches to testing for op, since that's at the end of the form too and also will include a test for the components page, since that will have the same issue with exceeding max_input_vars.

  • DanChadwick committed 45b2e3b on 7.x-4.x
    Issue #2417757 by DanChadwick: PHP max_input_var check extended to...
  • DanChadwick committed de434a7 on 8.x-4.x
    Issue #2417757 by DanChadwick: PHP max_input_var check extended to...
DanChadwick’s picture

Category: Feature request » Bug report
Status: Active » Fixed
FileSize
3.09 KB

Extended max_input_var check to the components page and changed warning test from form_build_id to op.

This resolves any issue with authcache removing the form_build_id and offers a warning to those with lots of components.

Committed to 7.x-4.x and 8.x

DanChadwick’s picture

Darn. 'op' doesn't work with ajax. form_id, then.

Committed to 7.x-4.x and 8.x

  • DanChadwick committed 859c655 on 7.x-4.x
    Issue #2417757 by DanChadwick: Change max_input_vars truncation test...
  • DanChadwick committed 157834d on 8.x-4.x
    Issue #2417757 by DanChadwick: Change max_input_vars truncation test...
joelpittet’s picture

Thanks no more emails since this commit:)

agileadam’s picture

Dan,

I've been having this issue with webform + modal_forms. Sure enough, $form_state['input']['form_id'] does not exist, which is leading to the message from webform.module. I'm going to try to get to the bottom of why. In the meantime, the error message from webform mislead me a little bit. Can you add a conditional to check if max_input_vars really is the culprit, and handle the result accordingly? I've attached what this might look like against 7.x-4.3 as a simple diff. I can provide a patch against 7.x-4.x but figured you'd want to monkey around with it (or reject the idea altogether), so it wouldn't be worth the effort.

Thanks!
Adam

DanChadwick’s picture

@agileadam -- are you using the latest dev? It should have no trouble with modal_forms.

I don't want to add that test because the limit from the .ini file is not necessarily correct. Apparently it can report the local value, even when that local value is not being used by PHP.

If the latest code works for your situation, then we are all set. If not, please send me the $_POST and/or $form_state['input'] that you are getting that is triggering the issue. You can post it publicly or send it to me via my contact page. Any information in it will be kept confidential.

agileadam’s picture

Dan,

Thanks for responding so quickly!

As suggested I tried the 7.x-4.x development branch. The error went away! Nothing happens when I click the "Submit" button, but I'll work through that now. This webform has just two text fields. If I view the full webform node I can submit. If I view the webform in a modal clicking submit does nothing (no watchdog entries, no javascript errors).

Is there a patch (or patches) I can apply to 7.x-4.3 instead of running the development branch? This project will be going live within the next month, so I'd rather be on a stable release. If the answer is "no" that's fine, I'm just curious.

Thank you again!

agileadam’s picture

It looks like I am getting some JQuery warnings when I click the link to the modal webform. I don't believe this is a webform issue, so I'll continue this over in the modal_forms issue queue if needed.

 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

UPDATE: The form doesn't work for user id #1, but it works for anonymous users and other users I've tried. That javascript warning exists whether the form lets me submit or not. I'll report back when I find out why user #1 doesn't work, in case it helps someone else.

UPDATE 2: The form was breaking because user id #1 had access to Search Autocomplete and all other users (and anon) did not (because I wasn't finished testing this). So, search_api_autocomplete is causing the webform in a modal to not submit correctly. As soon as I disabled autocomplete on my search form uid #1 was able to submit the form. That was an interesting wild goose chase. I'll stop updating this now and will poke around search_api_autocomplete.

DanChadwick’s picture

I don't see how #21 can be related to this issue, which is just some extra error checking.

You can apply the cumulative patches in this issue to 4.3, or you can use the current dev. You can review the post-4.3 commits, which are few to decide if you are comfortable with them. It is likely that there will be a 4.4 within a month.

agileadam’s picture

Dan,

Thank you for the followup. I just updated my last comment to say that, in fact, the problems I was having were related to search_api_autocomplete/ctools' modal.js. It took a while to figure that out. Sorry to muddy your thread. Uggh.

Thanks for the info re: 4.3 and 4.4.

paragonn’s picture

I am having the same issue with Webform Ajax. The form submits fine, but when I click on the ajax 'Return to form link', I get the 'Post truncated error' (or if I am an anonymous user: 'This form could not be submitted because it exceeds the server configuration. Contact the administrator.').

DanChadwick’s picture

@paragonn -- use the latest dev, or at least 7.x-4.3+3-dev. Post back if you still have an issue.

Status: Fixed » Closed (fixed)

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

fumble’s picture

After updating webform from 7.x-4.1 to 7.x-4.9

I got the following message when I try to save conditionals on a webform:

This form could not be submitted because $_POST was truncated to 874 input vars. PHP max_input_vars is 20000 and needs to be increased.

I upgraded to the devel version, but I still have the same message when I clic "save conditions".

I cannot edit conditionals anymore.

I tried to increase max_input_vars, but it changes nothing.

What am I missing?

DanChadwick’s picture

It sounds like you have increased max_input_vars, but your PHP configuration is using some other value. Are you using https://suhosin.org/stories/index.html for example?

The warning is just a warning, but the fact that you can't save conditionals indicates that your PHP server is truncating the (huge) form that the conditionals page returns from the browser.

fumble’s picture

Yes, I am using Suhosin Patch 0.9.9.1.

I have check with phpinfo, max_input_vars for this vhost is equal to the value I set.

If I let default value of max_input_vars (1000) then go to the conditional part of the (huge) webform, I can see this message in yellow:

This form contains 1021 input elements. PHP max_input_vars is 1000 and should be increased.

If I try to save, I have this one in red:

This form could not be submitted because $_POST was truncated to 874 input vars. PHP max_input_vars is 1000 and needs to be increased.

If I increase max_input_vars (for 2000, for example), the first warning disappear, but I still have this message when clicking "save":

This form could not be submitted because $_POST was truncated to 874 input vars. PHP max_input_vars is 2000 and needs to be increased.

even if the value has change...

I also have another message telling me:

More than one conditional hides or shows component "NAME"...

But I don't think it is important in this case...

DanChadwick’s picture

The value reported may not be the value actually limiting your php installation. You need to actually increase the limit. Google and a debugger are your friends. These messages from webform are just there to alert you of your configuration's limitation. If the conditionals aren't saving, the likely cause is php limiting the input vars in the form POST.

fumble’s picture

Yes, that was because of suhosin.

What I didn't know is, that in the php.ini file, I need to increase the max_input_vars but those two too:

suhosin.post.max_vars and suhosin.request.max_vars

My form is now working ok again.

Thanks again!

joelstein’s picture

I realize this is a closed issue, but I just want to report that we're seeing a similar message with several websites on a server that has a max_input_vars of 2000 and is not using Suhosin:

POST truncated to 63 input vars. PHP max_input_vars is 2000. Increase max_input_vars

Could we possibly read directly from php://input if Webform detects that the POST has been truncated?