1

a strange thing is on my testing server: I set max_input_vars to just 100 and sent a huge request with over 100 elements

I used:

$num=count($_REQUEST, COUNT_RECURSIVE);
$max=ini_get('max_input_vars');
if($max - $num<50) {
              die('Number of requests ('.$num.') near the maximum allowed value of max_input_vars:'.ini_get('max_input_vars'));
}

but I get the error

Number of requests (90) near the maximum allowed value of max_input_vars:100

why just 90? shouldnt it be 100 then or 99?

I get 240 vars in $_REQUEST if I set a higher limit, to be precise:

  • $_GET: 1
  • $_POST: 239
  • $_COOKIE: 1
rubo77
  • 19,527
  • 31
  • 134
  • 226
  • Are you sure you're sending over 100 _uniquely named_ input fields? `max_input_vars` does not account for unique names (if I send `field_name` twice, it will count as 2 input vars), but they will only be put in `$_REQUEST` once (with preference towards the more recent). – Colin M Sep 30 '13 at 12:59
  • yes, I am sure, If I set a higher limit, I get 240 with the same count and the same repuest – rubo77 Sep 30 '13 at 13:10
  • 1
    Do you have any arrays in your `$_REQUEST` values? – Pitchinnate Sep 30 '13 at 13:34
  • 1
    Yes I have many arrays in the request. – rubo77 Oct 03 '13 at 16:35

1 Answers1

0

max_input_vars doesen't count the subarray containers while count($a, COUNT_RECURSIVE) does, so you have to use a recursive loop instead:

$count = 0;
array_walk_recursive($_REQUEST, function($v) use(&$count) {
    if(!is_object($v)) ++$count;      //or if(is_string($v))
});
rubo77
  • 19,527
  • 31
  • 134
  • 226