PHP max_input_vars limit
If you tried submitting a form which contained more than a thousand fields, PHP would happiliy accept it and things would proceed normally. Till PHP 5.3.8, that is. PHP 5.3.9 introduced a configuration setting called max_input_vars (default value 1000) which limits the number of variables that will be parsed by PHP engine from client requests. This, I understand, is to prevent DDOS attacks where a payload of high number of variables might be sent for PHP to parse. Sometimes, this value also kicks in for older versions of PHP (see http://stackoverflow.com/questions/10303714/php-max-input-vars, check the output of your server's phpinfo() for this variable.
An interesting point is that max_input_vars is that its changeability is PHP_INI_PERDIR, which means that it cannot be changed during runtime. The only places you could specify this value are php.ini, .htaccess, httpd.conf or .user.ini - all of which would need the server to be restarted.
A side-effect of this setting is parse_str(). This function is also subjected to the limit specified by max_input_vars - which is not clearly documented. Even the father of PHP, Rasmus Lerdorf, thinks that this is unintuitive.
Instead of changing this variable to 2000 today (when you might need to change it to 3000 later and so on), I believe breaking up longer forms into multiple parts might be a better solution. Regarding, parse_str, I hope they introduce an optional parameter to override the limit.
Comments